Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

  • FileSystemProvider

Index

Properties(1)

Readonly onDidChangeFile

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(9)

watch

  • watch(uri: Uri, options: { recursive: boolean; excludes: readonly string[] }): Disposable
  • 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/**)

    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: { recursive: boolean; excludes: readonly string[] }

      Configures the watch.

      • Readonly recursive: boolean

        When enabled also watch subfolders.

      • Readonly excludes: readonly string[]

        A list of paths and pattern to exclude from watching.

    Returns Disposable

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

stat

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

    throws

    FileNotFound when uri doesn't exist.

    Parameters

    • uri: Uri

      The uri of the file to retrieve metadata about.

    Returns FileStat | Thenable<FileStat>

    The file metadata about the file.

readDirectory

createDirectory

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

    throws

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

    throws

    FileExists when uri already exists.

    throws

    NoPermissions when permissions aren't sufficient.

    Parameters

    • uri: Uri

      The uri of the new folder.

    Returns void | Thenable<void>

readFile

  • readFile(uri: Uri): Uint8Array | Thenable<Uint8Array>
  • Read the entire contents of a file.

    throws

    FileNotFound when uri doesn't exist.

    Parameters

    • uri: Uri

      The uri of the file.

    Returns Uint8Array | Thenable<Uint8Array>

    An array of bytes or a thenable that resolves to such.

writeFile

  • writeFile(uri: Uri, content: Uint8Array, options: { create: boolean; overwrite: boolean }): void | Thenable<void>
  • Write data to a file, replacing its entire contents.

    throws

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

    throws

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

    throws

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

    throws

    NoPermissions when permissions aren't sufficient.

    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.

      • Readonly create: boolean

        Create the file if it does not exist already.

      • Readonly overwrite: boolean

        Overwrite the file if it does exist.

    Returns void | Thenable<void>

delete

  • delete(uri: Uri, options: { recursive: boolean }): void | Thenable<void>
  • Delete a file.

    throws

    FileNotFound when uri doesn't exist.

    throws

    NoPermissions when permissions aren't sufficient.

    Parameters

    • uri: Uri

      The resource that is to be deleted.

    • options: { recursive: boolean }

      Defines if deletion of folders is recursive.

      • Readonly recursive: boolean

        Delete the content recursively if a folder is denoted.

    Returns void | Thenable<void>

rename

  • rename(oldUri: Uri, newUri: Uri, options: { overwrite: boolean }): void | Thenable<void>
  • Rename a file or folder.

    throws

    FileNotFound when oldUri doesn't exist.

    throws

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

    throws

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

    throws

    NoPermissions when permissions aren't sufficient.

    Parameters

    • oldUri: Uri

      The existing file.

    • newUri: Uri

      The new location.

    • options: { overwrite: boolean }

      Defines if existing files should be overwritten.

      • Readonly overwrite: boolean

        Overwrite the file if it does exist.

    Returns void | Thenable<void>

Optional copy

  • copy(source: Uri, destination: Uri, options: { overwrite: boolean }): void | Thenable<void>
  • Copy files or folders. Implementing this function is optional but it will speedup the copy operation.

    throws

    FileNotFound when source doesn't exist.

    throws

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

    throws

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

    throws

    NoPermissions when permissions aren't sufficient.

    Parameters

    • source: Uri

      The existing file.

    • destination: Uri

      The destination location.

    • options: { overwrite: boolean }

      Defines if existing files should be overwritten.

      • Readonly overwrite: boolean

        Overwrite the file if it does exist.

    Returns void | Thenable<void>

Generated by TypeDoc. Maintained by 紫升

Links: 搜外友链, 69中文网