mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
add ExtHostFileSystemInfo which knows what schemes are reserved and which are used, https://github.com/microsoft/vscode/issues/91697
This commit is contained in:
35
src/vs/workbench/api/common/extHostFileSystemInfo.ts
Normal file
35
src/vs/workbench/api/common/extHostFileSystemInfo.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ExtHostFileSystemInfoShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
|
||||
export class ExtHostFileSystemInfo implements ExtHostFileSystemInfoShape {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly _systemSchemes = new Set(Object.keys(Schemas));
|
||||
private readonly _providerInfo = new Map<string, number>();
|
||||
|
||||
$acceptProviderInfos(scheme: string, capabilities: number | null): void {
|
||||
if (capabilities === null) {
|
||||
this._providerInfo.delete(scheme);
|
||||
} else {
|
||||
this._providerInfo.set(scheme, capabilities);
|
||||
}
|
||||
}
|
||||
|
||||
isFreeScheme(scheme: string): boolean {
|
||||
return !this._providerInfo.has(scheme) && !this._systemSchemes.has(scheme);
|
||||
}
|
||||
|
||||
getCapabilities(scheme: string): number | undefined {
|
||||
return this._providerInfo.get(scheme);
|
||||
}
|
||||
}
|
||||
|
||||
export interface IExtHostFileSystemInfo extends ExtHostFileSystemInfo { }
|
||||
export const IExtHostFileSystemInfo = createDecorator<IExtHostFileSystemInfo>('IExtHostFileSystemInfo');
|
||||
Reference in New Issue
Block a user