Skip to content

Commit

Permalink
move workspace.fs to stable, #48034
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jul 10, 2019
1 parent 5f8aaae commit 046b66f
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 89 deletions.
85 changes: 85 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5753,6 +5753,83 @@ declare module 'vscode' {
copy?(source: Uri, destination: Uri, options: { overwrite: boolean }): void | Thenable<void>;
}

/**
* The file system interface exposes the editor's built-in and contributed
* [file system providers](#FileSystemProvider). 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.
*
* An instance of this interface is provided by [`workspace.fs`](#workspace.fs).
*/
export interface FileSystem {

/**
* Retrieve metadata about a file.
*
* @param uri The uri of the file to retrieve metadata about.
* @return The file metadata about the file.
*/
stat(uri: Uri): Thenable<FileStat>;

/**
* Retrieve all entries of a [directory](#FileType.Directory).
*
* @param uri The uri of the folder.
* @return An array of name/type-tuples or a thenable that resolves to such.
*/
readDirectory(uri: Uri): Thenable<[string, FileType][]>;

/**
* Create a new directory (Note, that new files are created via `write`-calls).
*
* @param uri The uri of the new folder.
*/
createDirectory(uri: Uri): Thenable<void>;

/**
* Read the entire contents of a file.
*
* @param uri The uri of the file.
* @return An array of bytes or a thenable that resolves to such.
*/
readFile(uri: Uri): Thenable<Uint8Array>;

/**
* Write data to a file, replacing its entire contents.
*
* @param uri The uri of the file.
* @param content The new content of the file.
*/
writeFile(uri: Uri, content: Uint8Array): Thenable<void>;

/**
* Delete a file.
*
* @param uri The resource that is to be deleted.
* @param options Defines if trash can should be used and if deletion of folders is recursive
*/
delete(uri: Uri, options?: { recursive?: boolean, useTrash?: boolean }): Thenable<void>;

/**
* Rename a file or folder.
*
* @param oldUri The existing file.
* @param newUri The new location.
* @param options Defines if existing files should be overwritten.
*/
rename(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;

/**
* Copy files or folders. Implementing this function is optional but it will speedup
* the copy operation.
*
* @param source The existing file.
* @param destination The destination location.
* @param options Defines if existing files should be overwritten.
*/
copy(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;
}

/**
* Defines a port mapping used for localhost inside the webview.
*/
Expand Down Expand Up @@ -7525,6 +7602,14 @@ declare module 'vscode' {
*/
export namespace workspace {

/**
* A [file system](#FileSystem) instance that allows to interact with local and remote
* files, e.g. `vscode.workspace.fs.readDirectory(someUri)` allows to retrieve all entries
* of a directory or `vscode.workspace.fs.stat(anotherUri)` returns the meta data for a
* file.
*/
export const fs: FileSystem;

/**
* ~~The folder that is open in the editor. `undefined` when no folder
* has been opened.~~
Expand Down
88 changes: 0 additions & 88 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1612,92 +1612,4 @@ declare module 'vscode' {
}

//#endregion


//#region Joh - read/write files of any scheme

/**
* The file system interface exposes the editor's built-in and contributed
* [file system providers](#FileSystemProvider). 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.
*/
export interface FileSystem {

/**
* Retrieve metadata about a file.
*
* @param uri The uri of the file to retrieve metadata about.
* @return The file metadata about the file.
*/
stat(uri: Uri): Thenable<FileStat>;

/**
* Retrieve all entries of a [directory](#FileType.Directory).
*
* @param uri The uri of the folder.
* @return An array of name/type-tuples or a thenable that resolves to such.
*/
readDirectory(uri: Uri): Thenable<[string, FileType][]>;

/**
* Create a new directory (Note, that new files are created via `write`-calls).
*
* @param uri The uri of the new folder.
*/
createDirectory(uri: Uri): Thenable<void>;

/**
* Read the entire contents of a file.
*
* @param uri The uri of the file.
* @return An array of bytes or a thenable that resolves to such.
*/
readFile(uri: Uri): Thenable<Uint8Array>;

/**
* Write data to a file, replacing its entire contents.
*
* @param uri The uri of the file.
* @param content The new content of the file.
*/
writeFile(uri: Uri, content: Uint8Array): Thenable<void>;

/**
* Delete a file.
*
* @param uri The resource that is to be deleted.
* @param options Defines if trash can should be used and if deletion of folders is recursive
*/
delete(uri: Uri, options?: { recursive?: boolean, useTrash?: boolean }): Thenable<void>;

/**
* Rename a file or folder.
*
* @param oldUri The existing file.
* @param newUri The new location.
* @param options Defines if existing files should be overwritten.
*/
rename(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;

/**
* Copy files or folders. Implementing this function is optional but it will speedup
* the copy operation.
*
* @param source The existing file.
* @param destination The destination location.
* @param options Defines if existing files should be overwritten.
*/
copy(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;
}

export namespace workspace {

/**
* File system that allows to interact with local and remote files.
*/
export const fs: FileSystem;
}

//#endregion
}
1 change: 0 additions & 1 deletion src/vs/workbench/api/node/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ export function createApiFactory(
return extHostFileSystem.registerFileSystemProvider(scheme, provider, options);
},
get fs() {
checkProposedApiEnabled(extension);
return extHostFileSystem.fileSystem;
},
registerFileSearchProvider: proposedApiFunction(extension, (scheme: string, provider: vscode.FileSearchProvider) => {
Expand Down

0 comments on commit 046b66f

Please sign in to comment.