Options
All
  • Public
  • Public/Protected
  • All
Menu

The FileService is the common facade responsible for all interactions with file systems. It manages all registered FileSystemProviders and forwards calls to the responsible FileSystemProvider, determined by the scheme. For additional documentation regarding the provided functions see also FileSystemProvider.

Hierarchy

  • FileService

Index

Constructors

Properties

Accessors

Methods

Constructors

Properties

BUFFER_SIZE: number = ...
activations: Map<string, Promise<FileSystemProvider>> = ...
activeWatchers: Map<string, { count: number; disposable: Disposable }> = ...
contributions: ContributionProvider<FileServiceContribution>
correlationIds: number = 0
encodingRegistry: EncodingRegistry
encodingService: EncodingService
labelProvider: LabelProvider
onDidChangeFileSystemProviderCapabilities: Event<FileSystemProviderCapabilitiesChangeEvent> = ...
onDidChangeFileSystemProviderCapabilitiesEmitter: Emitter<FileSystemProviderCapabilitiesChangeEvent> = ...
onDidChangeFileSystemProviderRegistrations: Event<FileSystemProviderRegistrationEvent> = ...
onDidChangeFileSystemProviderRegistrationsEmitter: Emitter<FileSystemProviderRegistrationEvent> = ...
onDidFailUserOperation: Event<UserFileOperationEvent> = ...

An event that is emitted when file operation is failed. This event is triggered by user gestures.

onDidFailUserOperationEmitter: AsyncEmitter<UserFileOperationEvent> = ...
onDidFilesChangeEmitter: Emitter<FileChangesEvent> = ...
onDidRunOperation: Event<FileOperationEvent> = ...

An event that is emitted when operation is finished. This event is triggered by user gestures and programmatically.

onDidRunOperationEmitter: Emitter<FileOperationEvent> = ...
onDidRunUserOperation: Event<UserFileOperationEvent> = ...

An event that is emitted when file operation is finished. This event is triggered by user gestures.

onDidRunUserOperationEmitter: AsyncEmitter<UserFileOperationEvent> = ...
onWillActivateFileSystemProvider: Event<FileSystemProviderActivationEvent> = ...

See FileServiceContribution.registerProviders.

onWillActivateFileSystemProviderEmitter: Emitter<FileSystemProviderActivationEvent> = ...
onWillRunUserOperation: Event<UserFileOperationEvent> = ...

An event that is emitted when file operation is being performed. This event is triggered by user gestures.

onWillRunUserOperationEmitter: AsyncEmitter<UserFileOperationEvent> = ...
participants: FileOperationParticipant[] = []
progressService: ProgressService
providers: Map<string, FileSystemProvider> = ...
watcherErrorHandler: FileSystemWatcherErrorHandler
writeQueues: Map<string, Promise<void>> = ...

Accessors

Methods

  • access(resource: URI, mode?: number): Promise<boolean>
  • Tests a user's permissions for the given resource.

    Parameters

    • resource: URI

      URI of the resource which should be tested.

    • Optional mode: number

      An optional integer that specifies the accessibility checks to be performed. Check FileAccess.Constants for possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. FileAccess.Constants.W_OK | FileAccess.Constants.R_OK). If mode is not defined, FileAccess.Constants.F_OK will be used instead.

    Returns Promise<boolean>

  • Try to activate the registered provider for the given scheme

    Parameters

    • scheme: string

      The uri scheme for which the responsible provider should be activated.

    Returns Promise<FileSystemProvider>

    A promise of the activated file system provider. Only resolves if a provider is available for this scheme, gets rejected otherwise.

  • canHandleResource(resource: URI): boolean
  • doValidateMoveCopy(sourceProvider: FileSystemProvider, source: URI, targetProvider: FileSystemProvider, target: URI, mode: "copy" | "move", overwrite?: boolean): Promise<{ exists: boolean; isSameResourceWithDifferentPathCase: boolean }>
  • doWatch(resource: URI, options: WatchOptions): Promise<Disposable>
  • doWriteUnbuffered(provider: FileSystemProviderWithFileReadWriteCapability, resource: URI, bufferOrReadableOrStreamOrBufferedStream: BinaryBuffer | BinaryBufferReadable | BinaryBufferReadableStream | BinaryBufferReadableBufferedStream): Promise<void>
  • doWriteUnbufferedQueued(provider: FileSystemProviderWithFileReadWriteCapability, resource: URI, bufferOrReadableOrStreamOrBufferedStream: BinaryBuffer | BinaryBufferReadable | BinaryBufferReadableStream | BinaryBufferReadableBufferedStream): Promise<void>
  • ensureWriteQueue(provider: FileSystemProvider, resource: URI, task: (() => Promise<void>)): Promise<void>
  • exists(resource: URI): Promise<boolean>
  • Tests if the given resource exists in the filesystem.

    throws

    Will throw an error if no FileSystemProvider is registered for the given resource.

    Parameters

    • resource: URI

      URI of the resource which should be tested.

    Returns Promise<boolean>

    A promise that resolves to true if the resource exists.

  • fsPath(resource: URI): Promise<string>
  • Resolves the fs path of the given URI.

    USE WITH CAUTION: You should always prefer URIs to paths if possible, as they are portable and platform independent. Paths should only be used in cases you directly interact with the OS, e.g. when running a command on the shell.

    If you need to display human readable simple or long names then use LabelProvider instead.

    throws

    Will throw an error if no FileSystemProvider is registered for the given resource.

    Parameters

    • resource: URI

      URI of the resource that should be resolved.

    Returns Promise<string>

    A promise of the resolved fs path.

  • getEncodingForResource(resource: URI, preferredEncoding?: string): Promise<string>
  • getReadEncoding(resource: URI, options?: ReadEncodingOptions, detectedEncoding?: string): Promise<string>
  • handleFileWatchError(): void
  • init(): void
  • Dirty write prevention: if the file on disk has been changed and does not match our expected mtime and etag, we bail out to prevent dirty writing.

    First, we check for a mtime that is in the future before we do more checks. The assumption is that only the mtime is an indicator for a file that has changed on disk.

    Second, if the mtime has advanced, we compare the size of the file on disk with our previous one using the etag() function. Relying only on the mtime check has proven to produce false positives due to file system weirdness (especially around remote file systems). As such, the check for size is a weaker check because it can return a false negative if the file has changed but to the same length. This is a compromise we take to avoid having to produce checksums of the file content for comparison which would be much slower to compute.

    Parameters

    Returns boolean

  • resourceForError(resource: URI): string
  • runFileOperationParticipants(target: URI, source: undefined | URI, operation: FileOperation): Promise<void>
  • throwIfFileSystemIsReadonly<T>(provider: T, resource: URI): T
  • toUnderlyingResource(resource: URI): Promise<URI>
  • Converts to an underlying fs provider resource format.

    For example converting user-storage resources to file resources under a user home: user-storage:/user/settings.json => file://home/.theia/settings.json

    Parameters

    • resource: URI

    Returns Promise<URI>

  • validateReadFileLimits(resource: URI, size: number, options?: ReadFileOptions): void