@codingame/monaco-vscode-files-service-override 3.2.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,988 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
2
- import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
3
- import { ResourceQueue, Promises } from 'vscode/vscode/vs/base/common/async';
4
- import { VSBuffer, bufferToReadable, streamToBuffer, newWriteableBufferStream, bufferedStreamToBuffer, readableToBuffer } from 'vscode/vscode/vs/base/common/buffer';
5
- import { CancellationTokenSource, CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
6
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
7
- import { hash } from 'vscode/vscode/vs/base/common/hash';
8
- import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
9
- import { Disposable, DisposableStore, toDisposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
10
- import { TernarySearchTree } from 'vscode/vscode/vs/base/common/ternarySearchTree';
11
- import { Schemas } from 'vscode/vscode/vs/base/common/network';
12
- import { mark } from 'vscode/vscode/vs/base/common/performance';
13
- import { isAbsolutePath, extUri, extUriIgnorePathCase } from 'vscode/vscode/vs/base/common/resources';
14
- import { isReadableStream, peekStream, peekReadable, consumeStream, transform, newWriteableStream, isReadableBufferedStream, listenStream } from 'vscode/vscode/vs/base/common/stream';
15
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
16
- import { FileChangesEvent, FileOperationError, hasOpenReadWriteCloseCapability, hasReadWriteCapability, hasFileReadStreamCapability, toFileSystemProviderErrorCode, FileSystemProviderErrorCode, ensureFileSystemProviderError, FileType, FilePermission, etag, FileOperationEvent, hasFileAtomicWriteCapability, toFileOperationResult, ETAG_DISABLED, hasFileAtomicReadCapability, NotModifiedSinceFileOperationError, TooLargeFileOperationError, hasFileFolderCopyCapability, hasFileAtomicDeleteCapability, hasFileCloneCapability } from 'vscode/vscode/vs/platform/files/common/files';
17
- import { readFileIntoStream } from './io.js';
18
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
19
- import { ErrorNoTelemetry } from 'vscode/vscode/vs/base/common/errors';
20
-
21
- var FileService_1;
22
- let FileService = class FileService extends Disposable {
23
- static { FileService_1 = this; }
24
- constructor(logService) {
25
- super();
26
- this.logService = logService;
27
- this.BUFFER_SIZE = 256 * 1024;
28
- this._onDidChangeFileSystemProviderRegistrations = this._register(( new Emitter()));
29
- this.onDidChangeFileSystemProviderRegistrations = this._onDidChangeFileSystemProviderRegistrations.event;
30
- this._onWillActivateFileSystemProvider = this._register(( new Emitter()));
31
- this.onWillActivateFileSystemProvider = this._onWillActivateFileSystemProvider.event;
32
- this._onDidChangeFileSystemProviderCapabilities = this._register(( new Emitter()));
33
- this.onDidChangeFileSystemProviderCapabilities = this._onDidChangeFileSystemProviderCapabilities.event;
34
- this.provider = ( new Map());
35
- this._onDidRunOperation = this._register(( new Emitter()));
36
- this.onDidRunOperation = this._onDidRunOperation.event;
37
- this.internalOnDidFilesChange = this._register(( new Emitter()));
38
- this._onDidUncorrelatedFilesChange = this._register(( new Emitter()));
39
- this.onDidFilesChange = this._onDidUncorrelatedFilesChange.event;
40
- this._onDidWatchError = this._register(( new Emitter()));
41
- this.onDidWatchError = this._onDidWatchError.event;
42
- this.activeWatchers = ( new Map());
43
- this.writeQueue = this._register(( new ResourceQueue()));
44
- }
45
- registerProvider(scheme, provider) {
46
- if (( this.provider.has(scheme))) {
47
- throw new Error(`A filesystem provider for the scheme '${scheme}' is already registered.`);
48
- }
49
- mark(`code/registerFilesystem/${scheme}`);
50
- const providerDisposables = ( new DisposableStore());
51
- this.provider.set(scheme, provider);
52
- this._onDidChangeFileSystemProviderRegistrations.fire({ added: true, scheme, provider });
53
- providerDisposables.add(provider.onDidChangeFile(changes => {
54
- const event = ( new FileChangesEvent(changes, !this.isPathCaseSensitive(provider)));
55
- this.internalOnDidFilesChange.fire(event);
56
- if (!event.hasCorrelation()) {
57
- this._onDidUncorrelatedFilesChange.fire(event);
58
- }
59
- }));
60
- if (typeof provider.onDidWatchError === 'function') {
61
- providerDisposables.add(provider.onDidWatchError(error => this._onDidWatchError.fire(( new Error(error)))));
62
- }
63
- providerDisposables.add(provider.onDidChangeCapabilities(() => this._onDidChangeFileSystemProviderCapabilities.fire({ provider, scheme })));
64
- return toDisposable(() => {
65
- this._onDidChangeFileSystemProviderRegistrations.fire({ added: false, scheme, provider });
66
- this.provider.delete(scheme);
67
- dispose(providerDisposables);
68
- });
69
- }
70
- getProvider(scheme) {
71
- return this.provider.get(scheme);
72
- }
73
- async activateProvider(scheme) {
74
- const joiners = [];
75
- this._onWillActivateFileSystemProvider.fire({
76
- scheme,
77
- join(promise) {
78
- joiners.push(promise);
79
- },
80
- });
81
- if (( this.provider.has(scheme))) {
82
- return;
83
- }
84
- await Promises.settled(joiners);
85
- }
86
- async canHandleResource(resource) {
87
- await this.activateProvider(resource.scheme);
88
- return this.hasProvider(resource);
89
- }
90
- hasProvider(resource) {
91
- return ( this.provider.has(resource.scheme));
92
- }
93
- hasCapability(resource, capability) {
94
- const provider = this.provider.get(resource.scheme);
95
- return !!(provider && (provider.capabilities & capability));
96
- }
97
- listCapabilities() {
98
- return ( Iterable.map(
99
- this.provider,
100
- ([scheme, provider]) => ({ scheme, capabilities: provider.capabilities })
101
- ));
102
- }
103
- async withProvider(resource) {
104
- if (!isAbsolutePath(resource)) {
105
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'invalidPath', "Unable to resolve filesystem provider with relative file path '{0}'", this.resourceForError(resource)), 8 );
106
- }
107
- await this.activateProvider(resource.scheme);
108
- const provider = this.provider.get(resource.scheme);
109
- if (!provider) {
110
- const error = ( new ErrorNoTelemetry());
111
- error.message = ( localizeWithPath(
112
- 'vs/platform/files/common/fileService',
113
- 'noProviderFound',
114
- "ENOPRO: No file system provider found for resource '{0}'",
115
- ( resource.toString())
116
- ));
117
- throw error;
118
- }
119
- return provider;
120
- }
121
- async withReadProvider(resource) {
122
- const provider = await this.withProvider(resource);
123
- if (hasOpenReadWriteCloseCapability(provider) || hasReadWriteCapability(provider) || hasFileReadStreamCapability(provider)) {
124
- return provider;
125
- }
126
- throw new Error(`Filesystem provider for scheme '${resource.scheme}' neither has FileReadWrite, FileReadStream nor FileOpenReadWriteClose capability which is needed for the read operation.`);
127
- }
128
- async withWriteProvider(resource) {
129
- const provider = await this.withProvider(resource);
130
- if (hasOpenReadWriteCloseCapability(provider) || hasReadWriteCapability(provider)) {
131
- return provider;
132
- }
133
- throw new Error(`Filesystem provider for scheme '${resource.scheme}' neither has FileReadWrite nor FileOpenReadWriteClose capability which is needed for the write operation.`);
134
- }
135
- async resolve(resource, options) {
136
- try {
137
- return await this.doResolveFile(resource, options);
138
- }
139
- catch (error) {
140
- if (toFileSystemProviderErrorCode(error) === FileSystemProviderErrorCode.FileNotFound) {
141
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'fileNotFoundError', "Unable to resolve nonexistent file '{0}'", this.resourceForError(resource)), 1 );
142
- }
143
- throw ensureFileSystemProviderError(error);
144
- }
145
- }
146
- async doResolveFile(resource, options) {
147
- const provider = await this.withProvider(resource);
148
- const isPathCaseSensitive = this.isPathCaseSensitive(provider);
149
- const resolveTo = options?.resolveTo;
150
- const resolveSingleChildDescendants = options?.resolveSingleChildDescendants;
151
- const resolveMetadata = options?.resolveMetadata;
152
- const stat = await provider.stat(resource);
153
- let trie;
154
- return this.toFileStat(provider, resource, stat, undefined, !!resolveMetadata, (stat, siblings) => {
155
- if (!trie) {
156
- trie = TernarySearchTree.forUris(() => !isPathCaseSensitive);
157
- trie.set(resource, true);
158
- if (resolveTo) {
159
- trie.fill(true, resolveTo);
160
- }
161
- }
162
- if (trie.get(stat.resource) || trie.findSuperstr(stat.resource.with({ query: null, fragment: null } ))) {
163
- return true;
164
- }
165
- if (stat.isDirectory && resolveSingleChildDescendants) {
166
- return siblings === 1;
167
- }
168
- return false;
169
- });
170
- }
171
- async toFileStat(provider, resource, stat, siblings, resolveMetadata, recurse) {
172
- const { providerExtUri } = this.getExtUri(provider);
173
- const fileStat = {
174
- resource,
175
- name: providerExtUri.basename(resource),
176
- isFile: (stat.type & FileType.File) !== 0,
177
- isDirectory: (stat.type & FileType.Directory) !== 0,
178
- isSymbolicLink: (stat.type & FileType.SymbolicLink) !== 0,
179
- mtime: stat.mtime,
180
- ctime: stat.ctime,
181
- size: stat.size,
182
- readonly: Boolean((stat.permissions ?? 0) & FilePermission.Readonly) || Boolean(provider.capabilities & 2048 ),
183
- locked: Boolean((stat.permissions ?? 0) & FilePermission.Locked),
184
- etag: etag({ mtime: stat.mtime, size: stat.size }),
185
- children: undefined
186
- };
187
- if (fileStat.isDirectory && recurse(fileStat, siblings)) {
188
- try {
189
- const entries = await provider.readdir(resource);
190
- const resolvedEntries = await Promises.settled(( entries.map(async ([name, type]) => {
191
- try {
192
- const childResource = providerExtUri.joinPath(resource, name);
193
- const childStat = resolveMetadata ? await provider.stat(childResource) : { type };
194
- return await this.toFileStat(provider, childResource, childStat, entries.length, resolveMetadata, recurse);
195
- }
196
- catch (error) {
197
- this.logService.trace(error);
198
- return null;
199
- }
200
- })));
201
- fileStat.children = coalesce(resolvedEntries);
202
- }
203
- catch (error) {
204
- this.logService.trace(error);
205
- fileStat.children = [];
206
- }
207
- return fileStat;
208
- }
209
- return fileStat;
210
- }
211
- async resolveAll(toResolve) {
212
- return Promises.settled(( toResolve.map(async (entry) => {
213
- try {
214
- return { stat: await this.doResolveFile(entry.resource, entry.options), success: true };
215
- }
216
- catch (error) {
217
- this.logService.trace(error);
218
- return { stat: undefined, success: false };
219
- }
220
- })));
221
- }
222
- async stat(resource) {
223
- const provider = await this.withProvider(resource);
224
- const stat = await provider.stat(resource);
225
- return this.toFileStat(provider, resource, stat, undefined, true, () => false );
226
- }
227
- async exists(resource) {
228
- const provider = await this.withProvider(resource);
229
- try {
230
- const stat = await provider.stat(resource);
231
- return !!stat;
232
- }
233
- catch (error) {
234
- return false;
235
- }
236
- }
237
- async canCreateFile(resource, options) {
238
- try {
239
- await this.doValidateCreateFile(resource, options);
240
- }
241
- catch (error) {
242
- return error;
243
- }
244
- return true;
245
- }
246
- async doValidateCreateFile(resource, options) {
247
- if (!options?.overwrite && (await this.exists(resource))) {
248
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'fileExists', "Unable to create file '{0}' that already exists when overwrite flag is not set", this.resourceForError(resource)), 3 , options);
249
- }
250
- }
251
- async createFile(resource, bufferOrReadableOrStream = VSBuffer.fromString(''), options) {
252
- await this.doValidateCreateFile(resource, options);
253
- const fileStat = await this.writeFile(resource, bufferOrReadableOrStream);
254
- this._onDidRunOperation.fire(( new FileOperationEvent(resource, 0 , fileStat)));
255
- return fileStat;
256
- }
257
- async writeFile(resource, bufferOrReadableOrStream, options) {
258
- const provider = this.throwIfFileSystemIsReadonly(await this.withWriteProvider(resource), resource);
259
- const { providerExtUri } = this.getExtUri(provider);
260
- let writeFileOptions = options;
261
- if (hasFileAtomicWriteCapability(provider) && !writeFileOptions?.atomic) {
262
- const enforcedAtomicWrite = provider.enforceAtomicWriteFile?.(resource);
263
- if (enforcedAtomicWrite) {
264
- writeFileOptions = { ...options, atomic: enforcedAtomicWrite };
265
- }
266
- }
267
- try {
268
- const stat = await this.validateWriteFile(provider, resource, writeFileOptions);
269
- if (!stat) {
270
- await this.mkdirp(provider, providerExtUri.dirname(resource));
271
- }
272
- let bufferOrReadableOrStreamOrBufferedStream;
273
- if (hasReadWriteCapability(provider) && !(bufferOrReadableOrStream instanceof VSBuffer)) {
274
- if (isReadableStream(bufferOrReadableOrStream)) {
275
- const bufferedStream = await peekStream(bufferOrReadableOrStream, 3);
276
- if (bufferedStream.ended) {
277
- bufferOrReadableOrStreamOrBufferedStream = VSBuffer.concat(bufferedStream.buffer);
278
- }
279
- else {
280
- bufferOrReadableOrStreamOrBufferedStream = bufferedStream;
281
- }
282
- }
283
- else {
284
- bufferOrReadableOrStreamOrBufferedStream = peekReadable(bufferOrReadableOrStream, data => VSBuffer.concat(data), 3);
285
- }
286
- }
287
- else {
288
- bufferOrReadableOrStreamOrBufferedStream = bufferOrReadableOrStream;
289
- }
290
- if (!hasOpenReadWriteCloseCapability(provider) ||
291
- (hasReadWriteCapability(provider) && bufferOrReadableOrStreamOrBufferedStream instanceof VSBuffer) ||
292
- (hasReadWriteCapability(provider) && hasFileAtomicWriteCapability(provider) && writeFileOptions?.atomic)
293
- ) {
294
- await this.doWriteUnbuffered(provider, resource, writeFileOptions, bufferOrReadableOrStreamOrBufferedStream);
295
- }
296
- else {
297
- await this.doWriteBuffered(provider, resource, writeFileOptions, bufferOrReadableOrStreamOrBufferedStream instanceof VSBuffer ? bufferToReadable(bufferOrReadableOrStreamOrBufferedStream) : bufferOrReadableOrStreamOrBufferedStream);
298
- }
299
- this._onDidRunOperation.fire(( new FileOperationEvent(resource, 4 )));
300
- }
301
- catch (error) {
302
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'err.write', "Unable to write file '{0}' ({1})", this.resourceForError(resource), ensureFileSystemProviderError(error).toString()), toFileOperationResult(error), writeFileOptions);
303
- }
304
- return this.resolve(resource, { resolveMetadata: true });
305
- }
306
- async validateWriteFile(provider, resource, options) {
307
- const unlock = !!options?.unlock;
308
- if (unlock && !((provider.capabilities & 8192) )) {
309
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'writeFailedUnlockUnsupported', "Unable to unlock file '{0}' because provider does not support it.", this.resourceForError(resource)));
310
- }
311
- const atomic = !!options?.atomic;
312
- if (atomic) {
313
- if (!((provider.capabilities & 32768) )) {
314
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'writeFailedAtomicUnsupported1', "Unable to atomically write file '{0}' because provider does not support it.", this.resourceForError(resource)));
315
- }
316
- if (!((provider.capabilities & 2) )) {
317
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'writeFailedAtomicUnsupported2', "Unable to atomically write file '{0}' because provider does not support unbuffered writes.", this.resourceForError(resource)));
318
- }
319
- if (unlock) {
320
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'writeFailedAtomicUnlock', "Unable to unlock file '{0}' because atomic write is enabled.", this.resourceForError(resource)));
321
- }
322
- }
323
- let stat = undefined;
324
- try {
325
- stat = await provider.stat(resource);
326
- }
327
- catch (error) {
328
- return undefined;
329
- }
330
- if ((stat.type & FileType.Directory) !== 0) {
331
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'fileIsDirectoryWriteError', "Unable to write file '{0}' that is actually a directory", this.resourceForError(resource)), 0 , options);
332
- }
333
- this.throwIfFileIsReadonly(resource, stat);
334
- if (typeof options?.mtime === 'number' && typeof options.etag === 'string' && options.etag !== ETAG_DISABLED &&
335
- typeof stat.mtime === 'number' && typeof stat.size === 'number' &&
336
- options.mtime < stat.mtime && options.etag !== etag({ mtime: options.mtime , size: stat.size })) {
337
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'fileModifiedError', "File Modified Since"), 3 , options);
338
- }
339
- return stat;
340
- }
341
- async readFile(resource, options, token) {
342
- const provider = await this.withReadProvider(resource);
343
- if (options?.atomic) {
344
- return this.doReadFileAtomic(provider, resource, options, token);
345
- }
346
- return this.doReadFile(provider, resource, options, token);
347
- }
348
- async doReadFileAtomic(provider, resource, options, token) {
349
- return ( new Promise((resolve, reject) => {
350
- this.writeQueue.queueFor(resource, async () => {
351
- try {
352
- const content = await this.doReadFile(provider, resource, options, token);
353
- resolve(content);
354
- }
355
- catch (error) {
356
- reject(error);
357
- }
358
- }, this.getExtUri(provider).providerExtUri);
359
- }));
360
- }
361
- async doReadFile(provider, resource, options, token) {
362
- const stream = await this.doReadFileStream(provider, resource, {
363
- ...options,
364
- preferUnbuffered: true
365
- }, token);
366
- return {
367
- ...stream,
368
- value: await streamToBuffer(stream.value)
369
- };
370
- }
371
- async readFileStream(resource, options, token) {
372
- const provider = await this.withReadProvider(resource);
373
- return this.doReadFileStream(provider, resource, options, token);
374
- }
375
- async doReadFileStream(provider, resource, options, token) {
376
- const cancellableSource = ( new CancellationTokenSource(token));
377
- let readFileOptions = options;
378
- if (hasFileAtomicReadCapability(provider) && provider.enforceAtomicReadFile?.(resource)) {
379
- readFileOptions = { ...options, atomic: true };
380
- }
381
- const statPromise = this.validateReadFile(resource, readFileOptions).then(stat => stat, error => {
382
- cancellableSource.dispose(true);
383
- throw error;
384
- });
385
- let fileStream = undefined;
386
- try {
387
- if (typeof readFileOptions?.etag === 'string' && readFileOptions.etag !== ETAG_DISABLED) {
388
- await statPromise;
389
- }
390
- if ((readFileOptions?.atomic && hasFileAtomicReadCapability(provider)) ||
391
- !(hasOpenReadWriteCloseCapability(provider) || hasFileReadStreamCapability(provider)) ||
392
- (hasReadWriteCapability(provider) && readFileOptions?.preferUnbuffered)
393
- ) {
394
- fileStream = this.readFileUnbuffered(provider, resource, readFileOptions);
395
- }
396
- else if (hasFileReadStreamCapability(provider)) {
397
- fileStream = this.readFileStreamed(provider, resource, cancellableSource.token, readFileOptions);
398
- }
399
- else {
400
- fileStream = this.readFileBuffered(provider, resource, cancellableSource.token, readFileOptions);
401
- }
402
- fileStream.on('end', () => cancellableSource.dispose());
403
- fileStream.on('error', () => cancellableSource.dispose());
404
- const fileStat = await statPromise;
405
- return {
406
- ...fileStat,
407
- value: fileStream
408
- };
409
- }
410
- catch (error) {
411
- if (fileStream) {
412
- await consumeStream(fileStream);
413
- }
414
- throw this.restoreReadError(error, resource, readFileOptions);
415
- }
416
- }
417
- restoreReadError(error, resource, options) {
418
- const message = ( localizeWithPath(
419
- 'vs/platform/files/common/fileService',
420
- 'err.read',
421
- "Unable to read file '{0}' ({1})",
422
- this.resourceForError(resource),
423
- ( ensureFileSystemProviderError(error).toString())
424
- ));
425
- if (error instanceof NotModifiedSinceFileOperationError) {
426
- return ( new NotModifiedSinceFileOperationError(message, error.stat, options));
427
- }
428
- if (error instanceof TooLargeFileOperationError) {
429
- return ( new TooLargeFileOperationError(message, error.fileOperationResult, error.size, error.options));
430
- }
431
- return ( new FileOperationError(message, toFileOperationResult(error), options));
432
- }
433
- readFileStreamed(provider, resource, token, options = Object.create(null)) {
434
- const fileStream = provider.readFileStream(resource, options, token);
435
- return transform(fileStream, {
436
- data: data => data instanceof VSBuffer ? data : VSBuffer.wrap(data),
437
- error: error => this.restoreReadError(error, resource, options)
438
- }, data => VSBuffer.concat(data));
439
- }
440
- readFileBuffered(provider, resource, token, options = Object.create(null)) {
441
- const stream = newWriteableBufferStream();
442
- readFileIntoStream(provider, resource, stream, data => data, {
443
- ...options,
444
- bufferSize: this.BUFFER_SIZE,
445
- errorTransformer: error => this.restoreReadError(error, resource, options)
446
- }, token);
447
- return stream;
448
- }
449
- readFileUnbuffered(provider, resource, options) {
450
- const stream = newWriteableStream(data => VSBuffer.concat(data));
451
- (async () => {
452
- try {
453
- let buffer;
454
- if (options?.atomic && hasFileAtomicReadCapability(provider)) {
455
- buffer = await provider.readFile(resource, { atomic: true });
456
- }
457
- else {
458
- buffer = await provider.readFile(resource);
459
- }
460
- if (typeof options?.position === 'number') {
461
- buffer = buffer.slice(options.position);
462
- }
463
- if (typeof options?.length === 'number') {
464
- buffer = buffer.slice(0, options.length);
465
- }
466
- this.validateReadFileLimits(resource, buffer.byteLength, options);
467
- stream.end(VSBuffer.wrap(buffer));
468
- }
469
- catch (err) {
470
- stream.error(err);
471
- stream.end();
472
- }
473
- })();
474
- return stream;
475
- }
476
- async validateReadFile(resource, options) {
477
- const stat = await this.resolve(resource, { resolveMetadata: true });
478
- if (stat.isDirectory) {
479
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'fileIsDirectoryReadError', "Unable to read file '{0}' that is actually a directory", this.resourceForError(resource)), 0 , options);
480
- }
481
- if (typeof options?.etag === 'string' && options.etag !== ETAG_DISABLED && options.etag === stat.etag) {
482
- throw new NotModifiedSinceFileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'fileNotModifiedError', "File not modified since"), stat, options);
483
- }
484
- this.validateReadFileLimits(resource, stat.size, options);
485
- return stat;
486
- }
487
- validateReadFileLimits(resource, size, options) {
488
- if (typeof options?.limits?.size === 'number' && size > options.limits.size) {
489
- throw new TooLargeFileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'fileTooLargeError', "Unable to read file '{0}' that is too large to open", this.resourceForError(resource)), 7 , size, options);
490
- }
491
- }
492
- async canMove(source, target, overwrite) {
493
- return this.doCanMoveCopy(source, target, 'move', overwrite);
494
- }
495
- async canCopy(source, target, overwrite) {
496
- return this.doCanMoveCopy(source, target, 'copy', overwrite);
497
- }
498
- async doCanMoveCopy(source, target, mode, overwrite) {
499
- if (( source.toString()) !== ( target.toString())) {
500
- try {
501
- const sourceProvider = mode === 'move' ? this.throwIfFileSystemIsReadonly(await this.withWriteProvider(source), source) : await this.withReadProvider(source);
502
- const targetProvider = this.throwIfFileSystemIsReadonly(await this.withWriteProvider(target), target);
503
- await this.doValidateMoveCopy(sourceProvider, source, targetProvider, target, mode, overwrite);
504
- }
505
- catch (error) {
506
- return error;
507
- }
508
- }
509
- return true;
510
- }
511
- async move(source, target, overwrite) {
512
- const sourceProvider = this.throwIfFileSystemIsReadonly(await this.withWriteProvider(source), source);
513
- const targetProvider = this.throwIfFileSystemIsReadonly(await this.withWriteProvider(target), target);
514
- const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'move', !!overwrite);
515
- const fileStat = await this.resolve(target, { resolveMetadata: true });
516
- this._onDidRunOperation.fire(( new FileOperationEvent(
517
- source,
518
- mode === 'move' ? 2 : 3 ,
519
- fileStat
520
- )));
521
- return fileStat;
522
- }
523
- async copy(source, target, overwrite) {
524
- const sourceProvider = await this.withReadProvider(source);
525
- const targetProvider = this.throwIfFileSystemIsReadonly(await this.withWriteProvider(target), target);
526
- const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'copy', !!overwrite);
527
- const fileStat = await this.resolve(target, { resolveMetadata: true });
528
- this._onDidRunOperation.fire(( new FileOperationEvent(
529
- source,
530
- mode === 'copy' ? 3 : 2 ,
531
- fileStat
532
- )));
533
- return fileStat;
534
- }
535
- async doMoveCopy(sourceProvider, source, targetProvider, target, mode, overwrite) {
536
- if (( source.toString()) === ( target.toString())) {
537
- return mode;
538
- }
539
- const { exists, isSameResourceWithDifferentPathCase } = await this.doValidateMoveCopy(sourceProvider, source, targetProvider, target, mode, overwrite);
540
- if (exists && !isSameResourceWithDifferentPathCase && overwrite) {
541
- await this.del(target, { recursive: true });
542
- }
543
- await this.mkdirp(targetProvider, this.getExtUri(targetProvider).providerExtUri.dirname(target));
544
- if (mode === 'copy') {
545
- if (sourceProvider === targetProvider && hasFileFolderCopyCapability(sourceProvider)) {
546
- await sourceProvider.copy(source, target, { overwrite });
547
- }
548
- else {
549
- const sourceFile = await this.resolve(source);
550
- if (sourceFile.isDirectory) {
551
- await this.doCopyFolder(sourceProvider, sourceFile, targetProvider, target);
552
- }
553
- else {
554
- await this.doCopyFile(sourceProvider, source, targetProvider, target);
555
- }
556
- }
557
- return mode;
558
- }
559
- else {
560
- if (sourceProvider === targetProvider) {
561
- await sourceProvider.rename(source, target, { overwrite });
562
- return mode;
563
- }
564
- else {
565
- await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'copy', overwrite);
566
- await this.del(source, { recursive: true });
567
- return 'copy';
568
- }
569
- }
570
- }
571
- async doCopyFile(sourceProvider, source, targetProvider, target) {
572
- if (hasOpenReadWriteCloseCapability(sourceProvider) && hasOpenReadWriteCloseCapability(targetProvider)) {
573
- return this.doPipeBuffered(sourceProvider, source, targetProvider, target);
574
- }
575
- if (hasOpenReadWriteCloseCapability(sourceProvider) && hasReadWriteCapability(targetProvider)) {
576
- return this.doPipeBufferedToUnbuffered(sourceProvider, source, targetProvider, target);
577
- }
578
- if (hasReadWriteCapability(sourceProvider) && hasOpenReadWriteCloseCapability(targetProvider)) {
579
- return this.doPipeUnbufferedToBuffered(sourceProvider, source, targetProvider, target);
580
- }
581
- if (hasReadWriteCapability(sourceProvider) && hasReadWriteCapability(targetProvider)) {
582
- return this.doPipeUnbuffered(sourceProvider, source, targetProvider, target);
583
- }
584
- }
585
- async doCopyFolder(sourceProvider, sourceFolder, targetProvider, targetFolder) {
586
- await targetProvider.mkdir(targetFolder);
587
- if (Array.isArray(sourceFolder.children)) {
588
- await Promises.settled(( sourceFolder.children.map(async (sourceChild) => {
589
- const targetChild = this.getExtUri(targetProvider).providerExtUri.joinPath(targetFolder, sourceChild.name);
590
- if (sourceChild.isDirectory) {
591
- return this.doCopyFolder(sourceProvider, await this.resolve(sourceChild.resource), targetProvider, targetChild);
592
- }
593
- else {
594
- return this.doCopyFile(sourceProvider, sourceChild.resource, targetProvider, targetChild);
595
- }
596
- })));
597
- }
598
- }
599
- async doValidateMoveCopy(sourceProvider, source, targetProvider, target, mode, overwrite) {
600
- let isSameResourceWithDifferentPathCase = false;
601
- if (sourceProvider === targetProvider) {
602
- const { providerExtUri, isPathCaseSensitive } = this.getExtUri(sourceProvider);
603
- if (!isPathCaseSensitive) {
604
- isSameResourceWithDifferentPathCase = providerExtUri.isEqual(source, target);
605
- }
606
- if (isSameResourceWithDifferentPathCase && mode === 'copy') {
607
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'unableToMoveCopyError1', "Unable to copy when source '{0}' is same as target '{1}' with different path case on a case insensitive file system", this.resourceForError(source), this.resourceForError(target)));
608
- }
609
- if (!isSameResourceWithDifferentPathCase && providerExtUri.isEqualOrParent(target, source)) {
610
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'unableToMoveCopyError2', "Unable to move/copy when source '{0}' is parent of target '{1}'.", this.resourceForError(source), this.resourceForError(target)));
611
- }
612
- }
613
- const exists = await this.exists(target);
614
- if (exists && !isSameResourceWithDifferentPathCase) {
615
- if (!overwrite) {
616
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'unableToMoveCopyError3', "Unable to move/copy '{0}' because target '{1}' already exists at destination.", this.resourceForError(source), this.resourceForError(target)), 4 );
617
- }
618
- if (sourceProvider === targetProvider) {
619
- const { providerExtUri } = this.getExtUri(sourceProvider);
620
- if (providerExtUri.isEqualOrParent(source, target)) {
621
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'unableToMoveCopyError4', "Unable to move/copy '{0}' into '{1}' since a file would replace the folder it is contained in.", this.resourceForError(source), this.resourceForError(target)));
622
- }
623
- }
624
- }
625
- return { exists, isSameResourceWithDifferentPathCase };
626
- }
627
- getExtUri(provider) {
628
- const isPathCaseSensitive = this.isPathCaseSensitive(provider);
629
- return {
630
- providerExtUri: isPathCaseSensitive ? extUri : extUriIgnorePathCase,
631
- isPathCaseSensitive
632
- };
633
- }
634
- isPathCaseSensitive(provider) {
635
- return !!((provider.capabilities & 1024) );
636
- }
637
- async createFolder(resource) {
638
- const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource), resource);
639
- await this.mkdirp(provider, resource);
640
- const fileStat = await this.resolve(resource, { resolveMetadata: true });
641
- this._onDidRunOperation.fire(( new FileOperationEvent(resource, 0 , fileStat)));
642
- return fileStat;
643
- }
644
- async mkdirp(provider, directory) {
645
- const directoriesToCreate = [];
646
- const { providerExtUri } = this.getExtUri(provider);
647
- while (!providerExtUri.isEqual(directory, providerExtUri.dirname(directory))) {
648
- try {
649
- const stat = await provider.stat(directory);
650
- if ((stat.type & FileType.Directory) === 0) {
651
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'mkdirExistsError', "Unable to create folder '{0}' that already exists but is not a directory", this.resourceForError(directory)));
652
- }
653
- break;
654
- }
655
- catch (error) {
656
- if (toFileSystemProviderErrorCode(error) !== FileSystemProviderErrorCode.FileNotFound) {
657
- throw error;
658
- }
659
- directoriesToCreate.push(providerExtUri.basename(directory));
660
- directory = providerExtUri.dirname(directory);
661
- }
662
- }
663
- for (let i = directoriesToCreate.length - 1; i >= 0; i--) {
664
- directory = providerExtUri.joinPath(directory, directoriesToCreate[i]);
665
- try {
666
- await provider.mkdir(directory);
667
- }
668
- catch (error) {
669
- if (toFileSystemProviderErrorCode(error) !== FileSystemProviderErrorCode.FileExists) {
670
- throw error;
671
- }
672
- }
673
- }
674
- }
675
- async canDelete(resource, options) {
676
- try {
677
- await this.doValidateDelete(resource, options);
678
- }
679
- catch (error) {
680
- return error;
681
- }
682
- return true;
683
- }
684
- async doValidateDelete(resource, options) {
685
- const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource), resource);
686
- const useTrash = !!options?.useTrash;
687
- if (useTrash && !((provider.capabilities & 4096) )) {
688
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'deleteFailedTrashUnsupported', "Unable to delete file '{0}' via trash because provider does not support it.", this.resourceForError(resource)));
689
- }
690
- const atomic = options?.atomic;
691
- if (atomic && !((provider.capabilities & 65536) )) {
692
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'deleteFailedAtomicUnsupported', "Unable to delete file '{0}' atomically because provider does not support it.", this.resourceForError(resource)));
693
- }
694
- if (useTrash && atomic) {
695
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'deleteFailedTrashAndAtomicUnsupported', "Unable to atomically delete file '{0}' because using trash is enabled.", this.resourceForError(resource)));
696
- }
697
- let stat = undefined;
698
- try {
699
- stat = await provider.stat(resource);
700
- }
701
- catch (error) {
702
- }
703
- if (stat) {
704
- this.throwIfFileIsReadonly(resource, stat);
705
- }
706
- else {
707
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'deleteFailedNotFound', "Unable to delete nonexistent file '{0}'", this.resourceForError(resource)), 1 );
708
- }
709
- const recursive = !!options?.recursive;
710
- if (!recursive) {
711
- const stat = await this.resolve(resource);
712
- if (stat.isDirectory && Array.isArray(stat.children) && stat.children.length > 0) {
713
- throw new Error(localizeWithPath('vs/platform/files/common/fileService', 'deleteFailedNonEmptyFolder', "Unable to delete non-empty folder '{0}'.", this.resourceForError(resource)));
714
- }
715
- }
716
- return provider;
717
- }
718
- async del(resource, options) {
719
- const provider = await this.doValidateDelete(resource, options);
720
- let deleteFileOptions = options;
721
- if (hasFileAtomicDeleteCapability(provider) && !deleteFileOptions?.atomic) {
722
- const enforcedAtomicDelete = provider.enforceAtomicDelete?.(resource);
723
- if (enforcedAtomicDelete) {
724
- deleteFileOptions = { ...options, atomic: enforcedAtomicDelete };
725
- }
726
- }
727
- const useTrash = !!deleteFileOptions?.useTrash;
728
- const recursive = !!deleteFileOptions?.recursive;
729
- const atomic = deleteFileOptions?.atomic ?? false;
730
- await provider.delete(resource, { recursive, useTrash, atomic });
731
- this._onDidRunOperation.fire(( new FileOperationEvent(resource, 1 )));
732
- }
733
- async cloneFile(source, target) {
734
- const sourceProvider = await this.withProvider(source);
735
- const targetProvider = this.throwIfFileSystemIsReadonly(await this.withWriteProvider(target), target);
736
- if (sourceProvider === targetProvider && this.getExtUri(sourceProvider).providerExtUri.isEqual(source, target)) {
737
- return;
738
- }
739
- if (sourceProvider === targetProvider && hasFileCloneCapability(sourceProvider)) {
740
- return sourceProvider.cloneFile(source, target);
741
- }
742
- await this.mkdirp(targetProvider, this.getExtUri(targetProvider).providerExtUri.dirname(target));
743
- if (sourceProvider === targetProvider && hasFileFolderCopyCapability(sourceProvider)) {
744
- return this.writeQueue.queueFor(source, () => sourceProvider.copy(source, target, { overwrite: true }), this.getExtUri(sourceProvider).providerExtUri);
745
- }
746
- return this.writeQueue.queueFor(source, () => this.doCopyFile(sourceProvider, source, targetProvider, target), this.getExtUri(sourceProvider).providerExtUri);
747
- }
748
- static { this.WATCHER_CORRELATION_IDS = 0; }
749
- createWatcher(resource, options) {
750
- return this.watch(resource, {
751
- ...options,
752
- correlationId: FileService_1.WATCHER_CORRELATION_IDS++
753
- });
754
- }
755
- watch(resource, options = { recursive: false, excludes: [] }) {
756
- const disposables = ( new DisposableStore());
757
- let watchDisposed = false;
758
- let disposeWatch = () => { watchDisposed = true; };
759
- disposables.add(toDisposable(() => disposeWatch()));
760
- (async () => {
761
- try {
762
- const disposable = await this.doWatch(resource, options);
763
- if (watchDisposed) {
764
- dispose(disposable);
765
- }
766
- else {
767
- disposeWatch = () => dispose(disposable);
768
- }
769
- }
770
- catch (error) {
771
- this.logService.error(error);
772
- }
773
- })();
774
- const correlationId = options.correlationId;
775
- if (typeof correlationId === 'number') {
776
- const fileChangeEmitter = disposables.add(( new Emitter()));
777
- disposables.add(this.internalOnDidFilesChange.event(e => {
778
- if (e.correlates(correlationId)) {
779
- fileChangeEmitter.fire(e);
780
- }
781
- }));
782
- const watcher = {
783
- onDidChange: fileChangeEmitter.event,
784
- dispose: () => disposables.dispose()
785
- };
786
- return watcher;
787
- }
788
- return disposables;
789
- }
790
- async doWatch(resource, options) {
791
- const provider = await this.withProvider(resource);
792
- const watchHash = hash([this.getExtUri(provider).providerExtUri.getComparisonKey(resource), options]);
793
- let watcher = this.activeWatchers.get(watchHash);
794
- if (!watcher) {
795
- watcher = {
796
- count: 0,
797
- disposable: provider.watch(resource, options)
798
- };
799
- this.activeWatchers.set(watchHash, watcher);
800
- }
801
- watcher.count += 1;
802
- return toDisposable(() => {
803
- if (watcher) {
804
- watcher.count--;
805
- if (watcher.count === 0) {
806
- dispose(watcher.disposable);
807
- this.activeWatchers.delete(watchHash);
808
- }
809
- }
810
- });
811
- }
812
- dispose() {
813
- super.dispose();
814
- for (const [, watcher] of this.activeWatchers) {
815
- dispose(watcher.disposable);
816
- }
817
- this.activeWatchers.clear();
818
- }
819
- async doWriteBuffered(provider, resource, options, readableOrStreamOrBufferedStream) {
820
- return this.writeQueue.queueFor(resource, async () => {
821
- const handle = await provider.open(resource, { create: true, unlock: options?.unlock ?? false });
822
- try {
823
- if (isReadableStream(readableOrStreamOrBufferedStream) || isReadableBufferedStream(readableOrStreamOrBufferedStream)) {
824
- await this.doWriteStreamBufferedQueued(provider, handle, readableOrStreamOrBufferedStream);
825
- }
826
- else {
827
- await this.doWriteReadableBufferedQueued(provider, handle, readableOrStreamOrBufferedStream);
828
- }
829
- }
830
- catch (error) {
831
- throw ensureFileSystemProviderError(error);
832
- }
833
- finally {
834
- await provider.close(handle);
835
- }
836
- }, this.getExtUri(provider).providerExtUri);
837
- }
838
- async doWriteStreamBufferedQueued(provider, handle, streamOrBufferedStream) {
839
- let posInFile = 0;
840
- let stream;
841
- if (isReadableBufferedStream(streamOrBufferedStream)) {
842
- if (streamOrBufferedStream.buffer.length > 0) {
843
- const chunk = VSBuffer.concat(streamOrBufferedStream.buffer);
844
- await this.doWriteBuffer(provider, handle, chunk, chunk.byteLength, posInFile, 0);
845
- posInFile += chunk.byteLength;
846
- }
847
- if (streamOrBufferedStream.ended) {
848
- return;
849
- }
850
- stream = streamOrBufferedStream.stream;
851
- }
852
- else {
853
- stream = streamOrBufferedStream;
854
- }
855
- return ( new Promise((resolve, reject) => {
856
- listenStream(stream, {
857
- onData: async (chunk) => {
858
- stream.pause();
859
- try {
860
- await this.doWriteBuffer(provider, handle, chunk, chunk.byteLength, posInFile, 0);
861
- }
862
- catch (error) {
863
- return reject(error);
864
- }
865
- posInFile += chunk.byteLength;
866
- setTimeout(() => stream.resume());
867
- },
868
- onError: error => reject(error),
869
- onEnd: () => resolve()
870
- });
871
- }));
872
- }
873
- async doWriteReadableBufferedQueued(provider, handle, readable) {
874
- let posInFile = 0;
875
- let chunk;
876
- while ((chunk = readable.read()) !== null) {
877
- await this.doWriteBuffer(provider, handle, chunk, chunk.byteLength, posInFile, 0);
878
- posInFile += chunk.byteLength;
879
- }
880
- }
881
- async doWriteBuffer(provider, handle, buffer, length, posInFile, posInBuffer) {
882
- let totalBytesWritten = 0;
883
- while (totalBytesWritten < length) {
884
- const bytesWritten = await provider.write(handle, posInFile + totalBytesWritten, buffer.buffer, posInBuffer + totalBytesWritten, length - totalBytesWritten);
885
- totalBytesWritten += bytesWritten;
886
- }
887
- }
888
- async doWriteUnbuffered(provider, resource, options, bufferOrReadableOrStreamOrBufferedStream) {
889
- return this.writeQueue.queueFor(resource, () => this.doWriteUnbufferedQueued(provider, resource, options, bufferOrReadableOrStreamOrBufferedStream), this.getExtUri(provider).providerExtUri);
890
- }
891
- async doWriteUnbufferedQueued(provider, resource, options, bufferOrReadableOrStreamOrBufferedStream) {
892
- let buffer;
893
- if (bufferOrReadableOrStreamOrBufferedStream instanceof VSBuffer) {
894
- buffer = bufferOrReadableOrStreamOrBufferedStream;
895
- }
896
- else if (isReadableStream(bufferOrReadableOrStreamOrBufferedStream)) {
897
- buffer = await streamToBuffer(bufferOrReadableOrStreamOrBufferedStream);
898
- }
899
- else if (isReadableBufferedStream(bufferOrReadableOrStreamOrBufferedStream)) {
900
- buffer = await bufferedStreamToBuffer(bufferOrReadableOrStreamOrBufferedStream);
901
- }
902
- else {
903
- buffer = readableToBuffer(bufferOrReadableOrStreamOrBufferedStream);
904
- }
905
- await provider.writeFile(resource, buffer.buffer, { create: true, overwrite: true, unlock: options?.unlock ?? false, atomic: options?.atomic ?? false });
906
- }
907
- async doPipeBuffered(sourceProvider, source, targetProvider, target) {
908
- return this.writeQueue.queueFor(target, () => this.doPipeBufferedQueued(sourceProvider, source, targetProvider, target), this.getExtUri(targetProvider).providerExtUri);
909
- }
910
- async doPipeBufferedQueued(sourceProvider, source, targetProvider, target) {
911
- let sourceHandle = undefined;
912
- let targetHandle = undefined;
913
- try {
914
- sourceHandle = await sourceProvider.open(source, { create: false });
915
- targetHandle = await targetProvider.open(target, { create: true, unlock: false });
916
- const buffer = VSBuffer.alloc(this.BUFFER_SIZE);
917
- let posInFile = 0;
918
- let posInBuffer = 0;
919
- let bytesRead = 0;
920
- do {
921
- bytesRead = await sourceProvider.read(sourceHandle, posInFile, buffer.buffer, posInBuffer, buffer.byteLength - posInBuffer);
922
- await this.doWriteBuffer(targetProvider, targetHandle, buffer, bytesRead, posInFile, posInBuffer);
923
- posInFile += bytesRead;
924
- posInBuffer += bytesRead;
925
- if (posInBuffer === buffer.byteLength) {
926
- posInBuffer = 0;
927
- }
928
- } while (bytesRead > 0);
929
- }
930
- catch (error) {
931
- throw ensureFileSystemProviderError(error);
932
- }
933
- finally {
934
- await Promises.settled([
935
- typeof sourceHandle === 'number' ? sourceProvider.close(sourceHandle) : Promise.resolve(),
936
- typeof targetHandle === 'number' ? targetProvider.close(targetHandle) : Promise.resolve(),
937
- ]);
938
- }
939
- }
940
- async doPipeUnbuffered(sourceProvider, source, targetProvider, target) {
941
- return this.writeQueue.queueFor(target, () => this.doPipeUnbufferedQueued(sourceProvider, source, targetProvider, target), this.getExtUri(targetProvider).providerExtUri);
942
- }
943
- async doPipeUnbufferedQueued(sourceProvider, source, targetProvider, target) {
944
- return targetProvider.writeFile(target, await sourceProvider.readFile(source), { create: true, overwrite: true, unlock: false, atomic: false });
945
- }
946
- async doPipeUnbufferedToBuffered(sourceProvider, source, targetProvider, target) {
947
- return this.writeQueue.queueFor(target, () => this.doPipeUnbufferedToBufferedQueued(sourceProvider, source, targetProvider, target), this.getExtUri(targetProvider).providerExtUri);
948
- }
949
- async doPipeUnbufferedToBufferedQueued(sourceProvider, source, targetProvider, target) {
950
- const targetHandle = await targetProvider.open(target, { create: true, unlock: false });
951
- try {
952
- const buffer = await sourceProvider.readFile(source);
953
- await this.doWriteBuffer(targetProvider, targetHandle, VSBuffer.wrap(buffer), buffer.byteLength, 0, 0);
954
- }
955
- catch (error) {
956
- throw ensureFileSystemProviderError(error);
957
- }
958
- finally {
959
- await targetProvider.close(targetHandle);
960
- }
961
- }
962
- async doPipeBufferedToUnbuffered(sourceProvider, source, targetProvider, target) {
963
- const buffer = await streamToBuffer(this.readFileBuffered(sourceProvider, source, CancellationToken.None));
964
- await this.doWriteUnbuffered(targetProvider, target, undefined, buffer);
965
- }
966
- throwIfFileSystemIsReadonly(provider, resource) {
967
- if (provider.capabilities & 2048 ) {
968
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'err.readonly', "Unable to modify read-only file '{0}'", this.resourceForError(resource)), 6 );
969
- }
970
- return provider;
971
- }
972
- throwIfFileIsReadonly(resource, stat) {
973
- if ((stat.permissions ?? 0) & FilePermission.Readonly) {
974
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'err.readonly', "Unable to modify read-only file '{0}'", this.resourceForError(resource)), 6 );
975
- }
976
- }
977
- resourceForError(resource) {
978
- if (resource.scheme === Schemas.file) {
979
- return resource.fsPath;
980
- }
981
- return ( resource.toString(true));
982
- }
983
- };
984
- FileService = FileService_1 = ( __decorate([
985
- ( __param(0, ILogService))
986
- ], FileService));
987
-
988
- export { FileService };