1042
1043
private async doValidateDelete(resource: URI, options?: Partial<IFileDeleteOptions>): Promise<IFileSystemProvider> {
1044
>
const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource), resource);
fileService.ts
1045
>
1046
>
// Validate trash support
1047
>
const useTrash = !!options?.useTrash;
1048
>
if (useTrash && !(provider.capabilities & FileSystemProviderCapabilities.Trash)) {
1049
throw new Error(localize('deleteFailedTrashUnsupported', "Unable to delete file '{0}' via trash because provider does not support it.", this.resourceForError(resource)));
1050
}
1052
>
// Validate atomic support
1053
>
const atomic = options?.atomic;
1054
>
if (atomic && !(provider.capabilities & FileSystemProviderCapabilities.FileAtomicDelete)) {
1055
throw new Error(localize('deleteFailedAtomicUnsupported', "Unable to delete file '{0}' atomically because provider does not support it.", this.resourceForError(resource)));
1056
}
1058
>
if (useTrash && atomic) {
1059
throw new Error(localize('deleteFailedTrashAndAtomicUnsupported', "Unable to atomically delete file '{0}' because using trash is enabled.", this.resourceForError(resource)));
1060
}
1062
>
// Validate delete
1063
>
let stat: IStat | undefined = undefined;
1064
>
try {
1065
>
stat = await provider.stat(resource);
1066
>
} catch (error) {
1067
// Handled later
1068
}
1070
>
if (stat) {
1071
this.throwIfFileIsReadonly(resource, stat);
1073
throw new FileOperationError(localize('deleteFailedNotFound', "Unable to delete nonexistent file '{0}'", this.resourceForError(resource)), FileOperationResult.FILE_NOT_FOUND);
1074
}