diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index c99d1c471d1..efda47d55cf 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -199,12 +199,12 @@ export interface IFileSystemProvider { watch(resource: URI, opts: IWatchOptions): IDisposable; stat(resource: URI): TPromise; - mkdir(resource: URI): TPromise; + mkdir(resource: URI): TPromise; readdir(resource: URI): TPromise<[string, FileType][]>; delete(resource: URI): TPromise; - rename(from: URI, to: URI, opts: FileOverwriteOptions): TPromise; - copy?(from: URI, to: URI, opts: FileOverwriteOptions): TPromise; + rename(from: URI, to: URI, opts: FileOverwriteOptions): TPromise; + copy?(from: URI, to: URI, opts: FileOverwriteOptions): TPromise; readFile?(resource: URI): TPromise; writeFile?(resource: URI, content: Uint8Array, opts: FileWriteOptions): TPromise; diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 68d3bc42576..373680ad3b8 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -5005,8 +5005,9 @@ declare module 'vscode' { * @returns Metadata about the created directory or a thenable that resolves to such. * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when the parent of `uri` doesn't exist. * @throws [`FileExists`](#FileSystemError.FileExists) when `uri` already exists. + * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient. */ - createDirectory(uri: Uri): FileStat | Thenable; + createDirectory(uri: Uri): void | Thenable; /** * Read the entire contents of a file. @@ -5026,6 +5027,7 @@ declare module 'vscode' { * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist and `create` is not set. * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when the parent of `uri` doesn't exist and `create` is set. * @throws [`FileExists`](#FileSystemError.FileExists) when `uri` already exists and `overwrite` is set. + * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient. */ writeFile(uri: Uri, content: Uint8Array, options: { create: boolean, overwrite: boolean }): void | Thenable; @@ -5035,6 +5037,7 @@ declare module 'vscode' { * @param uri The resource that is to be deleted. * @param options Defines if deletion of folders is recursive. * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist. + * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient. */ delete(uri: Uri, options: { recursive: boolean }): void | Thenable; @@ -5048,8 +5051,9 @@ declare module 'vscode' { * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `oldUri` doesn't exist. * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when parent of `newUri` doesn't exist * @throws [`FileExists`](#FileSystemError.FileExists) when `newUri` exists and when the `overwrite` option is not `true`. + * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient. */ - rename(oldUri: Uri, newUri: Uri, options: { overwrite: boolean }): FileStat | Thenable; + rename(oldUri: Uri, newUri: Uri, options: { overwrite: boolean }): void | Thenable; /** * Copy files or folders. Implementing this function is optional but it will speedup @@ -5062,8 +5066,9 @@ declare module 'vscode' { * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `source` doesn't exist * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when parent of `destination` doesn't exist * @throws [`FileExists`](#FileSystemError.FileExists) when `destination` exists and when the `overwrite` option is not `true`. + * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient. */ - copy?(source: Uri, destination: Uri, options: { overwrite: boolean }): FileStat | Thenable; + copy?(source: Uri, destination: Uri, options: { overwrite: boolean }): void | Thenable; } /** diff --git a/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts b/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts index ed8c02f6975..343051fb7e7 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadFileSystem.ts @@ -111,7 +111,7 @@ class RemoteFileSystemProvider implements IFileSystemProvider { return this._proxy.$delete(this._handle, resource); } - mkdir(resource: URI): TPromise { + mkdir(resource: URI): TPromise { return this._proxy.$mkdir(this._handle, resource); } @@ -119,11 +119,11 @@ class RemoteFileSystemProvider implements IFileSystemProvider { return this._proxy.$readdir(this._handle, resource); } - rename(resource: URI, target: URI, opts: FileOverwriteOptions): TPromise { + rename(resource: URI, target: URI, opts: FileOverwriteOptions): TPromise { return this._proxy.$rename(this._handle, resource, target, opts); } - copy(resource: URI, target: URI, opts: FileOverwriteOptions): TPromise { + copy(resource: URI, target: URI, opts: FileOverwriteOptions): TPromise { return this._proxy.$copy(this._handle, resource, target, opts); } } diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 8a7ee4a5de7..67ab3eab780 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -585,9 +585,9 @@ export interface ExtHostFileSystemShape { $readdir(handle: number, resource: UriComponents): TPromise<[string, FileType][]>; $readFile(handle: number, resource: UriComponents): TPromise; $writeFile(handle: number, resource: UriComponents, base64Encoded: string, opts: FileWriteOptions): TPromise; - $rename(handle: number, resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): TPromise; - $copy(handle: number, resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): TPromise; - $mkdir(handle: number, resource: UriComponents): TPromise; + $rename(handle: number, resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): TPromise; + $copy(handle: number, resource: UriComponents, target: UriComponents, opts: FileOverwriteOptions): TPromise; + $mkdir(handle: number, resource: UriComponents): TPromise; $delete(handle: number, resource: UriComponents): TPromise; $watch(handle: number, session: number, resource: UriComponents, opts: IWatchOptions): void; $unwatch(handle: number, session: number): void; diff --git a/src/vs/workbench/api/node/extHostFileSystem.ts b/src/vs/workbench/api/node/extHostFileSystem.ts index f46c802aeaa..927ab3d434b 100644 --- a/src/vs/workbench/api/node/extHostFileSystem.ts +++ b/src/vs/workbench/api/node/extHostFileSystem.ts @@ -78,8 +78,8 @@ class FileSystemProviderShim implements vscode.FileSystemProvider { stat(resource: vscode.Uri): Thenable { return this._delegate.stat(resource).then(stat => FileSystemProviderShim._modernizeFileStat(stat)); } - rename(oldUri: vscode.Uri, newUri: vscode.Uri): Thenable { - return this._delegate.move(oldUri, newUri).then(stat => FileSystemProviderShim._modernizeFileStat(stat)); + rename(oldUri: vscode.Uri, newUri: vscode.Uri): Thenable { + return this._delegate.move(oldUri, newUri).then(stat => void 0); } readDirectory(resource: vscode.Uri): Thenable<[string, vscode.FileType][]> { return this._delegate.readdir(resource).then(tuples => { @@ -135,8 +135,8 @@ class FileSystemProviderShim implements vscode.FileSystemProvider { } }); } - createDirectory(resource: vscode.Uri): Thenable { - return this._delegate.mkdir(resource).then(stat => FileSystemProviderShim._modernizeFileStat(stat)); + createDirectory(resource: vscode.Uri): Thenable { + return this._delegate.mkdir(resource).then(stat => void 0); } // --- read/write @@ -272,16 +272,16 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape { return asWinJsPromise(token => this._fsProvider.get(handle).delete(URI.revive(resource), { recursive: true })); } - $rename(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): TPromise { - return asWinJsPromise(token => this._fsProvider.get(handle).rename(URI.revive(oldUri), URI.revive(newUri), opts)).then(ExtHostFileSystem._asIStat); + $rename(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): TPromise { + return asWinJsPromise(token => this._fsProvider.get(handle).rename(URI.revive(oldUri), URI.revive(newUri), opts)); } - $copy(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): TPromise { - return asWinJsPromise(token => this._fsProvider.get(handle).copy(URI.revive(oldUri), URI.revive(newUri), opts)).then(ExtHostFileSystem._asIStat); + $copy(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): TPromise { + return asWinJsPromise(token => this._fsProvider.get(handle).copy(URI.revive(oldUri), URI.revive(newUri), opts)); } - $mkdir(handle: number, resource: UriComponents): TPromise { - return asWinJsPromise(token => this._fsProvider.get(handle).createDirectory(URI.revive(resource))).then(ExtHostFileSystem._asIStat); + $mkdir(handle: number, resource: UriComponents): TPromise { + return asWinJsPromise(token => this._fsProvider.get(handle).createDirectory(URI.revive(resource))); } $watch(handle: number, session: number, resource: UriComponents, opts: files.IWatchOptions): void { diff --git a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts index c62b811e0e9..1ecbe48e43f 100644 --- a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts +++ b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts @@ -516,8 +516,8 @@ export class RemoteFileService extends FileService { return super.createFolder(resource); } else { return this._withProvider(resource).then(provider => { - return provider.mkdir(resource).then(stat => { - return toIFileStat(provider, [resource, stat]); + return provider.mkdir(resource).then(() => { + return this.resolveFile(resource); }); }).then(fileStat => { this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat)); @@ -552,8 +552,8 @@ export class RemoteFileService extends FileService { : TPromise.as(null); return prepare.then(() => this._withProvider(source)).then(provider => { - return provider.rename(source, target, { overwrite }).then(stat => { - return toIFileStat(provider, [target, stat]); + return provider.rename(source, target, { overwrite }).then(() => { + return this.resolveFile(target); }).then(fileStat => { this._onAfterOperation.fire(new FileOperationEvent(source, FileOperation.MOVE, fileStat)); return fileStat; @@ -587,8 +587,8 @@ export class RemoteFileService extends FileService { if (source.scheme === target.scheme && (provider.capabilities & FileSystemProviderCapabilities.FileFolderCopy)) { // good: provider supports copy withing scheme - return provider.copy(source, target, { overwrite }).then(stat => { - return toIFileStat(provider, [target, stat]); + return provider.copy(source, target, { overwrite }).then(() => { + return this.resolveFile(target); }).then(fileStat => { this._onAfterOperation.fire(new FileOperationEvent(source, FileOperation.COPY, fileStat)); return fileStat;