FileSystemModuleRootResolver

class FileSystemModuleRootResolver(val name: String, val uri: URI, val fileManager: FileManager) : ModuleRootResolver

FileSystemModuleRootResolver is a ModuleRootResolver used for accessing a ModuleRoot from the local file system.

Author

Richard Arriaga

Parameters

name

The name of the module root.

uri

The URI that identifies the location of the ModuleRoot.

fileManager

The FileManager used to manage the files accessed via this FileSystemModuleRootResolver.

Constructors

Link copied to clipboard
constructor(name: String, uri: URI, fileManager: FileManager)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
inner class FileSystemWatcher

FileSystemWatcher manages the WatchService responsible for watching the local file system directories of the ModuleRoots loaded into the AvailRuntime.

Properties

Link copied to clipboard

The qualified names of all the modules known by this resolver.

Link copied to clipboard
open override val canSave: Boolean

Answer whether data can be written to modules under this resolver. Note that this may be further restricted by choosing to use the root as a read-only source. See AvailWorkbench.getProjectRoot.

Link copied to clipboard

The FileManager used for pooling I/O requests for this root.

Link copied to clipboard
Link copied to clipboard

The name of this root.

Link copied to clipboard
val uri: URI

The URI that identifies the location of the ModuleRoot.

Link copied to clipboard

The Map from a UUID that represents an interested party to a lambda that accepts a WatchEventType that describes the event that occurred at the source location and a ResolverReference that identifies to what the event occurred to.

Functions

Link copied to clipboard
open override fun close()

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

Link copied to clipboard
open override fun createDirectory(qualifiedName: String, completion: () -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Create a directory.

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

Create a file.

Link copied to clipboard
open override fun createPackage(qualifiedName: String, completion: () -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Create a package and its representative Avail module.

Link copied to clipboard
open override fun deleteResource(qualifiedName: String, completion: () -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Delete the ResourceType linked to the qualified name. If the ResourceType is a ResourceType.PACKAGE or a ResourceType.DIRECTORY, all of its children should be deleted as well. All deleted references should be removed from the reference tree.

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

Asynchronously execute the provided task.

Link copied to clipboard

Answer a AbstractFileWrapper for the targeted file.

Link copied to clipboard
open fun find(qualifiedName: ModuleName, initialCanonicalName: ModuleName, moduleNameResolver: ModuleNameResolver): ModuleNameResolver.ModuleNameResolutionResult?

Answer a ModuleNameResolver.ModuleNameResolutionResult when attempting to locate a module in this ModuleRootResolver.

Link copied to clipboard
fun fullResourceURI(qualifiedName: String): URI

Answer the URI for a resource in the source moduleRoot given a qualified name. There is no guarantee the target exists.

Link copied to clipboard
fun getQualifiedName(targetURI: String): String

Answer a qualified name for the given URI that points to a file in the moduleRoot.

Link copied to clipboard
open fun getResolverReference(qualifiedName: String): ResolverReference?

Answer the ResolverReference for the given qualified file name for a a file in moduleRoot.

Link copied to clipboard
open fun provideModuleRootTree(successHandler: (ResolverReference) -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Provide the non-null ResolverReference that represents the moduleRoot. There is no guarantee made by this interface as to how this should be run. It can be all executed on the calling thread or it can be executed on a separate thread.

Link copied to clipboard
open fun provideResolverReference(qualifiedName: String, withReference: (ResolverReference) -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Provide the ResolverReference for the given qualified file name for a file in moduleRoot.

Link copied to clipboard
open override fun readFile(bypassFileManager: Boolean, reference: ResolverReference, withContents: (ByteArray, UUID?) -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

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

Link copied to clipboard
fun referencesMatchingAbbreviation(abbreviation: String, ignoreCase: Boolean = false): List<ResolverReference>

Answer all the ResolverReferences known by this ModuleRootResolver that have a qualified name that matches the supplied abbreviation.

Link copied to clipboard
open override fun refreshResolverMetaData(reference: ResolverReference, successHandler: (Long) -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Specifically refresh the ResolverReference mutable state:

Link copied to clipboard
open override fun refreshResolverReferenceDigest(reference: ResolverReference, successHandler: (ByteArray, Long) -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Specifically refresh the ResolverReference.digest in the Repository.ModuleArchive for the most recent ResolverReference.lastModified timestamp. This also refreshes the metrics (mutable state) of the provided ResolverReference. It should refresh:

Link copied to clipboard
open override fun resolve(successHandler: (ResolverReference) -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Connect to the source of the moduleRoot and populate this resolver with all the ResolverReferences from the module root. This is not required nor expected to be executed in the calling thread.

Link copied to clipboard
fun resolverReference(path: Path, qualifiedName: String, type: ResourceType?): ResolverReference

Answer the ResolverReference for the given absolute Path.

Link copied to clipboard
open override fun resolvesToValidModuleRoot(): Boolean
Link copied to clipboard
open override fun rootManifest(forceRefresh: Boolean, withList: (List<ResolverReference>) -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Provide the full list of all ResolverReferences in this ModuleRootResolver.

Link copied to clipboard
open override fun saveFile(reference: ResolverReference, fileContents: ByteArray, successHandler: () -> Unit, failureHandler: (ErrorCode, Throwable?) -> Unit)

Save the file to where it is stored.

Link copied to clipboard

Subscribe to receive notifications of WatchEventTypes occurring to this ModuleRoot.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Remove a watch subscription.