FileManager

open class FileManager

FileManager manages the access to the source and resource files in Avail s. It provides an LRU caching mechanism by which open files can be added and removed as needed to control the number of open files in memory.

Author

Richard Arriaga

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The IOSystem used by this FileManager.

Functions

Link copied to clipboard

Associate an AvailRuntime with this FileManager.

Link copied to clipboard

Check if interest in the file associated with the provided fileCache id still exists (interest count 0). If there is no file interest the file is closed and fully removed from the fileCache.

Link copied to clipboard
open fun close()

Close this FileManager. Should be called at shutdown to ensure proper clean up of any open resources.

Link copied to clipboard
fun createFile(qualifiedName: String, mimeType: String, resolver: ModuleRootResolver, completion: () -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Create a file.

Link copied to clipboard
fun delete(reference: ResolverReference, success: (UUID?) -> Unit, failure: (ErrorCode, Throwable?) -> Unit)

Delete the file at the provided ResolverReference.

Link copied to clipboard
fun deregisterInterest(id: UUID, interestedPartId: UUID? = null)

Deregister interest in the file associated with the provided fileCache id. If the resulting interest count is 0, the file is closed and fully removed from the fileCache.

Link copied to clipboard
fun executeAction(id: UUID, fileAction: FileAction, originator: UUID, continuation: () -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Retrieve the ManagedFileWrapper and provide it with a request to obtain the raw file bytes.

Link copied to clipboard
fun executeFileTask(task: () -> Unit)

Schedule the specified task for eventual execution by the thread pool executor for asynchronous file operations. The implementation is free to run the task immediately or delay its execution arbitrarily. The task will not execute on an Avail thread.

Link copied to clipboard
fun fileId(resolverReference: ResolverReference): UUID?

Answer the FileManager file id for the provided ResolverReference.

Link copied to clipboard
fun optionallyProvideExistingFile(resolverReference: ResolverReference, successHandler: (UUID, AvailFile) -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit): Boolean

Attempt to provide a file if it already exists in this FileManager without directly requesting it be added.

Link copied to clipboard
open fun readFile(qualifiedName: String, resolver: ModuleRootResolver, withFile: (UUID, String, AvailFile) -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Retrieve the AbstractFileWrapper and provide it with a request to obtain the raw file bytes.

Link copied to clipboard
fun remove(id: UUID)

Fully remove the file associated with the provided fileCache id. This also removes it from resolverRefToId.

Link copied to clipboard

Answer the AvailRuntime associated with this FileManager.

Link copied to clipboard
fun saveFile(availFile: AvailFile, failureHandler: (ErrorCode, Throwable?) -> Unit)

Save the AvailFile to where it is stored.