FileSystemProvider
interfaceThe 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.
Import
import { FileSystemProvider } from '@modular/sdk/view';Members10
- 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.
- copy()optional
(source: Uri, destination: Uri, options: { /** * Overwrite the file if it does exist. */ readonly overwrite: boolean; }) => void | Thenable<void>Copy files or folders. Implementing this function is optional but it will speedup the copy operation.
- createDirectory()
(uri: Uri) => void | Thenable<void>Create a new directory (Note, that new files are created via `write`-calls).
- delete()
(uri: Uri, options: { /** * Delete the content recursively if a folder is denoted. */ readonly recursive: boolean; }) => void | Thenable<void>Delete a file.
- readDirectory()
(uri: Uri) => [string, FileType][] | Thenable<[string, FileType][]>Retrieve all entries of a directory.
- readFile()
(uri: Uri) => Uint8Array | Thenable<Uint8Array>Read the entire contents of a file.
- rename()
(oldUri: Uri, newUri: Uri, options: { /** * Overwrite the file if it does exist. */ readonly overwrite: boolean; }) => void | Thenable<void>Rename a file or folder.
- stat()
(uri: Uri) => FileStat | Thenable<FileStat>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`.
- watch()
(uri: Uri, options: { /** * When enabled also watch subfolders. */ readonly recursive: boolean; /** * A list of paths and pattern to exclude from watching. */ readonly excludes: readonly string[]; }) => DisposableSubscribes 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.
- writeFile()
(uri: Uri, content: Uint8Array, options: { /** * Create the file if it does not exist already. */ readonly create: boolean; /** * Overwrite the file if it does exist. */ readonly overwrite: boolean; }) => void | Thenable<void>Write data to a file, replacing its entire contents.