VS Code API
    Preparing search index...

    Interface FileSystemProvider

    The filesystem provider defines what the editor needs to read, write, discover, and to manage files and folders. It allows extensions to serve files from remote places, like ftp-servers, and to seamlessly integrate those into the editor.

    • Note 1: The filesystem provider API works with uris and assumes hierarchical paths, e.g. foo:/my/path is a child of foo:/my/ and a parent of foo:/my/path/deeper.
    • Note 2: There is an activation event onFileSystem:<scheme> that fires when a file or folder is being accessed.
    • Note 3: The word 'file' is often used to denote all kinds of files, e.g. folders, symbolic links, and regular files.
    interface FileSystemProvider {
        onDidChangeFile: Event<FileChangeEvent[]>;
        copy?(
            source: Uri,
            destination: Uri,
            options: { overwrite: boolean },
        ): void | Thenable<void>;
        createDirectory(uri: Uri): void | Thenable<void>;
        delete(uri: Uri, options: { recursive: boolean }): void | Thenable<void>;
        readDirectory(
            uri: Uri,
        ): [string, FileType][] | Thenable<[string, FileType][]>;
        readFile(
            uri: Uri,
        ): Uint8Array<ArrayBufferLike> | Thenable<Uint8Array<ArrayBufferLike>>;
        rename(
            oldUri: Uri,
            newUri: Uri,
            options: { overwrite: boolean },
        ): void | Thenable<void>;
        stat(uri: Uri): FileStat | Thenable<FileStat>;
        watch(
            uri: Uri,
            options: { excludes: readonly string[]; recursive: boolean },
        ): Disposable;
        writeFile(
            uri: Uri,
            content: Uint8Array,
            options: { create: boolean; overwrite: boolean },
        ): void | Thenable<void>;
    }
    Index

    Properties

    onDidChangeFile: Event<FileChangeEvent[]>

    An event to signal that a resource has been created, changed, or deleted. This event should fire for resources that are being watched by clients of this provider.

    Note: It is important that the metadata of the file that changed provides an updated mtime that advanced from the previous value in the stat and a correct size value. Otherwise there may be optimizations in place that will not show the change in an editor for example.

    Methods

    • Copy files or folders. Implementing this function is optional but it will speedup the copy operation.

      Parameters

      • source: Uri

        The existing file.

      • destination: Uri

        The destination location.

      • options: { overwrite: boolean }

        Defines if existing files should be overwritten.

        • Readonlyoverwrite: boolean

          Overwrite the file if it does exist.

      Returns void | Thenable<void>

      FileNotFound when source doesn't exist.

      FileNotFound when parent of destination doesn't exist, e.g. no mkdirp-logic required.

      FileExists when destination exists and when the overwrite option is not true.

      NoPermissions when permissions aren't sufficient.

    • Create a new directory (Note, that new files are created via write-calls).

      Parameters

      • uri: Uri

        The uri of the new folder.

      Returns void | Thenable<void>

      FileNotFound when the parent of uri doesn't exist, e.g. no mkdirp-logic required.

      FileExists when uri already exists.

      NoPermissions when permissions aren't sufficient.

    • Delete a file.

      Parameters

      • uri: Uri

        The resource that is to be deleted.

      • options: { recursive: boolean }

        Defines if deletion of folders is recursive.

        • Readonlyrecursive: boolean

          Delete the content recursively if a folder is denoted.

      Returns void | Thenable<void>

      FileNotFound when uri doesn't exist.

      NoPermissions when permissions aren't sufficient.

    • Rename a file or folder.

      Parameters

      • oldUri: Uri

        The existing file.

      • newUri: Uri

        The new location.

      • options: { overwrite: boolean }

        Defines if existing files should be overwritten.

        • Readonlyoverwrite: boolean

          Overwrite the file if it does exist.

      Returns void | Thenable<void>

      FileNotFound when oldUri doesn't exist.

      FileNotFound when parent of newUri doesn't exist, e.g. no mkdirp-logic required.

      FileExists when newUri exists and when the overwrite option is not true.

      NoPermissions when permissions aren't sufficient.

    • Retrieve metadata about a file.

      Note that the metadata for symbolic links should be the metadata of the file they refer to. Still, the SymbolicLink-type must be used in addition to the actual type, e.g. FileType.SymbolicLink | FileType.Directory.

      Parameters

      • uri: Uri

        The uri of the file to retrieve metadata about.

      Returns FileStat | Thenable<FileStat>

      The file metadata about the file.

      FileNotFound when uri doesn't exist.

    • Subscribes to file change events in the file or folder denoted by uri. For folders, the option recursive indicates whether subfolders, sub-subfolders, etc. should be watched for file changes as well. With recursive: false, only changes to the files that are direct children of the folder should trigger an event.

      The excludes array is used to indicate paths that should be excluded from file watching. It is typically derived from the files.watcherExclude setting that is configurable by the user. Each entry can be be:

      • the absolute path to exclude
      • a relative path to exclude (for example build/output)
      • a simple glob pattern (for example **​/build, output/**)

      Note that case-sensitivity of the excludes patterns for built-in file system providers will depend on the underlying file system: on Windows and macOS the matching will be case-insensitive and on Linux it will be case-sensitive.

      It is the file system provider's job to call onDidChangeFile for every change given these rules. No event should be emitted for files that match any of the provided excludes.

      Parameters

      • uri: Uri

        The uri of the file or folder to be watched.

      • options: { excludes: readonly string[]; recursive: boolean }

        Configures the watch.

        • Readonlyexcludes: readonly string[]

          A list of paths and pattern to exclude from watching.

        • Readonlyrecursive: boolean

          When enabled also watch subfolders.

      Returns Disposable

      A disposable that tells the provider to stop watching the uri.

    • Write data to a file, replacing its entire contents.

      Parameters

      • uri: Uri

        The uri of the file.

      • content: Uint8Array

        The new content of the file.

      • options: { create: boolean; overwrite: boolean }

        Defines if missing files should or must be created.

        • Readonlycreate: boolean

          Create the file if it does not exist already.

        • Readonlyoverwrite: boolean

          Overwrite the file if it does exist.

      Returns void | Thenable<void>

      FileNotFound when uri doesn't exist and create is not set.

      FileNotFound when the parent of uri doesn't exist and create is set, e.g. no mkdirp-logic required.

      FileExists when uri already exists, create is set but overwrite is not set.

      NoPermissions when permissions aren't sufficient.