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

Methods

Constructors

constructor

Properties

Private Readonly BUFFER_SIZE

BUFFER_SIZE: number = ...

Private Readonly activations

activations: Map<string, Promise<FileSystemProvider>> = ...

Private activeWatchers

activeWatchers: Map<string, { count: number; disposable: Disposable }> = ...

Protected Readonly contributions

contributions: ContributionProvider<FileServiceContribution>

Private correlationIds

correlationIds: number = 0

Protected Readonly encodingRegistry

encodingRegistry: EncodingRegistry

Protected Readonly encodingService

encodingService: EncodingService

Protected Readonly labelProvider

labelProvider: LabelProvider

Readonly onDidChangeFileSystemProviderCapabilities

onDidChangeFileSystemProviderCapabilities: Event<FileSystemProviderCapabilitiesChangeEvent> = ...

Private onDidChangeFileSystemProviderCapabilitiesEmitter

onDidChangeFileSystemProviderCapabilitiesEmitter: Emitter<FileSystemProviderCapabilitiesChangeEvent> = ...

Readonly onDidChangeFileSystemProviderRegistrations

onDidChangeFileSystemProviderRegistrations: Event<FileSystemProviderRegistrationEvent> = ...

Private onDidChangeFileSystemProviderRegistrationsEmitter

onDidChangeFileSystemProviderRegistrationsEmitter: Emitter<FileSystemProviderRegistrationEvent> = ...

Readonly onDidFailUserOperation

onDidFailUserOperation: Event<UserFileOperationEvent> = ...

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

Private Readonly onDidFailUserOperationEmitter

onDidFailUserOperationEmitter: AsyncEmitter<UserFileOperationEvent> = ...

Readonly onDidFilesChange

onDidFilesChange: Event<FileChangesEvent> = ...

An event that is emitted when files are changed on the disk.

Private onDidFilesChangeEmitter

onDidFilesChangeEmitter: Emitter<FileChangesEvent> = ...

Readonly onDidRunOperation

onDidRunOperation: Event<FileOperationEvent> = ...

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

Private onDidRunOperationEmitter

onDidRunOperationEmitter: Emitter<FileOperationEvent> = ...

Readonly onDidRunUserOperation

onDidRunUserOperation: Event<UserFileOperationEvent> = ...

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

Private Readonly onDidRunUserOperationEmitter

onDidRunUserOperationEmitter: AsyncEmitter<UserFileOperationEvent> = ...

Readonly onWillActivateFileSystemProvider

onWillActivateFileSystemProvider: Event<FileSystemProviderActivationEvent> = ...

See FileServiceContribution.registerProviders.

Private onWillActivateFileSystemProviderEmitter

onWillActivateFileSystemProviderEmitter: Emitter<FileSystemProviderActivationEvent> = ...

Readonly onWillRunUserOperation

onWillRunUserOperation: Event<UserFileOperationEvent> = ...

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

Private Readonly onWillRunUserOperationEmitter

onWillRunUserOperationEmitter: AsyncEmitter<UserFileOperationEvent> = ...

Private Readonly participants

participants: FileOperationParticipant[] = []

Protected Readonly preferences

preferences: PreferenceProxy<FileSystemConfiguration>

Protected Readonly progressService

progressService: ProgressService

Private Readonly providers

providers: Map<string, FileSystemProvider> = ...

Protected Readonly watcherErrorHandler

watcherErrorHandler: FileSystemWatcherErrorHandler

Private writeQueues

writeQueues: Map<string, Promise<void>> = ...

Methods

access

  • access(resource: default, mode?: number): Promise<boolean>

activateProvider

  • 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.

addFileOperationParticipant

Protected asFileOperationError

canHandleResource

  • canHandleResource(resource: default): boolean

copy

create

createFile

createFolder

delete

Protected doCopy

Private doCopyFile

Private doCopyFolder

Protected doCreate

Protected doDelete

Protected doMove

