提交 65270230 编写于 作者: J Johannes Rieken

tweak options for delete and write, #48034

上级 a4fc9bb8
......@@ -83,7 +83,7 @@ suite('workspace-fs', () => {
// ensure non empty folder cannot be deleted
try {
await vscode.workspace.fs.delete(folder, { recursive: false });
await vscode.workspace.fs.delete(folder, { recursive: false, useTrash: false });
assert.ok(false);
} catch {
await vscode.workspace.fs.stat(folder);
......@@ -100,7 +100,7 @@ suite('workspace-fs', () => {
}
// delete non empty folder with recursive-flag
await vscode.workspace.fs.delete(folder, { recursive: true });
await vscode.workspace.fs.delete(folder, { recursive: true, useTrash: false });
// esnure folder/file are gone
try {
......
......@@ -1638,17 +1638,16 @@ declare module 'vscode' {
*
* @param uri The uri of the file.
* @param content The new content of the file.
* @param options Defines if missing files should or must be created.
*/
writeFile(uri: Uri, content: Uint8Array, options?: { create: boolean, overwrite: boolean }): Thenable<void>;
writeFile(uri: Uri, content: Uint8Array): Thenable<void>;
/**
* Delete a file.
*
* @param uri The resource that is to be deleted.
* @param options Defines if deletion of folders is recursive.
* @param options Defines if trash can should be used and if deletion of folders is recursive
*/
delete(uri: Uri, options?: { recursive: boolean }): Thenable<void>;
delete(uri: Uri, options?: { recursive: boolean, useTrash: boolean }): Thenable<void>;
/**
* Rename a file or folder.
......
......@@ -79,9 +79,8 @@ export class MainThreadFileSystem implements MainThreadFileSystemShape {
return this._fileService.readFile(URI.revive(uri)).then(file => file.value).catch(MainThreadFileSystem._handleError);
}
$writeFile(uri: UriComponents, content: VSBuffer, opts: FileWriteOptions): Promise<void> {
//todo@joh honor opts
return this._fileService.writeFile(URI.revive(uri), content, {}).catch(MainThreadFileSystem._handleError);
$writeFile(uri: UriComponents, content: VSBuffer): Promise<void> {
return this._fileService.writeFile(URI.revive(uri), content).catch(MainThreadFileSystem._handleError);
}
$rename(source: UriComponents, target: UriComponents, opts: FileOverwriteOptions): Promise<void> {
......
......@@ -612,7 +612,7 @@ export interface MainThreadFileSystemShape extends IDisposable {
$stat(uri: UriComponents): Promise<files.IStat>;
$readdir(resource: UriComponents): Promise<[string, files.FileType][]>;
$readFile(resource: UriComponents): Promise<VSBuffer>;
$writeFile(resource: UriComponents, content: VSBuffer, opts: files.FileWriteOptions): Promise<void>;
$writeFile(resource: UriComponents, content: VSBuffer): Promise<void>;
$rename(resource: UriComponents, target: UriComponents, opts: files.FileOverwriteOptions): Promise<void>;
$copy(resource: UriComponents, target: UriComponents, opts: files.FileOverwriteOptions): Promise<void>;
$mkdir(resource: UriComponents): Promise<void>;
......
......@@ -119,11 +119,11 @@ class ConsumerFileSystem implements vscode.FileSystem {
async readFile(uri: vscode.Uri): Promise<Uint8Array> {
return this._proxy.$readFile(uri).then(buff => buff.buffer).catch(ConsumerFileSystem._handleError);
}
writeFile(uri: vscode.Uri, content: Uint8Array, options: { create: boolean; overwrite: boolean; } = { create: true, overwrite: true }): Promise<void> {
return this._proxy.$writeFile(uri, VSBuffer.wrap(content), options).catch(ConsumerFileSystem._handleError);
writeFile(uri: vscode.Uri, content: Uint8Array): Promise<void> {
return this._proxy.$writeFile(uri, VSBuffer.wrap(content)).catch(ConsumerFileSystem._handleError);
}
delete(uri: vscode.Uri, options: { recursive: boolean; } = { recursive: false }): Promise<void> {
return this._proxy.$delete(uri, { ...options, useTrash: false }).catch(ConsumerFileSystem._handleError); //todo@joh useTrash
delete(uri: vscode.Uri, options: { recursive: boolean; useTrash: boolean; } = { recursive: false, useTrash: false }): Promise<void> {
return this._proxy.$delete(uri, options).catch(ConsumerFileSystem._handleError);
}
rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean; } = { overwrite: false }): Promise<void> {
return this._proxy.$rename(oldUri, newUri, options).catch(ConsumerFileSystem._handleError);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册