From 046b66fb8f85584c918b9559e35f7efa0803c3ff Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 10 Jul 2019 16:20:10 +0200 Subject: [PATCH] move workspace.fs to stable, #48034 --- src/vs/vscode.d.ts | 85 ++++++++++++++++++ src/vs/vscode.proposed.d.ts | 88 ------------------- src/vs/workbench/api/node/extHost.api.impl.ts | 1 - 3 files changed, 85 insertions(+), 89 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 6f326cc55aaf3..2027771b9166c 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -5753,6 +5753,83 @@ declare module 'vscode' { copy?(source: Uri, destination: Uri, options: { overwrite: boolean }): void | Thenable; } + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + + /** + * 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; + } + /** * Defines a port mapping used for localhost inside the webview. */ @@ -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.~~ diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 69d8c29c1cdad..33a93a228cd3f 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -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; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * 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; - - /** - * 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; - } - - export namespace workspace { - - /** - * File system that allows to interact with local and remote files. - */ - export const fs: FileSystem; - } - - //#endregion } diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 7fbbabb3564a9..2f2235d1a71dc 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -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) => {