提交 f4eae9a5 编写于 作者: B Benjamin Pasero

files2 - polish method names

上级 7081def4
......@@ -70,8 +70,8 @@ export class FileServiceBasedUserConfiguration extends Disposable {
this._register(fileService.onFileChanges(e => this.handleFileEvents(e)));
this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this.reload().then(configurationModel => this._onDidChangeConfiguration.fire(configurationModel)), 50));
this.fileService.watchFileChanges(this.configurationResource);
this._register(toDisposable(() => this.fileService.unwatchFileChanges(this.configurationResource)));
this.fileService.watch(this.configurationResource);
this._register(toDisposable(() => this.fileService.unwatch(this.configurationResource)));
}
initialize(): Promise<ConfigurationModel> {
......
......@@ -70,7 +70,7 @@ export interface IFileService {
/**
* Allows to listen for file changes. The event will fire for every file within the opened workspace
* (if any) as well as all files that have been watched explicitly using the #watchFileChanges() API.
* (if any) as well as all files that have been watched explicitly using the #watch() API.
*/
readonly onFileChanges: Event<FileChangesEvent>;
......@@ -80,7 +80,7 @@ export interface IFileService {
readonly onAfterOperation: Event<FileOperationEvent>;
/**
* Resolve the properties of a file identified by the resource.
* Resolve the properties of a file/folder identified by the resource.
*
* If the optional parameter "resolveTo" is specified in options, the stat service is asked
* to provide a stat object that should contain the full graph of folders up to all of the
......@@ -93,20 +93,20 @@ export interface IFileService {
* If the optional parameter "resolveMetadata" is specified in options,
* the stat will contain metadata information such as size, mtime and etag.
*/
resolveFile(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
resolve(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
/**
* Same as resolveFile but supports resolving multiple resources in parallel.
* Same as resolve() but supports resolving multiple resources in parallel.
* If one of the resolve targets fails to resolve returns a fake IFileStat instead of making the whole call fail.
*/
resolveFiles(toResolve: { resource: URI, options: IResolveMetadataFileOptions }[]): Promise<IResolveFileResult[]>;
resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]>;
resolveAll(toResolve: { resource: URI, options: IResolveMetadataFileOptions }[]): Promise<IResolveFileResult[]>;
resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]>;
/**
* Finds out if a file identified by the resource exists.
* Finds out if a file/folder identified by the resource exists.
*/
existsFile(resource: URI): Promise<boolean>;
exists(resource: URI): Promise<boolean>;
/**
* Resolve the contents of a file identified by the resource.
......@@ -128,18 +128,18 @@ export interface IFileService {
updateContent(resource: URI, value: string | ITextSnapshot, options?: IUpdateContentOptions): Promise<IFileStatWithMetadata>;
/**
* Moves the file to a new path identified by the resource.
* Moves the file/folder to a new path identified by the resource.
*
* The optional parameter overwrite can be set to replace an existing file at the location.
*/
moveFile(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata>;
move(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata>;
/**
* Copies the file to a path identified by the resource.
* Copies the file/folder to a path identified by the resource.
*
* The optional parameter overwrite can be set to replace an existing file at the location.
*/
copyFile(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata>;
copy(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata>;
/**
* Creates a new file with the given path. The returned promise
......@@ -165,12 +165,12 @@ export interface IFileService {
/**
* Allows to start a watcher that reports file change events on the provided resource.
*/
watchFileChanges(resource: URI): void;
watch(resource: URI): void;
/**
* Allows to stop a watcher on the provided resource or absolute fs path.
*/
unwatchFileChanges(resource: URI): void;
unwatch(resource: URI): void;
/**
* Frees up any resources occupied by this service.
......@@ -1135,7 +1135,7 @@ export interface ILegacyFileService {
createFile(resource: URI, content?: string, options?: ICreateFileOptions): Promise<IFileStat>;
watchFileChanges(resource: URI): void;
watch(resource: URI): void;
unwatchFileChanges(resource: URI): void;
unwatch(resource: URI): void;
}
\ No newline at end of file
......@@ -215,7 +215,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
private _handleUntitledScheme(uri: URI): Promise<boolean> {
const asFileUri = uri.with({ scheme: Schemas.file });
return this._fileService.resolveFile(asFileUri).then(stats => {
return this._fileService.resolve(asFileUri).then(stats => {
// don't create a new file ontop of an existing file
return Promise.reject(new Error('file already exists on disk'));
}, err => {
......
......@@ -269,7 +269,7 @@ export class ResourcesDropHandler {
}
// Check for Folder
return this.fileService.resolveFile(fileOnDiskResource).then(stat => {
return this.fileService.resolve(fileOnDiskResource).then(stat => {
if (stat.isDirectory) {
workspaceResources.folders.push({ uri: stat.resource, typeHint: 'folder' });
}
......
......@@ -695,16 +695,16 @@ export class SimpleRemoteFileService implements IFileService {
readonly onDidChangeFileSystemProviderRegistrations = Event.None;
readonly onWillActivateFileSystemProvider = Event.None;
resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStatWithMetadata> {
resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStatWithMetadata> {
// @ts-ignore
return Promise.resolve(fileMap.get(resource));
}
resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(resourceAndOption => this.resolveFile(resourceAndOption.resource, resourceAndOption.options))).then(stats => stats.map(stat => ({ stat, success: true })));
resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(resourceAndOption => this.resolve(resourceAndOption.resource, resourceAndOption.options))).then(stats => stats.map(stat => ({ stat, success: true })));
}
existsFile(resource: URI): Promise<boolean> {
exists(resource: URI): Promise<boolean> {
return Promise.resolve(fileMap.has(resource));
}
......@@ -761,9 +761,9 @@ export class SimpleRemoteFileService implements IFileService {
});
}
moveFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> { return Promise.resolve(null!); }
move(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> { return Promise.resolve(null!); }
copyFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<any> {
copy(_source: URI, _target: URI, _overwrite?: boolean): Promise<any> {
const parent = fileMap.get(dirname(_target));
if (!parent) {
return Promise.resolve(undefined);
......@@ -802,9 +802,9 @@ export class SimpleRemoteFileService implements IFileService {
del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> { return Promise.resolve(); }
watchFileChanges(_resource: URI): void { }
watch(_resource: URI): void { }
unwatchFileChanges(_resource: URI): void { }
unwatch(_resource: URI): void { }
getWriteEncoding(_resource: URI): IResourceEncoding { return { encoding: 'utf8', hasBOM: false }; }
......
......@@ -228,7 +228,7 @@ class FileDataSource implements IAsyncDataSource<IWorkspace | URI, IWorkspaceFol
} else {
uri = element.resource;
}
return this._fileService.resolveFile(uri).then(stat => {
return this._fileService.resolve(uri).then(stat => {
for (const child of stat.children || []) {
this._parents.set(stat, child);
}
......
......@@ -76,7 +76,7 @@ export class BinaryEditorModel extends EditorModel {
// Make sure to resolve up to date stat for file resources
if (this.fileService.canHandleResource(this.resource)) {
return this.fileService.resolveFile(this.resource, { resolveMetadata: true }).then(stat => {
return this.fileService.resolve(this.resource, { resolveMetadata: true }).then(stat => {
this.etag = stat.etag;
if (typeof stat.size === 'number') {
this.size = stat.size;
......
......@@ -335,7 +335,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
private resolveWorkspaceFolderExtensionConfig(workspaceFolder: IWorkspaceFolder): Promise<IExtensionsConfigContent | null> {
const extensionsJsonUri = workspaceFolder.toResource(EXTENSIONS_CONFIG);
return Promise.resolve(this.fileService.resolveFile(extensionsJsonUri)
return Promise.resolve(this.fileService.resolve(extensionsJsonUri)
.then(() => this.fileService.resolveContent(extensionsJsonUri))
.then(content => <IExtensionsConfigContent>json.parse(content.value), err => null));
}
......
......@@ -2528,7 +2528,7 @@ export class OpenExtensionsFolderAction extends Action {
run(): Promise<void> {
const extensionsHome = URI.file(this.environmentService.extensionsPath);
return Promise.resolve(this.fileService.resolveFile(extensionsHome)).then(file => {
return Promise.resolve(this.fileService.resolve(extensionsHome)).then(file => {
let itemToShow: URI;
if (file.children && file.children.length > 0) {
itemToShow = file.children[0].resource;
......
......@@ -90,7 +90,7 @@ CommandsRegistry.registerCommand({
const terminalService = accessor.get(IExternalTerminalService);
const resources = getMultiSelectedResources(resource, accessor.get(IListService), editorService);
return fileService.resolveFiles(resources.map(r => ({ resource: r }))).then(stats => {
return fileService.resolveAll(resources.map(r => ({ resource: r }))).then(stats => {
const directoriesToOpen = distinct(stats.filter(data => data.success).map(({ stat }) => stat!.isDirectory ? stat!.resource.fsPath : paths.dirname(stat!.resource.fsPath)));
return directoriesToOpen.map(dir => {
if (configurationService.getValue<IExternalTerminalConfiguration>().terminal.explorerKind === 'integrated') {
......
......@@ -171,7 +171,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
// flag.
let checkExists: Promise<boolean>;
if (isExternal) {
checkExists = timeout(100).then(() => this.fileService.existsFile(resource));
checkExists = timeout(100).then(() => this.fileService.exists(resource));
} else {
checkExists = Promise.resolve(false);
}
......@@ -352,7 +352,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
// Handle no longer visible out of workspace resources
this.activeOutOfWorkspaceWatchers.forEach(resource => {
if (!visibleOutOfWorkspacePaths.get(resource)) {
this.fileService.unwatchFileChanges(resource);
this.fileService.unwatch(resource);
this.activeOutOfWorkspaceWatchers.delete(resource);
}
});
......@@ -360,7 +360,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
// Handle newly visible out of workspace resources
visibleOutOfWorkspacePaths.forEach(resource => {
if (!this.activeOutOfWorkspaceWatchers.get(resource)) {
this.fileService.watchFileChanges(resource);
this.fileService.watch(resource);
this.activeOutOfWorkspaceWatchers.set(resource, resource);
}
});
......@@ -370,7 +370,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
super.dispose();
// Dispose watchers if any
this.activeOutOfWorkspaceWatchers.forEach(resource => this.fileService.unwatchFileChanges(resource));
this.activeOutOfWorkspaceWatchers.forEach(resource => this.fileService.unwatch(resource));
this.activeOutOfWorkspaceWatchers.clear();
}
}
......@@ -492,7 +492,7 @@ class PasteFileAction extends BaseErrorReportingAction {
throw new Error(nls.localize('fileIsAncestor', "File to paste is an ancestor of the destination folder"));
}
return this.fileService.resolveFile(fileToPaste).then(fileToPasteStat => {
return this.fileService.resolve(fileToPaste).then(fileToPasteStat => {
// Find target
let target: ExplorerItem;
......@@ -505,7 +505,7 @@ class PasteFileAction extends BaseErrorReportingAction {
const targetFile = findValidPasteFileTarget(target, { resource: fileToPaste, isDirectory: fileToPasteStat.isDirectory, allowOverwirte: pasteShouldMove });
// Copy File
const promise = pasteShouldMove ? this.fileService.moveFile(fileToPaste, targetFile) : this.fileService.copyFile(fileToPaste, targetFile);
const promise = pasteShouldMove ? this.fileService.move(fileToPaste, targetFile) : this.fileService.copy(fileToPaste, targetFile);
return promise.then<ITextEditor | undefined>(stat => {
if (pasteShouldMove) {
// Cut is done. Make sure to clear cut state.
......
......@@ -270,7 +270,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
// Set side input
if (resources.length) {
return fileService.resolveFiles(resources.map(resource => ({ resource }))).then(resolved => {
return fileService.resolveAll(resources.map(resource => ({ resource }))).then(resolved => {
const editors = resolved.filter(r => r.stat && r.success && !r.stat.isDirectory).map(r => ({
resource: r.stat!.resource
}));
......
......@@ -607,7 +607,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
const droppedResources = extractResources(originalEvent, true);
// Check for dropped external files to be folders
return this.fileService.resolveFiles(droppedResources).then(result => {
return this.fileService.resolveAll(droppedResources).then(result => {
// Pass focus to window
this.windowService.focusWindow();
......@@ -648,7 +648,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
if (resources && resources.length > 0) {
// Resolve target to check for name collisions and ask user
return this.fileService.resolveFile(target.resource).then(targetStat => {
return this.fileService.resolve(target.resource).then(targetStat => {
// Check for name collisions
const targetNames = new Set<string>();
......@@ -694,7 +694,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
return revertPromise.then(() => {
const copyTarget = joinPath(target.resource, basename(sourceFile));
return this.fileService.copyFile(sourceFile, copyTarget, true).then(stat => {
return this.fileService.copy(sourceFile, copyTarget, true).then(stat => {
// if we only add one file, just open it directly
if (resources.length === 1) {
......@@ -794,7 +794,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
// Reuse duplicate action if user copies
if (isCopy) {
return this.fileService.copyFile(source.resource, findValidPasteFileTarget(target, { resource: source.resource, isDirectory: source.isDirectory, allowOverwirte: false })).then(stat => {
return this.fileService.copy(source.resource, findValidPasteFileTarget(target, { resource: source.resource, isDirectory: source.isDirectory, allowOverwirte: false })).then(stat => {
if (!stat.isDirectory) {
return this.editorService.openEditor({ resource: stat.resource, options: { pinned: true } }).then(() => undefined);
}
......
......@@ -249,7 +249,7 @@ export class ExplorerItem {
// Resolve metadata only when the mtime is needed since this can be expensive
// Mtime is only used when the sort order is 'modified'
const resolveMetadata = explorerService.sortOrder === 'modified';
promise = fileService.resolveFile(this.resource, { resolveSingleChildDescendants: true, resolveMetadata }).then(stat => {
promise = fileService.resolve(this.resource, { resolveSingleChildDescendants: true, resolveMetadata }).then(stat => {
const resolved = ExplorerItem.create(stat, this);
ExplorerItem.mergeLocalWithDisk(resolved, this);
this._isDirectoryResolved = true;
......
......@@ -151,7 +151,7 @@ export class ExplorerService implements IExplorerService {
const workspaceFolder = this.contextService.getWorkspaceFolder(resource);
const rootUri = workspaceFolder ? workspaceFolder.uri : this.roots[0].resource;
const root = this.roots.filter(r => r.resource.toString() === rootUri.toString()).pop()!;
return this.fileService.resolveFile(rootUri, options).then(stat => {
return this.fileService.resolve(rootUri, options).then(stat => {
// Convert to model
const modelStat = ExplorerItem.create(stat, undefined, options.resolveTo);
......@@ -193,7 +193,7 @@ export class ExplorerService implements IExplorerService {
parents.forEach(p => {
// We have to check if the parent is resolved #29177
const resolveMetadata = this.sortOrder === `modified`;
const thenable: Promise<IFileStat | undefined> = p.isDirectoryResolved ? Promise.resolve(undefined) : this.fileService.resolveFile(p.resource, { resolveMetadata });
const thenable: Promise<IFileStat | undefined> = p.isDirectoryResolved ? Promise.resolve(undefined) : this.fileService.resolve(p.resource, { resolveMetadata });
thenable.then(stat => {
if (stat) {
const modelStat = ExplorerItem.create(stat, p.parent);
......
......@@ -191,7 +191,7 @@ export class OpenFileHandler extends QuickOpenHandler {
workspaceFolders[0].uri.with({ path: detildifiedQuery }) :
URI.file(detildifiedQuery);
return this.fileService.resolveFile(resource).then(
return this.fileService.resolve(resource).then(
stat => stat.isDirectory ? undefined : resource,
error => undefined);
}
......
......@@ -367,7 +367,7 @@ const searchInFolderCommand: ICommandHandler = (accessor, resource?: URI) => {
return openSearchView(viewletService, panelService, configurationService, true).then(searchView => {
if (resources && resources.length && searchView) {
return fileService.resolveFiles(resources.map(resource => ({ resource }))).then(results => {
return fileService.resolveAll(resources.map(resource => ({ resource }))).then(results => {
const folders: URI[] = [];
results.forEach(result => {
......
......@@ -1200,7 +1200,7 @@ export class SearchView extends ViewletPanel {
// Validate folderQueries
const folderQueriesExistP =
query.folderQueries.map(fq => {
return this.fileService.existsFile(fq.folder);
return this.fileService.exists(fq.folder);
});
return Promise.resolve(folderQueriesExistP).then(existResults => {
......
......@@ -164,7 +164,7 @@ async function createSnippetFile(scope: string, defaultPath: URI, windowService:
}
async function createLanguageSnippetFile(pick: ISnippetPick, fileService: IFileService) {
if (await fileService.existsFile(URI.file(pick.filepath))) {
if (await fileService.exists(URI.file(pick.filepath))) {
return;
}
const contents = [
......
......@@ -121,11 +121,11 @@ function watch(service: IFileService, resource: URI, callback: (type: FileChange
}
}
});
service.watchFileChanges(resource);
service.watch(resource);
return {
dispose() {
listener.dispose();
service.unwatchFileChanges(resource);
service.unwatch(resource);
}
};
}
......@@ -277,7 +277,7 @@ class SnippetsService implements ISnippetsService {
private _initWorkspaceFolderSnippets(workspace: IWorkspace, bucket: IDisposable[]): Promise<any> {
let promises = workspace.folders.map(folder => {
const snippetFolder = folder.toResource('.vscode');
return this._fileService.existsFile(snippetFolder).then(value => {
return this._fileService.exists(snippetFolder).then(value => {
if (value) {
this._initFolderSnippets(SnippetSource.Workspace, snippetFolder, bucket);
} else {
......@@ -305,7 +305,7 @@ class SnippetsService implements ISnippetsService {
if (type === FileChangeType.DELETED) {
return Promise.resolve();
}
return this._fileService.resolveFile(folder).then(stat => {
return this._fileService.resolve(folder).then(stat => {
for (const entry of stat.children || []) {
disposables.push(this._addSnippetFile(entry.resource, source));
}
......
......@@ -196,7 +196,7 @@ export function getHashedRemotesFromConfig(text: string, stripEndingDotGit: bool
export function getHashedRemotesFromUri(workspaceUri: URI, fileService: IFileService, stripEndingDotGit: boolean = false): Promise<string[]> {
const path = workspaceUri.path;
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
return fileService.existsFile(uri).then(exists => {
return fileService.exists(uri).then(exists => {
if (!exists) {
return [];
}
......@@ -364,7 +364,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
return Promise.resolve(tags);
}
return this.fileService.resolveFiles(folders.map(resource => ({ resource }))).then((files: IResolveFileResult[]) => {
return this.fileService.resolveAll(folders.map(resource => ({ resource }))).then((files: IResolveFileResult[]) => {
const names = (<IFileStat[]>[]).concat(...files.map(result => result.success ? (result.stat!.children || []) : [])).map(c => c.name);
const nameSet = names.reduce((s, n) => s.add(n.toLowerCase()), new Set());
......@@ -437,7 +437,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
function getFilePromises(filename: string, fileService: IFileService, contentHandler: (content: IContent) => void): Promise<void>[] {
return !nameSet.has(filename) ? [] : (folders as URI[]).map(workspaceUri => {
const uri = workspaceUri.with({ path: `${workspaceUri.path !== '/' ? workspaceUri.path : ''}/${filename}` });
return fileService.existsFile(uri).then(exists => {
return fileService.exists(uri).then(exists => {
if (!exists) {
return undefined;
}
......@@ -620,7 +620,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
Promise.all<string[]>(workspaceUris.map(workspaceUri => {
const path = workspaceUri.path;
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
return this.fileService.existsFile(uri).then(exists => {
return this.fileService.exists(uri).then(exists => {
if (!exists) {
return [];
}
......@@ -666,7 +666,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
const path = workspaceUri.path;
return workspaceUri.with({ path: `${path !== '/' ? path : ''}/node_modules` });
});
return this.fileService.resolveFiles(uris.map(resource => ({ resource }))).then(
return this.fileService.resolveAll(uris.map(resource => ({ resource }))).then(
results => {
const names = (<IFileStat[]>[]).concat(...results.map(result => result.success ? (result.stat!.children || []) : [])).map(c => c.name);
const referencesAzure = WorkspaceStats.searchArray(names, /azure/i);
......@@ -689,7 +689,7 @@ export class WorkspaceStats implements IWorkbenchContribution {
return Promise.all(workspaceUris.map(workspaceUri => {
const path = workspaceUri.path;
const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/pom.xml` });
return this.fileService.existsFile(uri).then(exists => {
return this.fileService.exists(uri).then(exists => {
if (!exists) {
return false;
}
......
......@@ -2318,7 +2318,7 @@ class TaskService extends Disposable implements ITaskService {
let openTaskFile = (workspaceFolder: IWorkspaceFolder): void => {
let resource = workspaceFolder.toResource('.vscode/tasks.json');
let configFileCreated = false;
this.fileService.resolveFile(resource).then((stat) => stat, () => undefined).then((stat) => {
this.fileService.resolve(resource).then((stat) => stat, () => undefined).then((stat) => {
if (stat) {
return stat.resource;
}
......@@ -2375,7 +2375,7 @@ class TaskService extends Disposable implements ITaskService {
}
let stats = this.contextService.getWorkspace().folders.map<Promise<IFileStat | undefined>>((folder) => {
return this.fileService.resolveFile(folder.toResource('.vscode/tasks.json')).then(stat => stat, () => undefined);
return this.fileService.resolve(folder.toResource('.vscode/tasks.json')).then(stat => stat, () => undefined);
});
let createLabel = nls.localize('TaskService.createJsonFile', 'Create tasks.json file from template');
......
......@@ -230,7 +230,7 @@ export class ProcessRunnerDetector {
}
private tryDetectGulp(workspaceFolder: IWorkspaceFolder, list: boolean): Promise<DetectorResult> {
return Promise.resolve(this.fileService.resolveFile(workspaceFolder.toResource('gulpfile.js'))).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return Promise.resolve(this.fileService.resolve(workspaceFolder.toResource('gulpfile.js'))).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
let config = ProcessRunnerDetector.detectorConfig('gulp');
let process = new LineProcess('gulp', [config.arg, '--no-color'], true, { cwd: this._cwd });
return this.runDetection(process, 'gulp', true, config.matcher, ProcessRunnerDetector.DefaultProblemMatchers, list);
......@@ -240,7 +240,7 @@ export class ProcessRunnerDetector {
}
private tryDetectGrunt(workspaceFolder: IWorkspaceFolder, list: boolean): Promise<DetectorResult> {
return Promise.resolve(this.fileService.resolveFile(workspaceFolder.toResource('Gruntfile.js'))).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return Promise.resolve(this.fileService.resolve(workspaceFolder.toResource('Gruntfile.js'))).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
let config = ProcessRunnerDetector.detectorConfig('grunt');
let process = new LineProcess('grunt', [config.arg, '--no-color'], true, { cwd: this._cwd });
return this.runDetection(process, 'grunt', true, config.matcher, ProcessRunnerDetector.DefaultProblemMatchers, list);
......@@ -255,10 +255,10 @@ export class ProcessRunnerDetector {
let process = new LineProcess('jake', [config.arg], true, { cwd: this._cwd });
return this.runDetection(process, 'jake', true, config.matcher, ProcessRunnerDetector.DefaultProblemMatchers, list);
};
return Promise.resolve(this.fileService.resolveFile(workspaceFolder.toResource('Jakefile'))).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return Promise.resolve(this.fileService.resolve(workspaceFolder.toResource('Jakefile'))).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return run();
}, (err: any) => {
return this.fileService.resolveFile(workspaceFolder.toResource('Jakefile.js')).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return this.fileService.resolve(workspaceFolder.toResource('Jakefile.js')).then((stat) => { // TODO@Dirk (https://github.com/Microsoft/vscode/issues/29454)
return run();
}, (err: any) => {
return null;
......
......@@ -305,7 +305,7 @@ export class TerminalLinkHandler {
uri = URI.file(linkUrl);
}
return this._fileService.resolveFile(uri).then(stat => {
return this._fileService.resolve(uri).then(stat => {
if (stat.isDirectory) {
return null;
}
......
......@@ -416,7 +416,7 @@ export abstract class TerminalService implements ITerminalService {
return Promise.resolve(null);
}
const current = potentialPaths.shift();
return this._fileService.existsFile(URI.file(current!)).then(exists => {
return this._fileService.exists(URI.file(current!)).then(exists => {
if (!exists) {
return this._validateShellPaths(label, potentialPaths);
}
......
......@@ -82,7 +82,7 @@ export class TerminalService extends BrowserTerminalService implements ITerminal
const interval = setInterval(() => {
if (!running) {
running = true;
this._fileService.existsFile(path).then(exists => {
this._fileService.exists(path).then(exists => {
running = false;
if (!exists) {
......
......@@ -69,7 +69,7 @@ export class WelcomePageContribution implements IWorkbenchContribution {
if (openWithReadme) {
return Promise.all(contextService.getWorkspace().folders.map(folder => {
const folderUri = folder.uri;
return fileService.resolveFile(folderUri)
return fileService.resolve(folderUri)
.then(folder => {
const files = folder.children ? folder.children.map(child => child.name) : [];
......
......@@ -318,14 +318,14 @@ export class BulkEdit {
if (edit.newUri && edit.oldUri) {
// rename
if (options.overwrite === undefined && options.ignoreIfExists && await this._fileService.existsFile(edit.newUri)) {
if (options.overwrite === undefined && options.ignoreIfExists && await this._fileService.exists(edit.newUri)) {
continue; // not overwriting, but ignoring, and the target file exists
}
await this._textFileService.move(edit.oldUri, edit.newUri, options.overwrite);
} else if (!edit.newUri && edit.oldUri) {
// delete file
if (await this._fileService.existsFile(edit.oldUri)) {
if (await this._fileService.exists(edit.oldUri)) {
let useTrash = this._configurationService.getValue<boolean>('files.enableTrash');
if (useTrash && !(await this._fileService.hasCapability(edit.oldUri, FileSystemProviderCapabilities.Trash))) {
useTrash = false; // not supported by provider
......@@ -336,7 +336,7 @@ export class BulkEdit {
}
} else if (edit.newUri && !edit.oldUri) {
// create file
if (options.overwrite === undefined && options.ignoreIfExists && await this._fileService.existsFile(edit.newUri)) {
if (options.overwrite === undefined && options.ignoreIfExists && await this._fileService.exists(edit.newUri)) {
continue; // not overwriting, but ignoring, and the target file exists
}
await this._textFileService.create(edit.newUri, undefined, { overwrite: options.overwrite });
......
......@@ -373,7 +373,7 @@ export class ConfigurationEditingService {
}
private async resolveModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
const exists = await this.fileService.existsFile(resource);
const exists = await this.fileService.exists(resource);
if (!exists) {
await this.fileService.updateContent(resource, '{}', { encoding: 'utf8' });
}
......
......@@ -84,7 +84,7 @@ export class JSONEditingService implements IJSONEditingService {
}
private async resolveModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
const exists = await this.fileService.existsFile(resource);
const exists = await this.fileService.exists(resource);
if (!exists) {
await this.fileService.updateContent(resource, '{}', { encoding: 'utf8' });
}
......
......@@ -369,13 +369,13 @@ class FileServiceBasedWorkspaceConfiguration extends AbstractWorkspaceConfigurat
private watchWorkspaceConfigurationFile(): void {
if (this.workspaceConfig) {
this.fileService.watchFileChanges(this.workspaceConfig);
this.fileService.watch(this.workspaceConfig);
}
}
private unWatchWorkspaceConfigurtionFile(): void {
if (this.workspaceConfig) {
this.fileService.unwatchFileChanges(this.workspaceConfig);
this.fileService.unwatch(this.workspaceConfig);
}
}
......@@ -638,7 +638,7 @@ export class FileServiceBasedFolderConfiguration extends AbstractFolderConfigura
private doLoadFolderConfigurationContents(): Promise<Array<{ resource: URI, value: string }>> {
const workspaceFilePathToConfiguration: { [relativeWorkspacePath: string]: Promise<IContent | undefined> } = Object.create(null);
const bulkContentFetchromise = Promise.resolve(this.fileService.resolveFile(this.folderConfigurationPath))
const bulkContentFetchromise = Promise.resolve(this.fileService.resolve(this.folderConfigurationPath))
.then(stat => {
if (stat.isDirectory && stat.children) {
stat.children
......
......@@ -87,7 +87,7 @@ export class RemoteFileDialog {
return this.pickResource().then(async fileFolderUri => {
if (fileFolderUri) {
const stat = await this.fileService.resolveFile(fileFolderUri);
const stat = await this.fileService.resolve(fileFolderUri);
return <IURIToOpen[]>[{ uri: fileFolderUri, typeHint: stat.isDirectory ? 'folder' : 'file' }];
}
......@@ -163,7 +163,7 @@ export class RemoteFileDialog {
let ext: string = resources.extname(homedir);
if (this.options.defaultUri) {
try {
stat = await this.fileService.resolveFile(this.options.defaultUri);
stat = await this.fileService.resolve(this.options.defaultUri);
} catch (e) {
// The file or folder doesn't exist
}
......@@ -296,8 +296,8 @@ export class RemoteFileDialog {
let stat: IFileStat | undefined;
let statDirname: IFileStat | undefined;
try {
statDirname = await this.fileService.resolveFile(inputUriDirname);
stat = await this.fileService.resolveFile(inputUri);
statDirname = await this.fileService.resolve(inputUriDirname);
stat = await this.fileService.resolve(inputUri);
} catch (e) {
// do nothing
}
......@@ -339,7 +339,7 @@ export class RemoteFileDialog {
if (this.endsWithSlash(value) || (!resources.isEqual(this.currentFolder, resources.dirname(valueUri), true) && resources.isEqualOrParent(this.currentFolder, resources.dirname(valueUri), true))) {
let stat: IFileStat | undefined;
try {
stat = await this.fileService.resolveFile(valueUri);
stat = await this.fileService.resolve(valueUri);
} catch (e) {
// do nothing
}
......@@ -350,7 +350,7 @@ export class RemoteFileDialog {
if (!resources.isEqual(this.currentFolder, inputUriDirname, true)) {
let statWithoutTrailing: IFileStat | undefined;
try {
statWithoutTrailing = await this.fileService.resolveFile(inputUriDirname);
statWithoutTrailing = await this.fileService.resolve(inputUriDirname);
} catch (e) {
// do nothing
}
......@@ -391,8 +391,8 @@ export class RemoteFileDialog {
let stat: IFileStat | undefined;
let statDirname: IFileStat | undefined;
try {
statDirname = await this.fileService.resolveFile(resources.dirname(uri));
stat = await this.fileService.resolveFile(uri);
statDirname = await this.fileService.resolve(resources.dirname(uri));
stat = await this.fileService.resolve(uri);
} catch (e) {
// do nothing
}
......@@ -513,7 +513,7 @@ export class RemoteFileDialog {
const backDir = this.createBackItem(currentFolder);
try {
const folder = await this.fileService.resolveFile(currentFolder);
const folder = await this.fileService.resolve(currentFolder);
const fileNames = folder.children ? folder.children.map(child => child.name) : [];
const items = await Promise.all(fileNames.map(fileName => this.createItem(fileName, currentFolder)));
for (let item of items) {
......@@ -562,7 +562,7 @@ export class RemoteFileDialog {
private async createItem(filename: string, parent: URI): Promise<FileQuickPickItem | undefined> {
let fullPath = resources.joinPath(parent, filename);
try {
const stat = await this.fileService.resolveFile(fullPath);
const stat = await this.fileService.resolve(fullPath);
if (stat.isDirectory) {
filename = this.basenameWithTrailingSlash(fullPath);
return { label: filename, uri: fullPath, isFolder: true, iconClasses: getIconClasses(this.modelService, this.modeService, fullPath || undefined, FileKind.FOLDER) };
......
......@@ -280,7 +280,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return Promise.reject(error);
};
const statsPromise = this.resolveFile(resource).then(stat => {
const statsPromise = this.resolve(resource).then(stat => {
result.resource = stat.resource;
result.name = stat.name;
result.mtime = stat.mtime;
......@@ -812,11 +812,11 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
));
}
moveFile(source: uri, target: uri, overwrite?: boolean): Promise<IFileStatWithMetadata> {
move(source: uri, target: uri, overwrite?: boolean): Promise<IFileStatWithMetadata> {
return this.moveOrCopyFile(source, target, false, !!overwrite);
}
copyFile(source: uri, target: uri, overwrite?: boolean): Promise<IFileStatWithMetadata> {
copy(source: uri, target: uri, overwrite?: boolean): Promise<IFileStatWithMetadata> {
return this.moveOrCopyFile(source, target, true, !!overwrite);
}
......@@ -828,7 +828,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return this.doMoveOrCopyFile(sourcePath, targetPath, keepCopy, overwrite).then(() => {
// 2.) resolve
return this.resolve(target, { resolveMetadata: true }).then(result => {
return this.doResolve(target, { resolveMetadata: true }).then(result => {
// Events (unless it was a no-op because paths are identical)
if (sourcePath !== targetPath) {
......@@ -952,9 +952,9 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return paths.normalize(resource.fsPath);
}
private resolve(resource: uri, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
private resolve(resource: uri, options?: IResolveFileOptions): Promise<IFileStat>;
private resolve(resource: uri, options: IResolveFileOptions = Object.create(null)): Promise<IFileStat> {
private doResolve(resource: uri, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
private doResolve(resource: uri, options?: IResolveFileOptions): Promise<IFileStat>;
private doResolve(resource: uri, options: IResolveFileOptions = Object.create(null)): Promise<IFileStat> {
return this.toStatResolver(resource).then(model => model.resolve(options));
}
......@@ -966,7 +966,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
});
}
watchFileChanges(resource: uri): void {
watch(resource: uri): void {
assert.ok(resource && resource.scheme === Schemas.file, `Invalid resource for watching: ${resource}`);
// Check for existing watcher first
......@@ -1000,11 +1000,11 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
// Wait a bit and try to install watcher again, assuming that the file was renamed quickly ("Atomic Save")
setTimeout(() => {
this.existsFile(resource).then(exists => {
this.exists(resource).then(exists => {
// File still exists, so reapply the watcher
if (exists) {
this.watchFileChanges(resource);
this.watch(resource);
}
// File seems to be really gone, so emit a deleted event
......@@ -1063,7 +1063,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
});
}
unwatchFileChanges(resource: uri): void {
unwatch(resource: uri): void {
const watcher = this.activeFileChangesWatchers.get(resource);
if (watcher && --watcher.count === 0) {
watcher.unwatch();
......@@ -1092,14 +1092,14 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
// Tests only
resolveFile(resource: uri, options?: IResolveFileOptions): Promise<IFileStat>;
resolveFile(resource: uri, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolveFile(resource: uri, options?: IResolveFileOptions): Promise<IFileStat> {
return this.resolve(resource, options);
resolve(resource: uri, options?: IResolveFileOptions): Promise<IFileStat>;
resolve(resource: uri, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolve(resource: uri, options?: IResolveFileOptions): Promise<IFileStat> {
return this.doResolve(resource, options);
}
resolveFiles(toResolve: { resource: uri, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(resourceAndOptions => this.resolve(resourceAndOptions.resource, resourceAndOptions.options)
resolveAll(toResolve: { resource: uri, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(resourceAndOptions => this.doResolve(resourceAndOptions.resource, resourceAndOptions.options)
.then(stat => ({ stat, success: true }), error => ({ stat: undefined, success: false }))));
}
......@@ -1110,7 +1110,7 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
return pfs.mkdirp(absolutePath).then(() => {
// 2.) Resolve
return this.resolve(resource, { resolveMetadata: true }).then(result => {
return this.doResolve(resource, { resolveMetadata: true }).then(result => {
// Events
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, result));
......@@ -1120,8 +1120,8 @@ export class FileService extends Disposable implements ILegacyFileService, IFile
});
}
existsFile(resource: uri): Promise<boolean> {
return this.resolveFile(resource).then(() => true, () => false);
exists(resource: uri): Promise<boolean> {
return this.resolve(resource).then(() => true, () => false);
}
}
......
......@@ -140,18 +140,18 @@ class WorkspaceWatchLogic extends Disposable {
}
}
this._watches.set(resource.toString(), resource);
this._fileService.watchFileChanges(resource, { recursive: true, excludes });
this._fileService.watch(resource, { recursive: true, excludes });
}
private _unwatchWorkspace(resource: URI) {
if (this._watches.has(resource.toString())) {
this._fileService.unwatchFileChanges(resource);
this._fileService.unwatch(resource);
this._watches.delete(resource.toString());
}
}
private _unwatchWorkspaces() {
this._watches.forEach(uri => this._fileService.unwatchFileChanges(uri));
this._watches.forEach(uri => this._fileService.unwatch(uri));
this._watches.clear();
}
}
......@@ -223,11 +223,11 @@ export class RemoteFileService extends FileService {
});
}
resolveFile(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
resolve(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
if (resource.scheme === Schemas.file) {
return super.resolveFile(resource, options);
return super.resolve(resource, options);
} else {
return this._doResolveFiles([{ resource, options }]).then(data => {
if (data.length !== 1 || !data[0].success) {
......@@ -279,7 +279,7 @@ export class RemoteFileService extends FileService {
private _readFile(resource: URI, options: IResolveContentOptions = Object.create(null)): Promise<IStreamContent> {
return this._withProvider(resource).then(provider => {
return this.resolveFile(resource).then(fileStat => {
return this.resolve(resource).then(fileStat => {
if (fileStat.isDirectory) {
// todo@joh cannot copy a folder
......@@ -409,7 +409,7 @@ export class RemoteFileService extends FileService {
target.once('error', err => reject(err));
target.once('finish', (_: unknown) => resolve(undefined));
}).then(_ => {
return this.resolveFile(resource, { resolveMetadata: true }) as Promise<IFileStatWithMetadata>;
return this.resolve(resource, { resolveMetadata: true }) as Promise<IFileStatWithMetadata>;
});
}
......@@ -433,9 +433,9 @@ export class RemoteFileService extends FileService {
private _activeWatches = new Map<string, { unwatch: Promise<IDisposable>, count: number }>();
watchFileChanges(resource: URI, opts: IWatchOptions = { recursive: false, excludes: [] }): void {
watch(resource: URI, opts: IWatchOptions = { recursive: false, excludes: [] }): void {
if (resource.scheme === Schemas.file) {
return super.watchFileChanges(resource);
return super.watch(resource);
}
const key = resource.toString();
......@@ -455,9 +455,9 @@ export class RemoteFileService extends FileService {
});
}
unwatchFileChanges(resource: URI): void {
unwatch(resource: URI): void {
if (resource.scheme === Schemas.file) {
return super.unwatchFileChanges(resource);
return super.unwatch(resource);
}
let entry = this._activeWatches.get(resource.toString());
if (entry && --entry.count === 0) {
......
......@@ -348,15 +348,15 @@ suite('FileService', () => {
});
});
test('watchFileChanges', function (done) {
test('watch', function (done) {
const toWatch = uri.file(path.join(testDir, 'index.html'));
service.watchFileChanges(toWatch);
service.watch(toWatch);
service.onFileChanges((e: FileChangesEvent) => {
assert.ok(e);
service.unwatchFileChanges(toWatch);
service.unwatch(toWatch);
done();
});
......@@ -365,15 +365,15 @@ suite('FileService', () => {
}, 100);
});
// test('watchFileChanges - support atomic save', function (done) {
// test('watch - support atomic save', function (done) {
// const toWatch = uri.file(path.join(testDir, 'index.html'));
// service.watchFileChanges(toWatch);
// service.watch(toWatch);
// service.onFileChanges((e: FileChangesEvent) => {
// assert.ok(e);
// service.unwatchFileChanges(toWatch);
// service.unwatch(toWatch);
// done();
// });
......
......@@ -152,9 +152,9 @@ export class FileService2 extends Disposable implements IFileService {
//#region File Metadata Resolving
async resolveFile(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
async resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
async resolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
async resolve(resource: URI, options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
async resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStat>;
async resolve(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
try {
return await this.doResolveFile(resource, options);
} catch (error) {
......@@ -251,9 +251,9 @@ export class FileService2 extends Disposable implements IFileService {
return Promise.resolve(fileStat);
}
async resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]>;
async resolveFiles(toResolve: { resource: URI, options: IResolveMetadataFileOptions }[]): Promise<IResolveFileResultWithMetadata[]>;
async resolveFiles(toResolve: { resource: URI; options?: IResolveFileOptions; }[]): Promise<IResolveFileResult[]> {
async resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]>;
async resolveAll(toResolve: { resource: URI, options: IResolveMetadataFileOptions }[]): Promise<IResolveFileResultWithMetadata[]>;
async resolveAll(toResolve: { resource: URI; options?: IResolveFileOptions; }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(async entry => {
try {
return { stat: await this.doResolveFile(entry.resource, entry.options), success: true };
......@@ -265,9 +265,9 @@ export class FileService2 extends Disposable implements IFileService {
}));
}
async existsFile(resource: URI): Promise<boolean> {
async exists(resource: URI): Promise<boolean> {
try {
return !!(await this.resolveFile(resource));
return !!(await this.resolve(resource));
} catch (error) {
return false;
}
......@@ -295,7 +295,7 @@ export class FileService2 extends Disposable implements IFileService {
// validate overwrite
const overwrite = !!(options && options.overwrite);
if (await this.existsFile(resource)) {
if (await this.exists(resource)) {
if (!overwrite) {
throw new FileOperationError(localize('fileExists', "File to create already exists ({0})", resource.toString(true)), FileOperationResult.FILE_MODIFIED_SINCE, options);
}
......@@ -328,7 +328,7 @@ export class FileService2 extends Disposable implements IFileService {
}
// events
const fileStat = await this.resolveFile(resource, { resolveMetadata: true });
const fileStat = await this.resolve(resource, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
return fileStat;
......@@ -350,7 +350,7 @@ export class FileService2 extends Disposable implements IFileService {
//#region Move/Copy/Delete/Create Folder
async moveFile(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata> {
async move(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata> {
const sourceProvider = this.throwIfFileSystemIsReadonly(await this.withProvider(source));
const targetProvider = this.throwIfFileSystemIsReadonly(await this.withProvider(target));
......@@ -358,13 +358,13 @@ export class FileService2 extends Disposable implements IFileService {
const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'move', overwrite);
// resolve and send events
const fileStat = await this.resolveFile(target, { resolveMetadata: true });
const fileStat = await this.resolve(target, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(source, mode === 'move' ? FileOperation.MOVE : FileOperation.COPY, fileStat));
return fileStat;
}
async copyFile(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata> {
async copy(source: URI, target: URI, overwrite?: boolean): Promise<IFileStatWithMetadata> {
const sourceProvider = await this.withProvider(source);
const targetProvider = this.throwIfFileSystemIsReadonly(await this.withProvider(target));
......@@ -372,7 +372,7 @@ export class FileService2 extends Disposable implements IFileService {
const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'copy', overwrite);
// resolve and send events
const fileStat = await this.resolveFile(target, { resolveMetadata: true });
const fileStat = await this.resolve(target, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(source, mode === 'copy' ? FileOperation.COPY : FileOperation.MOVE, fileStat));
return fileStat;
......@@ -409,7 +409,7 @@ export class FileService2 extends Disposable implements IFileService {
// when copying via buffer/unbuffered, we have to manually
// traverse the source if it is a folder and not a file
const sourceFile = await this.resolveFile(source);
const sourceFile = await this.resolve(source);
if (sourceFile.isDirectory) {
return this.doCopyFolder(sourceProvider, sourceFile, targetProvider, target, overwrite).then(() => mode);
} else {
......@@ -467,7 +467,7 @@ export class FileService2 extends Disposable implements IFileService {
await Promise.all(sourceFolder.children.map(async sourceChild => {
const targetChild = joinPath(targetFolder, sourceChild.name);
if (sourceChild.isDirectory) {
return this.doCopyFolder(sourceProvider, await this.resolveFile(sourceChild.resource), targetProvider, targetChild, overwrite);
return this.doCopyFolder(sourceProvider, await this.resolve(sourceChild.resource), targetProvider, targetChild, overwrite);
} else {
return this.doCopyFile(sourceProvider, sourceChild.resource, targetProvider, targetChild, overwrite);
}
......@@ -489,7 +489,7 @@ export class FileService2 extends Disposable implements IFileService {
}
// Extra checks if target exists and this is not a rename
const exists = await this.existsFile(target);
const exists = await this.exists(target);
if (exists && !isCaseChange) {
// Bail out if target exists and we are not about to overwrite
......@@ -514,7 +514,7 @@ export class FileService2 extends Disposable implements IFileService {
await this.mkdirp(provider, resource);
// events
const fileStat = await this.resolveFile(resource, { resolveMetadata: true });
const fileStat = await this.resolve(resource, { resolveMetadata: true });
this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
return fileStat;
......@@ -565,8 +565,8 @@ export class FileService2 extends Disposable implements IFileService {
// Validate recursive
const recursive = !!(options && options.recursive);
if (!recursive && await this.existsFile(resource)) {
const stat = await this.resolveFile(resource);
if (!recursive && await this.exists(resource)) {
const stat = await this.resolve(resource);
if (stat.isDirectory && Array.isArray(stat.children) && stat.children.length > 0) {
throw new Error(localize('deleteFailed', "Failed to delete non-empty folder '{0}'.", resource.toString()));
}
......@@ -586,12 +586,12 @@ export class FileService2 extends Disposable implements IFileService {
private _onFileChanges: Emitter<FileChangesEvent> = this._register(new Emitter<FileChangesEvent>());
get onFileChanges(): Event<FileChangesEvent> { return this._onFileChanges.event; }
watchFileChanges(resource: URI): void {
this.joinOnLegacy.then(legacy => legacy.watchFileChanges(resource));
watch(resource: URI): void {
this.joinOnLegacy.then(legacy => legacy.watch(resource));
}
unwatchFileChanges(resource: URI): void {
this.joinOnLegacy.then(legacy => legacy.unwatchFileChanges(resource));
unwatch(resource: URI): void {
this.joinOnLegacy.then(legacy => legacy.unwatch(resource));
}
//#endregion
......@@ -690,7 +690,7 @@ export class FileService2 extends Disposable implements IFileService {
private async doPipeBufferedToUnbuffered(sourceProvider: IFileSystemProviderWithOpenReadWriteCloseCapability, source: URI, targetProvider: IFileSystemProviderWithFileReadWriteCapability, target: URI, overwrite: boolean): Promise<void> {
// Determine file size
const size = (await this.resolveFile(source, { resolveMetadata: true })).size;
const size = (await this.resolve(source, { resolveMetadata: true })).size;
// Open handle
const sourceHandle = await sourceProvider.open(source, { create: false });
......
......@@ -208,7 +208,7 @@ export class KeybindingsEditingService extends Disposable implements IKeybinding
private resolveModelReference(): Promise<IReference<IResolvedTextEditorModel>> {
return this.fileService.existsFile(this.resource)
return this.fileService.exists(this.resource)
.then(exists => {
const EOL = this.configurationService.getValue('files', { overrideIdentifier: 'json' })['eol'];
const result: Promise<any> = exists ? Promise.resolve(null) : this.fileService.updateContent(this.resource, this.getEmptyContent(EOL), { encoding: 'utf8' });
......
......@@ -160,7 +160,7 @@ class OutputFileListener extends Disposable {
}
private doWatch(): Promise<void> {
return this.fileService.resolveFile(this.file, { resolveMetadata: true })
return this.fileService.resolve(this.file, { resolveMetadata: true })
.then(stat => {
if (stat.etag !== this.etag) {
this.etag = stat.etag;
......
......@@ -161,7 +161,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
return true;
}
return this.fileService.existsFile(this.resource).then(exists => !exists);
return this.fileService.exists(this.resource).then(exists => !exists);
});
} else {
checkOrphanedPromise = Promise.resolve(false);
......
......@@ -718,7 +718,7 @@ export class TextFileService extends Disposable implements ITextFileService {
}
// Otherwise we can only copy
return this.fileService.copyFile(resource, target).then(() => true);
return this.fileService.copy(resource, target).then(() => true);
}).then(result => {
// Return early if the operation was not running
......@@ -748,7 +748,7 @@ export class TextFileService extends Disposable implements ITextFileService {
// Otherwise create the target file empty if it does not exist already and resolve it from there
else {
targetModelResolver = this.fileService.existsFile(target).then<any>(exists => {
targetModelResolver = this.fileService.exists(target).then<any>(exists => {
targetExists = exists;
// create target model adhoc if file does not exist yet
......@@ -964,7 +964,7 @@ export class TextFileService extends Disposable implements ITextFileService {
return this.revertAll(dirtySourceModels.map(dirtySourceModel => dirtySourceModel.getResource()), { soft: true }).then(() => {
// Rename to target
return this.fileService.moveFile(source, target, overwrite).then(() => {
return this.fileService.move(source, target, overwrite).then(() => {
// Load models that were dirty before
return Promise.all(dirtyTargetModels.map(dirtyTargetModel => this.models.loadOrCreate(dirtyTargetModel))).then(() => undefined);
......
......@@ -394,12 +394,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if (this.fileService && !resources.isEqual(newTheme.location, this.watchedColorThemeLocation)) {
if (this.watchedColorThemeLocation) {
this.fileService.unwatchFileChanges(this.watchedColorThemeLocation);
this.fileService.unwatch(this.watchedColorThemeLocation);
this.watchedColorThemeLocation = undefined;
}
if (newTheme.location && (newTheme.watch || !!this.environmentService.extensionDevelopmentLocationURI)) {
this.watchedColorThemeLocation = newTheme.location;
this.fileService.watchFileChanges(this.watchedColorThemeLocation);
this.fileService.watch(this.watchedColorThemeLocation);
}
}
......@@ -512,12 +512,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if (this.fileService && !resources.isEqual(iconThemeData.location, this.watchedIconThemeLocation)) {
if (this.watchedIconThemeLocation) {
this.fileService.unwatchFileChanges(this.watchedIconThemeLocation);
this.fileService.unwatch(this.watchedIconThemeLocation);
this.watchedIconThemeLocation = undefined;
}
if (iconThemeData.location && (iconThemeData.watch || !!this.environmentService.extensionDevelopmentLocationURI)) {
this.watchedIconThemeLocation = iconThemeData.location;
this.fileService.watchFileChanges(this.watchedIconThemeLocation);
this.fileService.watch(this.watchedIconThemeLocation);
}
}
......
......@@ -929,9 +929,9 @@ export class TestFileService implements IFileService {
this._onAfterOperation.fire(event);
}
resolveFile(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat>;
resolveFile(resource: URI, _options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolveFile(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat> {
resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat>;
resolve(resource: URI, _options: IResolveMetadataFileOptions): Promise<IFileStatWithMetadata>;
resolve(resource: URI, _options?: IResolveFileOptions): Promise<IFileStat> {
return Promise.resolve({
resource,
etag: Date.now().toString(),
......@@ -943,11 +943,11 @@ export class TestFileService implements IFileService {
});
}
resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(resourceAndOption => this.resolveFile(resourceAndOption.resource, resourceAndOption.options))).then(stats => stats.map(stat => ({ stat, success: true })));
resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
return Promise.all(toResolve.map(resourceAndOption => this.resolve(resourceAndOption.resource, resourceAndOption.options))).then(stats => stats.map(stat => ({ stat, success: true })));
}
existsFile(_resource: URI): Promise<boolean> {
exists(_resource: URI): Promise<boolean> {
return Promise.resolve(true);
}
......@@ -996,11 +996,11 @@ export class TestFileService implements IFileService {
}));
}
moveFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> {
move(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> {
return Promise.resolve(null!);
}
copyFile(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> {
copy(_source: URI, _target: URI, _overwrite?: boolean): Promise<IFileStatWithMetadata> {
throw new Error('not implemented');
}
......@@ -1032,10 +1032,10 @@ export class TestFileService implements IFileService {
return Promise.resolve();
}
watchFileChanges(_resource: URI): void {
watch(_resource: URI): void {
}
unwatchFileChanges(_resource: URI): void {
unwatch(_resource: URI): void {
}
getWriteEncoding(_resource: URI): IResourceEncoding {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册