Private doMoveCopy

  • doMoveCopy(sourceProvider: FileSystemProvider, source: default, targetProvider: FileSystemProvider, target: default, mode: "copy" | "move", overwrite: boolean): Promise<"copy" | "move">

Private doPipeBuffered

Private doPipeBufferedQueued

Private doPipeBufferedToUnbuffered

Private doPipeUnbuffered

Private doPipeUnbufferedQueued

Private doPipeUnbufferedToBuffered

Private doPipeUnbufferedToBufferedQueued

Private doRead

Private doReadAsFileStream

Private doResolveFile

Private doValidateMoveCopy

  • doValidateMoveCopy(sourceProvider: FileSystemProvider, source: default, targetProvider: FileSystemProvider, target: default, mode: "copy" | "move", overwrite?: boolean): Promise<{ exists: boolean; isSameResourceWithDifferentPathCase: boolean }>

doWatch

  • doWatch(resource: default, options: WatchOptions): Promise<Disposable>

Private doWriteBuffer

Private doWriteBuffered

Private doWriteReadableBufferedQueued

Private doWriteStreamBufferedQueued

Private doWriteUnbuffered

  • doWriteUnbuffered(provider: FileSystemProviderWithFileReadWriteCapability, resource: default, bufferOrReadableOrStreamOrBufferedStream: BinaryBuffer | BinaryBufferReadable | BinaryBufferReadableStream | BinaryBufferReadableBufferedStream): Promise<void>

Private doWriteUnbufferedQueued

  • doWriteUnbufferedQueued(provider: FileSystemProviderWithFileReadWriteCapability, resource: default, bufferOrReadableOrStreamOrBufferedStream: BinaryBuffer | BinaryBufferReadable | BinaryBufferReadableStream | BinaryBufferReadableBufferedStream): Promise<void>

Private ensureWriteQueue

  • ensureWriteQueue(provider: FileSystemProvider, resource: default, task: () => Promise<void>): Promise<void>

exists

  • exists(resource: default): 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: default

      URI of the resource which should be tested.

    Returns Promise<boolean>

    A promise that resolves to true if the resource exists.

fsPath

  • fsPath(resource: default): 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: default

      URI of the resource that should be resolved.

    Returns Promise<string>

    A promise of the resolved fs path.

Protected getEncodingForResource

  • getEncodingForResource(resource: default, preferredEncoding?: string): Promise<string>

Protected getReadEncoding

  • getReadEncoding(resource: default, options?: ReadEncodingOptions, detectedEncoding?: string): Promise<string>

Protected getWriteEncoding

Protected handleFileWatchError

  • handleFileWatchError(): void

hasCapability

Protected init

  • init(): void

Private mkdirp

Protected modifiedSince

  • 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

move

Private progressLabel

read

readFile

Private readFileBuffered

readFileStream

Private readFileStreamed

Private readFileUnbuffered

readStream

registerProvider

resolve

resolveAll

Protected resolveReadOptions

Private resourceForError

  • resourceForError(resource: default): string

Protected rethrowAsFileOperationError

runFileOperationParticipants

  • runFileOperationParticipants(target: default, source: undefined | default, operation: FileOperation): Promise<void>

Protected throwIfFileSystemIsReadonly

  • throwIfFileSystemIsReadonly<T>(provider: T, resource: default): T

Private toFileStat

Private toMapKey

toUnderlyingResource

  • toUnderlyingResource(resource: default): Promise<default>
  • 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: default

    Returns Promise<default>

Private toWatchKey

update

Private validateReadFile

Private validateReadFileLimits

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

Private validateWriteFile

watch

  • watch(resource: default, options?: WatchOptions): Disposable

Protected withProvider

Private withReadProvider

Private withWriteProvider

write

writeFile

  • writeFile(resource: default, bufferOrReadableOrStream: BinaryBuffer | BinaryBufferReadable | BinaryBufferReadableStream, options?: WriteFileOptions): Promise<FileStatWithMetadata>