Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fileSystemProvider: isReadonly #52330

Merged
merged 1 commit into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/vs/platform/files/common/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -411,6 +412,11 @@ export interface IFileStat extends IBaseStat {
*/
isDirectory: boolean;

/**
* The resource is readonly.
*/
isReadonly?: boolean;

/**
* The resource is a symbolic link.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/vs/workbench/api/node/extHostFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1213,6 +1214,7 @@ export class StatResolver {
resource: fileResource,
isDirectory: fileStat.isDirectory(),
isSymbolicLink,
isReadonly: false,
name: file,
mtime: fileStat.mtime.getTime(),
etag: etag(fileStat),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down