The file system interface exposes the editor's built-in and contributed {@link FileSystemProvider file system providers}. It allows extensions to work with files from the local disk as well as files from remote places, like the remote extension host or ftp-servers.

Note that an instance of this interface is available as {@linkcode workspace.fs}.

Fields

writeFile(uri:Uri, content:Uint8Array):Thenable<Void>

Write data to a file, replacing its entire contents.

Parameters:

uri

The uri of the file.

content

The new content of the file.

stat(uri:Uri):Thenable<FileStat>

Retrieve metadata about a file.

Parameters:

uri

The uri of the file to retrieve metadata about.

Returns:

The file metadata about the file.

rename(source:Uri, target:Uri, ?options:{overwrite:Null<Bool>}):Thenable<Void>

Rename a file or folder.

Parameters:

oldUri

The existing file.

newUri

The new location.

options

Defines if existing files should be overwritten.

readFile(uri:Uri):Thenable<Uint8Array>

Read the entire contents of a file.

Parameters:

uri

The uri of the file.

Returns:

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

readDirectory(uri:Uri):Thenable<Array<FileSystemReadDirectoryTuple>>

Retrieve all entries of a {@link FileType.Directory directory}.

Parameters:

uri

The uri of the folder.

Returns:

An array of name/type-tuples or a thenable that resolves to such.

isWritableFileSystem(scheme:String):Null<Bool>

Check if a given file system supports writing files.

Keep in mind that just because a file system supports writing, that does not mean that writes will always succeed. There may be permissions issues or other errors that prevent writing a file.

Parameters:

scheme

The scheme of the filesystem, for example file or git.

Returns:

true if the file system supports writing, false if it does not support writing (i.e. it is readonly), and undefined if the editor does not know about the filesystem.

delete(uri:Uri, ?options:{useTrash:Null<Bool>, recursive:Null<Bool>}):Thenable<Void>

Delete a file.

Parameters:

uri

The resource that is to be deleted.

options

Defines if trash can should be used and if deletion of folders is recursive

createDirectory(uri:Uri):Thenable<Void>

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

Note that missing directories are created automatically, e.g this call has mkdirp semantics.

Parameters:

uri

The uri of the new folder.

copy(source:Uri, target:Uri, ?options:{overwrite:Null<Bool>}):Thenable<Void>

Copy files or folders.

Parameters:

source

The existing file.

destination

The destination location.

options

Defines if existing files should be overwritten.