app / com.otago.open / PDFOperations

PDFOperations

object PDFOperations

Common operations for PDF files / course folders

Functions

createMetaFile

Creates a meta file for the file indicated via saveFile based on the FetchResult This creates the file saveFile.meta

fun createMetaFile(saveFile: String, it: FetchResult): Unit

Creates a meta file for the file indicated via saveFolder and fileName based on the FetchResult

fun createMetaFile(saveFolder: String, fileName: String, it: FetchResult): Unit

determinePath

Determines where a href on a page given by onPageUrl should point, if onPageUrl is a file (i.e. no forward slash), otherwise when in the folder given by onPageUrl it determines where the sub-resource would be located

fun determinePath(onPageUrl: String, href: String): String

downloadFile

Downloads a file at url to the file parentDir/fileName using a HTTP GET

fun downloadFile(url: String, parentDir: String, fileName: String): String?

downloadPDF

Downloads a PDF using the downloadFile logic.

fun downloadPDF(pdfFile: FetchResult): String?

fetchLinks

Retrieve links from a table containing href elements.

fun fetchLinks(parentFolder: String, url: String, doFolders: Boolean): ArrayList<FetchResult>?

generatePdfItems

Creates PDFItems from FetchResults by deciding on the pretty name and the icon to use.

fun generatePdfItems(fetched: List<FetchResult>): List<PDFItem>

loadMetaFile

Loads a meta file for the resource assFile (associated file), i.e. the loaded meta file will be assFile.meta

fun loadMetaFile(assFile: String): FetchResult?