From 22a98f386bd95562ca24f9cb613be613721b98db Mon Sep 17 00:00:00 2001 From: isidor Date: Tue, 19 Jun 2018 15:00:18 +0200 Subject: [PATCH] fileSystemProvider: isReadonly --- src/vs/platform/files/common/files.ts | 8 +++++++- src/vs/vscode.d.ts | 2 +- src/vs/workbench/api/node/extHostFileSystem.ts | 5 ++++- .../services/files/electron-browser/fileService.ts | 2 ++ .../services/files/electron-browser/remoteFileService.ts | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index 24188ef8c4df2..9ab1c0be2955b 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -182,7 +182,8 @@ export enum FileSystemProviderCapabilities { FileOpenReadWriteClose = 1 << 2, FileFolderCopy = 1 << 3, - PathCaseSensitive = 1 << 10 + PathCaseSensitive = 1 << 10, + Readonly = 1 << 11 } export interface IFileSystemProvider { @@ -411,6 +412,11 @@ export interface IFileStat extends IBaseStat { */ isDirectory: boolean; + /** + * The resource is readonly. + */ + isReadonly?: boolean; + /** * The resource is a symbolic link. */ diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 60f7435509c80..026f84b57b104 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -6863,7 +6863,7 @@ declare module 'vscode' { * @param options Immutable metadata about the provider. * @return A [disposable](#Disposable) that unregisters this provider when being disposed. */ - export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider, options?: { isCaseSensitive?: boolean }): Disposable; + export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider, options?: { isCaseSensitive?: boolean, isReadonly?: boolean }): Disposable; } /** diff --git a/src/vs/workbench/api/node/extHostFileSystem.ts b/src/vs/workbench/api/node/extHostFileSystem.ts index 2fa4cc8844fe1..58f06eb2188b5 100644 --- a/src/vs/workbench/api/node/extHostFileSystem.ts +++ b/src/vs/workbench/api/node/extHostFileSystem.ts @@ -83,7 +83,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape { extHostLanguageFeatures.registerDocumentLinkProvider('*', this._linkProvider); } - registerFileSystemProvider(scheme: string, provider: vscode.FileSystemProvider, options: { isCaseSensitive?: boolean } = {}) { + registerFileSystemProvider(scheme: string, provider: vscode.FileSystemProvider, options: { isCaseSensitive?: boolean, isReadonly?: boolean } = {}) { if (this._usedSchemes.has(scheme)) { throw new Error(`a provider for the scheme '${scheme}' is already registered`); @@ -98,6 +98,9 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape { if (options.isCaseSensitive) { capabilites += files.FileSystemProviderCapabilities.PathCaseSensitive; } + if (options.isReadonly) { + capabilites += files.FileSystemProviderCapabilities.Readonly; + } if (typeof provider.copy === 'function') { capabilites += files.FileSystemProviderCapabilities.FileFolderCopy; } diff --git a/src/vs/workbench/services/files/electron-browser/fileService.ts b/src/vs/workbench/services/files/electron-browser/fileService.ts index d8501eb66b0ae..e2021d010ce14 100644 --- a/src/vs/workbench/services/files/electron-browser/fileService.ts +++ b/src/vs/workbench/services/files/electron-browser/fileService.ts @@ -1129,6 +1129,7 @@ export class StatResolver { resource: this.resource, isDirectory: this.isDirectory, isSymbolicLink: this.isSymbolicLink, + isReadonly: false, name: this.name, etag: this.etag, size: this.size, @@ -1213,6 +1214,7 @@ export class StatResolver { resource: fileResource, isDirectory: fileStat.isDirectory(), isSymbolicLink, + isReadonly: false, name: file, mtime: fileStat.mtime.getTime(), etag: etag(fileStat), diff --git a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts index 0dca336c1a788..d03b24db8bd82 100644 --- a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts +++ b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts @@ -45,6 +45,7 @@ function toIFileStat(provider: IFileSystemProvider, tuple: [URI, IStat], recurse name: posix.basename(resource.path), isDirectory: (stat.type & FileType.Directory) !== 0, isSymbolicLink: (stat.type & FileType.SymbolicLink) !== 0, + isReadonly: !!(provider.capabilities & FileSystemProviderCapabilities.Readonly), mtime: stat.mtime, size: stat.size, etag: stat.mtime.toString(29) + stat.size.toString(31),