@codingame/monaco-vscode-files-service-override 4.5.0 → 4.5.2

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.
@@ -13,52 +13,96 @@ import { mark } from 'vscode/vscode/vs/base/common/performance';
13
13
  import { isAbsolutePath, extUri, extUriIgnorePathCase } from 'vscode/vscode/vs/base/common/resources';
14
14
  import { isReadableStream, peekStream, peekReadable, consumeStream, transform, newWriteableStream, isReadableBufferedStream, listenStream } from 'vscode/vscode/vs/base/common/stream';
15
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';
16
+ import { FileType, toFileSystemProviderErrorCode, FileSystemProviderErrorCode, FileChangesEvent, FileOperationError, hasOpenReadWriteCloseCapability, hasReadWriteCapability, hasFileReadStreamCapability, ensureFileSystemProviderError, FilePermission, etag, FileOperationEvent, hasFileAtomicWriteCapability, toFileOperationResult, ETAG_DISABLED, hasFileAtomicReadCapability, NotModifiedSinceFileOperationError, TooLargeFileOperationError, hasFileFolderCopyCapability, hasFileAtomicDeleteCapability, hasFileCloneCapability } from 'vscode/vscode/vs/platform/files/common/files';
17
17
  import { readFileIntoStream } from './io.js';
18
18
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
19
19
  import { ErrorNoTelemetry } from 'vscode/vscode/vs/base/common/errors';
20
20
 
21
21
  var FileService_1;
22
+ const _moduleId = "vs/platform/files/common/fileService";
23
+ function resourceForError(resource) {
24
+ if (resource.scheme === Schemas.file) {
25
+ return resource.fsPath;
26
+ }
27
+ return (
28
+ (resource.toString(true))
29
+ );
30
+ }
31
+ async function mkdirp(providerExtUri, provider, directory) {
32
+ const directoriesToCreate = [];
33
+ while (!providerExtUri.isEqual(directory, providerExtUri.dirname(directory))) {
34
+ try {
35
+ const stat = await provider.stat(directory);
36
+ if ((stat.type & FileType.Directory) === 0) {
37
+ throw ( (new Error(localizeWithPath(
38
+ _moduleId,
39
+ 0,
40
+ "Unable to create folder '{0}' that already exists but is not a directory",
41
+ resourceForError(directory)
42
+ ))));
43
+ }
44
+ break;
45
+ }
46
+ catch (error) {
47
+ if (toFileSystemProviderErrorCode(error) !== FileSystemProviderErrorCode.FileNotFound) {
48
+ throw error;
49
+ }
50
+ directoriesToCreate.push(providerExtUri.basename(directory));
51
+ directory = providerExtUri.dirname(directory);
52
+ }
53
+ }
54
+ for (let i = directoriesToCreate.length - 1; i >= 0; i--) {
55
+ directory = providerExtUri.joinPath(directory, directoriesToCreate[i]);
56
+ try {
57
+ await provider.mkdir(directory);
58
+ }
59
+ catch (error) {
60
+ if (toFileSystemProviderErrorCode(error) !== FileSystemProviderErrorCode.FileExists) {
61
+ throw error;
62
+ }
63
+ }
64
+ }
65
+ }
22
66
  let FileService = class FileService extends Disposable {
23
67
  static { FileService_1 = this; }
24
68
  constructor(logService) {
25
69
  super();
26
70
  this.logService = logService;
27
71
  this.BUFFER_SIZE = 256 * 1024;
28
- this._onDidChangeFileSystemProviderRegistrations = this._register(( new Emitter()));
72
+ this._onDidChangeFileSystemProviderRegistrations = this._register(( (new Emitter())));
29
73
  this.onDidChangeFileSystemProviderRegistrations = this._onDidChangeFileSystemProviderRegistrations.event;
30
- this._onWillActivateFileSystemProvider = this._register(( new Emitter()));
74
+ this._onWillActivateFileSystemProvider = this._register(( (new Emitter())));
31
75
  this.onWillActivateFileSystemProvider = this._onWillActivateFileSystemProvider.event;
32
- this._onDidChangeFileSystemProviderCapabilities = this._register(( new Emitter()));
76
+ this._onDidChangeFileSystemProviderCapabilities = this._register(( (new Emitter())));
33
77
  this.onDidChangeFileSystemProviderCapabilities = this._onDidChangeFileSystemProviderCapabilities.event;
34
- this.provider = ( new Map());
35
- this._onDidRunOperation = this._register(( new Emitter()));
78
+ this.provider = ( (new Map()));
79
+ this._onDidRunOperation = this._register(( (new Emitter())));
36
80
  this.onDidRunOperation = this._onDidRunOperation.event;
37
- this.internalOnDidFilesChange = this._register(( new Emitter()));
38
- this._onDidUncorrelatedFilesChange = this._register(( new Emitter()));
81
+ this.internalOnDidFilesChange = this._register(( (new Emitter())));
82
+ this._onDidUncorrelatedFilesChange = this._register(( (new Emitter())));
39
83
  this.onDidFilesChange = this._onDidUncorrelatedFilesChange.event;
40
- this._onDidWatchError = this._register(( new Emitter()));
84
+ this._onDidWatchError = this._register(( (new Emitter())));
41
85
  this.onDidWatchError = this._onDidWatchError.event;
42
- this.activeWatchers = ( new Map());
43
- this.writeQueue = this._register(( new ResourceQueue()));
86
+ this.activeWatchers = ( (new Map()));
87
+ this.writeQueue = this._register(( (new ResourceQueue())));
44
88
  }
45
89
  registerProvider(scheme, provider) {
46
- if (( this.provider.has(scheme))) {
47
- throw new Error(`A filesystem provider for the scheme '${scheme}' is already registered.`);
90
+ if (( (this.provider.has(scheme)))) {
91
+ throw ( (new Error(`A filesystem provider for the scheme '${scheme}' is already registered.`)));
48
92
  }
49
93
  mark(`code/registerFilesystem/${scheme}`);
50
- const providerDisposables = ( new DisposableStore());
94
+ const providerDisposables = ( (new DisposableStore()));
51
95
  this.provider.set(scheme, provider);
52
96
  this._onDidChangeFileSystemProviderRegistrations.fire({ added: true, scheme, provider });
53
97
  providerDisposables.add(provider.onDidChangeFile(changes => {
54
- const event = ( new FileChangesEvent(changes, !this.isPathCaseSensitive(provider)));
98
+ const event = ( (new FileChangesEvent(changes, !this.isPathCaseSensitive(provider))));
55
99
  this.internalOnDidFilesChange.fire(event);
56
100
  if (!event.hasCorrelation()) {
57
101
  this._onDidUncorrelatedFilesChange.fire(event);
58
102
  }
59
103
  }));
60
104
  if (typeof provider.onDidWatchError === 'function') {
61
- providerDisposables.add(provider.onDidWatchError(error => this._onDidWatchError.fire(( new Error(error)))));
105
+ providerDisposables.add(provider.onDidWatchError(error => this._onDidWatchError.fire(( (new Error(error))))));
62
106
  }
63
107
  providerDisposables.add(provider.onDidChangeCapabilities(() => this._onDidChangeFileSystemProviderCapabilities.fire({ provider, scheme })));
64
108
  return toDisposable(() => {
@@ -78,7 +122,7 @@ let FileService = class FileService extends Disposable {
78
122
  joiners.push(promise);
79
123
  },
80
124
  });
81
- if (( this.provider.has(scheme))) {
125
+ if (( (this.provider.has(scheme)))) {
82
126
  return;
83
127
  }
84
128
  await Promises.settled(joiners);
@@ -88,31 +132,40 @@ let FileService = class FileService extends Disposable {
88
132
  return this.hasProvider(resource);
89
133
  }
90
134
  hasProvider(resource) {
91
- return ( this.provider.has(resource.scheme));
135
+ return (
136
+ (this.provider.has(resource.scheme))
137
+ );
92
138
  }
93
139
  hasCapability(resource, capability) {
94
140
  const provider = this.provider.get(resource.scheme);
95
141
  return !!(provider && (provider.capabilities & capability));
96
142
  }
97
143
  listCapabilities() {
98
- return ( Iterable.map(
99
- this.provider,
100
- ([scheme, provider]) => ({ scheme, capabilities: provider.capabilities })
101
- ));
144
+ return (
145
+ (Iterable.map(
146
+ this.provider,
147
+ ([scheme, provider]) => ({ scheme, capabilities: provider.capabilities })
148
+ ))
149
+ );
102
150
  }
103
151
  async withProvider(resource) {
104
152
  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 );
153
+ throw ( (new FileOperationError(localizeWithPath(
154
+ _moduleId,
155
+ 1,
156
+ "Unable to resolve filesystem provider with relative file path '{0}'",
157
+ this.resourceForError(resource)
158
+ ), 8 )));
106
159
  }
107
160
  await this.activateProvider(resource.scheme);
108
161
  const provider = this.provider.get(resource.scheme);
109
162
  if (!provider) {
110
- const error = ( new ErrorNoTelemetry());
163
+ const error = ( (new ErrorNoTelemetry()));
111
164
  error.message = ( localizeWithPath(
112
- 'vs/platform/files/common/fileService',
113
- 'noProviderFound',
165
+ _moduleId,
166
+ 2,
114
167
  "ENOPRO: No file system provider found for resource '{0}'",
115
- ( resource.toString())
168
+ (resource.toString())
116
169
  ));
117
170
  throw error;
118
171
  }
@@ -123,14 +176,18 @@ let FileService = class FileService extends Disposable {
123
176
  if (hasOpenReadWriteCloseCapability(provider) || hasReadWriteCapability(provider) || hasFileReadStreamCapability(provider)) {
124
177
  return provider;
125
178
  }
126
- throw new Error(`Filesystem provider for scheme '${resource.scheme}' neither has FileReadWrite, FileReadStream nor FileOpenReadWriteClose capability which is needed for the read operation.`);
179
+ throw ( (new Error(
180
+ `Filesystem provider for scheme '${resource.scheme}' neither has FileReadWrite, FileReadStream nor FileOpenReadWriteClose capability which is needed for the read operation.`
181
+ )));
127
182
  }
128
183
  async withWriteProvider(resource) {
129
184
  const provider = await this.withProvider(resource);
130
185
  if (hasOpenReadWriteCloseCapability(provider) || hasReadWriteCapability(provider)) {
131
186
  return provider;
132
187
  }
133
- throw new Error(`Filesystem provider for scheme '${resource.scheme}' neither has FileReadWrite nor FileOpenReadWriteClose capability which is needed for the write operation.`);
188
+ throw ( (new Error(
189
+ `Filesystem provider for scheme '${resource.scheme}' neither has FileReadWrite nor FileOpenReadWriteClose capability which is needed for the write operation.`
190
+ )));
134
191
  }
135
192
  async resolve(resource, options) {
136
193
  try {
@@ -138,7 +195,12 @@ let FileService = class FileService extends Disposable {
138
195
  }
139
196
  catch (error) {
140
197
  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 );
198
+ throw ( (new FileOperationError(localizeWithPath(
199
+ _moduleId,
200
+ 3,
201
+ "Unable to resolve nonexistent file '{0}'",
202
+ this.resourceForError(resource)
203
+ ), 1 )));
142
204
  }
143
205
  throw ensureFileSystemProviderError(error);
144
206
  }
@@ -187,7 +249,7 @@ let FileService = class FileService extends Disposable {
187
249
  if (fileStat.isDirectory && recurse(fileStat, siblings)) {
188
250
  try {
189
251
  const entries = await provider.readdir(resource);
190
- const resolvedEntries = await Promises.settled(( entries.map(async ([name, type]) => {
252
+ const resolvedEntries = await Promises.settled(( (entries.map(async ([name, type]) => {
191
253
  try {
192
254
  const childResource = providerExtUri.joinPath(resource, name);
193
255
  const childStat = resolveMetadata ? await provider.stat(childResource) : { type };
@@ -197,7 +259,7 @@ let FileService = class FileService extends Disposable {
197
259
  this.logService.trace(error);
198
260
  return null;
199
261
  }
200
- })));
262
+ }))));
201
263
  fileStat.children = coalesce(resolvedEntries);
202
264
  }
203
265
  catch (error) {
@@ -209,7 +271,7 @@ let FileService = class FileService extends Disposable {
209
271
  return fileStat;
210
272
  }
211
273
  async resolveAll(toResolve) {
212
- return Promises.settled(( toResolve.map(async (entry) => {
274
+ return Promises.settled(( (toResolve.map(async (entry) => {
213
275
  try {
214
276
  return { stat: await this.doResolveFile(entry.resource, entry.options), success: true };
215
277
  }
@@ -217,7 +279,7 @@ let FileService = class FileService extends Disposable {
217
279
  this.logService.trace(error);
218
280
  return { stat: undefined, success: false };
219
281
  }
220
- })));
282
+ }))));
221
283
  }
222
284
  async stat(resource) {
223
285
  const provider = await this.withProvider(resource);
@@ -245,13 +307,18 @@ let FileService = class FileService extends Disposable {
245
307
  }
246
308
  async doValidateCreateFile(resource, options) {
247
309
  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);
310
+ throw ( (new FileOperationError(localizeWithPath(
311
+ _moduleId,
312
+ 4,
313
+ "Unable to create file '{0}' that already exists when overwrite flag is not set",
314
+ this.resourceForError(resource)
315
+ ), 3 , options)));
249
316
  }
250
317
  }
251
318
  async createFile(resource, bufferOrReadableOrStream = VSBuffer.fromString(''), options) {
252
319
  await this.doValidateCreateFile(resource, options);
253
320
  const fileStat = await this.writeFile(resource, bufferOrReadableOrStream);
254
- this._onDidRunOperation.fire(( new FileOperationEvent(resource, 0 , fileStat)));
321
+ this._onDidRunOperation.fire(( (new FileOperationEvent(resource, 0 , fileStat))));
255
322
  return fileStat;
256
323
  }
257
324
  async writeFile(resource, bufferOrReadableOrStream, options) {
@@ -296,28 +363,54 @@ let FileService = class FileService extends Disposable {
296
363
  else {
297
364
  await this.doWriteBuffered(provider, resource, writeFileOptions, bufferOrReadableOrStreamOrBufferedStream instanceof VSBuffer ? bufferToReadable(bufferOrReadableOrStreamOrBufferedStream) : bufferOrReadableOrStreamOrBufferedStream);
298
365
  }
299
- this._onDidRunOperation.fire(( new FileOperationEvent(resource, 4 )));
366
+ this._onDidRunOperation.fire(( (new FileOperationEvent(resource, 4 ))));
300
367
  }
301
368
  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);
369
+ throw ( (new FileOperationError(localizeWithPath(
370
+ _moduleId,
371
+ 5,
372
+ "Unable to write file '{0}' ({1})",
373
+ this.resourceForError(resource),
374
+ ( (ensureFileSystemProviderError(error).toString()))
375
+ ), toFileOperationResult(error), writeFileOptions)));
303
376
  }
304
377
  return this.resolve(resource, { resolveMetadata: true });
305
378
  }
306
379
  async validateWriteFile(provider, resource, options) {
307
380
  const unlock = !!options?.unlock;
308
381
  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)));
382
+ throw ( (new Error(localizeWithPath(
383
+ _moduleId,
384
+ 6,
385
+ "Unable to unlock file '{0}' because provider does not support it.",
386
+ this.resourceForError(resource)
387
+ ))));
310
388
  }
311
389
  const atomic = !!options?.atomic;
312
390
  if (atomic) {
313
391
  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)));
392
+ throw ( (new Error(localizeWithPath(
393
+ _moduleId,
394
+ 7,
395
+ "Unable to atomically write file '{0}' because provider does not support it.",
396
+ this.resourceForError(resource)
397
+ ))));
315
398
  }
316
399
  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)));
400
+ throw ( (new Error(localizeWithPath(
401
+ _moduleId,
402
+ 8,
403
+ "Unable to atomically write file '{0}' because provider does not support unbuffered writes.",
404
+ this.resourceForError(resource)
405
+ ))));
318
406
  }
319
407
  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)));
408
+ throw ( (new Error(localizeWithPath(
409
+ _moduleId,
410
+ 9,
411
+ "Unable to unlock file '{0}' because atomic write is enabled.",
412
+ this.resourceForError(resource)
413
+ ))));
321
414
  }
322
415
  }
323
416
  let stat = undefined;
@@ -328,13 +421,22 @@ let FileService = class FileService extends Disposable {
328
421
  return undefined;
329
422
  }
330
423
  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);
424
+ throw ( (new FileOperationError(localizeWithPath(
425
+ _moduleId,
426
+ 10,
427
+ "Unable to write file '{0}' that is actually a directory",
428
+ this.resourceForError(resource)
429
+ ), 0 , options)));
332
430
  }
333
431
  this.throwIfFileIsReadonly(resource, stat);
334
432
  if (typeof options?.mtime === 'number' && typeof options.etag === 'string' && options.etag !== ETAG_DISABLED &&
335
433
  typeof stat.mtime === 'number' && typeof stat.size === 'number' &&
336
434
  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);
435
+ throw ( (new FileOperationError(
436
+ localizeWithPath(_moduleId, 11, "File Modified Since"),
437
+ 3 ,
438
+ options
439
+ )));
338
440
  }
339
441
  return stat;
340
442
  }
@@ -346,17 +448,19 @@ let FileService = class FileService extends Disposable {
346
448
  return this.doReadFile(provider, resource, options, token);
347
449
  }
348
450
  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
- }));
451
+ return (
452
+ (new Promise((resolve, reject) => {
453
+ this.writeQueue.queueFor(resource, async () => {
454
+ try {
455
+ const content = await this.doReadFile(provider, resource, options, token);
456
+ resolve(content);
457
+ }
458
+ catch (error) {
459
+ reject(error);
460
+ }
461
+ }, this.getExtUri(provider).providerExtUri);
462
+ }))
463
+ );
360
464
  }
361
465
  async doReadFile(provider, resource, options, token) {
362
466
  const stream = await this.doReadFileStream(provider, resource, {
@@ -373,7 +477,7 @@ let FileService = class FileService extends Disposable {
373
477
  return this.doReadFileStream(provider, resource, options, token);
374
478
  }
375
479
  async doReadFileStream(provider, resource, options, token) {
376
- const cancellableSource = ( new CancellationTokenSource(token));
480
+ const cancellableSource = ( (new CancellationTokenSource(token)));
377
481
  let readFileOptions = options;
378
482
  if (hasFileAtomicReadCapability(provider) && provider.enforceAtomicReadFile?.(resource)) {
379
483
  readFileOptions = { ...options, atomic: true };
@@ -416,19 +520,25 @@ let FileService = class FileService extends Disposable {
416
520
  }
417
521
  restoreReadError(error, resource, options) {
418
522
  const message = ( localizeWithPath(
419
- 'vs/platform/files/common/fileService',
420
- 'err.read',
523
+ _moduleId,
524
+ 12,
421
525
  "Unable to read file '{0}' ({1})",
422
526
  this.resourceForError(resource),
423
- ( ensureFileSystemProviderError(error).toString())
527
+ (ensureFileSystemProviderError(error).toString())
424
528
  ));
425
529
  if (error instanceof NotModifiedSinceFileOperationError) {
426
- return ( new NotModifiedSinceFileOperationError(message, error.stat, options));
530
+ return (
531
+ (new NotModifiedSinceFileOperationError(message, error.stat, options))
532
+ );
427
533
  }
428
534
  if (error instanceof TooLargeFileOperationError) {
429
- return ( new TooLargeFileOperationError(message, error.fileOperationResult, error.size, error.options));
535
+ return (
536
+ (new TooLargeFileOperationError(message, error.fileOperationResult, error.size, error.options))
537
+ );
430
538
  }
431
- return ( new FileOperationError(message, toFileOperationResult(error), options));
539
+ return (
540
+ (new FileOperationError(message, toFileOperationResult(error), options))
541
+ );
432
542
  }
433
543
  readFileStreamed(provider, resource, token, options = Object.create(null)) {
434
544
  const fileStream = provider.readFileStream(resource, options, token);
@@ -476,17 +586,27 @@ let FileService = class FileService extends Disposable {
476
586
  async validateReadFile(resource, options) {
477
587
  const stat = await this.resolve(resource, { resolveMetadata: true });
478
588
  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);
589
+ throw ( (new FileOperationError(localizeWithPath(
590
+ _moduleId,
591
+ 13,
592
+ "Unable to read file '{0}' that is actually a directory",
593
+ this.resourceForError(resource)
594
+ ), 0 , options)));
480
595
  }
481
596
  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);
597
+ throw ( (new NotModifiedSinceFileOperationError(localizeWithPath(_moduleId, 14, "File not modified since"), stat, options)));
483
598
  }
484
599
  this.validateReadFileLimits(resource, stat.size, options);
485
600
  return stat;
486
601
  }
487
602
  validateReadFileLimits(resource, size, options) {
488
603
  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);
604
+ throw ( (new TooLargeFileOperationError(localizeWithPath(
605
+ _moduleId,
606
+ 15,
607
+ "Unable to read file '{0}' that is too large to open",
608
+ this.resourceForError(resource)
609
+ ), 7 , size, options)));
490
610
  }
491
611
  }
492
612
  async canMove(source, target, overwrite) {
@@ -496,7 +616,7 @@ let FileService = class FileService extends Disposable {
496
616
  return this.doCanMoveCopy(source, target, 'copy', overwrite);
497
617
  }
498
618
  async doCanMoveCopy(source, target, mode, overwrite) {
499
- if (( source.toString()) !== ( target.toString())) {
619
+ if (( (source.toString())) !== ( (target.toString()))) {
500
620
  try {
501
621
  const sourceProvider = mode === 'move' ? this.throwIfFileSystemIsReadonly(await this.withWriteProvider(source), source) : await this.withReadProvider(source);
502
622
  const targetProvider = this.throwIfFileSystemIsReadonly(await this.withWriteProvider(target), target);
@@ -513,11 +633,11 @@ let FileService = class FileService extends Disposable {
513
633
  const targetProvider = this.throwIfFileSystemIsReadonly(await this.withWriteProvider(target), target);
514
634
  const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'move', !!overwrite);
515
635
  const fileStat = await this.resolve(target, { resolveMetadata: true });
516
- this._onDidRunOperation.fire(( new FileOperationEvent(
636
+ this._onDidRunOperation.fire(( (new FileOperationEvent(
517
637
  source,
518
638
  mode === 'move' ? 2 : 3 ,
519
639
  fileStat
520
- )));
640
+ ))));
521
641
  return fileStat;
522
642
  }
523
643
  async copy(source, target, overwrite) {
@@ -525,15 +645,15 @@ let FileService = class FileService extends Disposable {
525
645
  const targetProvider = this.throwIfFileSystemIsReadonly(await this.withWriteProvider(target), target);
526
646
  const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'copy', !!overwrite);
527
647
  const fileStat = await this.resolve(target, { resolveMetadata: true });
528
- this._onDidRunOperation.fire(( new FileOperationEvent(
648
+ this._onDidRunOperation.fire(( (new FileOperationEvent(
529
649
  source,
530
650
  mode === 'copy' ? 3 : 2 ,
531
651
  fileStat
532
- )));
652
+ ))));
533
653
  return fileStat;
534
654
  }
535
655
  async doMoveCopy(sourceProvider, source, targetProvider, target, mode, overwrite) {
536
- if (( source.toString()) === ( target.toString())) {
656
+ if (( (source.toString())) === ( (target.toString()))) {
537
657
  return mode;
538
658
  }
539
659
  const { exists, isSameResourceWithDifferentPathCase } = await this.doValidateMoveCopy(sourceProvider, source, targetProvider, target, mode, overwrite);
@@ -585,7 +705,7 @@ let FileService = class FileService extends Disposable {
585
705
  async doCopyFolder(sourceProvider, sourceFolder, targetProvider, targetFolder) {
586
706
  await targetProvider.mkdir(targetFolder);
587
707
  if (Array.isArray(sourceFolder.children)) {
588
- await Promises.settled(( sourceFolder.children.map(async (sourceChild) => {
708
+ await Promises.settled(( (sourceFolder.children.map(async (sourceChild) => {
589
709
  const targetChild = this.getExtUri(targetProvider).providerExtUri.joinPath(targetFolder, sourceChild.name);
590
710
  if (sourceChild.isDirectory) {
591
711
  return this.doCopyFolder(sourceProvider, await this.resolve(sourceChild.resource), targetProvider, targetChild);
@@ -593,7 +713,7 @@ let FileService = class FileService extends Disposable {
593
713
  else {
594
714
  return this.doCopyFile(sourceProvider, sourceChild.resource, targetProvider, targetChild);
595
715
  }
596
- })));
716
+ }))));
597
717
  }
598
718
  }
599
719
  async doValidateMoveCopy(sourceProvider, source, targetProvider, target, mode, overwrite) {
@@ -604,21 +724,45 @@ let FileService = class FileService extends Disposable {
604
724
  isSameResourceWithDifferentPathCase = providerExtUri.isEqual(source, target);
605
725
  }
606
726
  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)));
727
+ throw ( (new Error(localizeWithPath(
728
+ _moduleId,
729
+ 16,
730
+ "Unable to copy when source '{0}' is same as target '{1}' with different path case on a case insensitive file system",
731
+ this.resourceForError(source),
732
+ this.resourceForError(target)
733
+ ))));
608
734
  }
609
735
  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)));
736
+ throw ( (new Error(localizeWithPath(
737
+ _moduleId,
738
+ 17,
739
+ "Unable to move/copy when source '{0}' is parent of target '{1}'.",
740
+ this.resourceForError(source),
741
+ this.resourceForError(target)
742
+ ))));
611
743
  }
612
744
  }
613
745
  const exists = await this.exists(target);
614
746
  if (exists && !isSameResourceWithDifferentPathCase) {
615
747
  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 );
748
+ throw ( (new FileOperationError(localizeWithPath(
749
+ _moduleId,
750
+ 18,
751
+ "Unable to move/copy '{0}' because target '{1}' already exists at destination.",
752
+ this.resourceForError(source),
753
+ this.resourceForError(target)
754
+ ), 4 )));
617
755
  }
618
756
  if (sourceProvider === targetProvider) {
619
757
  const { providerExtUri } = this.getExtUri(sourceProvider);
620
758
  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)));
759
+ throw ( (new Error(localizeWithPath(
760
+ _moduleId,
761
+ 19,
762
+ "Unable to move/copy '{0}' into '{1}' since a file would replace the folder it is contained in.",
763
+ this.resourceForError(source),
764
+ this.resourceForError(target)
765
+ ))));
622
766
  }
623
767
  }
624
768
  }
@@ -638,39 +782,12 @@ let FileService = class FileService extends Disposable {
638
782
  const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource), resource);
639
783
  await this.mkdirp(provider, resource);
640
784
  const fileStat = await this.resolve(resource, { resolveMetadata: true });
641
- this._onDidRunOperation.fire(( new FileOperationEvent(resource, 0 , fileStat)));
785
+ this._onDidRunOperation.fire(( (new FileOperationEvent(resource, 0 , fileStat))));
642
786
  return fileStat;
643
787
  }
644
788
  async mkdirp(provider, directory) {
645
- const directoriesToCreate = [];
646
789
  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
- }
790
+ return mkdirp(providerExtUri, provider, directory);
674
791
  }
675
792
  async canDelete(resource, options) {
676
793
  try {
@@ -685,14 +802,29 @@ let FileService = class FileService extends Disposable {
685
802
  const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource), resource);
686
803
  const useTrash = !!options?.useTrash;
687
804
  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)));
805
+ throw ( (new Error(localizeWithPath(
806
+ _moduleId,
807
+ 20,
808
+ "Unable to delete file '{0}' via trash because provider does not support it.",
809
+ this.resourceForError(resource)
810
+ ))));
689
811
  }
690
812
  const atomic = options?.atomic;
691
813
  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)));
814
+ throw ( (new Error(localizeWithPath(
815
+ _moduleId,
816
+ 21,
817
+ "Unable to delete file '{0}' atomically because provider does not support it.",
818
+ this.resourceForError(resource)
819
+ ))));
693
820
  }
694
821
  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)));
822
+ throw ( (new Error(localizeWithPath(
823
+ _moduleId,
824
+ 22,
825
+ "Unable to atomically delete file '{0}' because using trash is enabled.",
826
+ this.resourceForError(resource)
827
+ ))));
696
828
  }
697
829
  let stat = undefined;
698
830
  try {
@@ -704,13 +836,23 @@ let FileService = class FileService extends Disposable {
704
836
  this.throwIfFileIsReadonly(resource, stat);
705
837
  }
706
838
  else {
707
- throw new FileOperationError(localizeWithPath('vs/platform/files/common/fileService', 'deleteFailedNotFound', "Unable to delete nonexistent file '{0}'", this.resourceForError(resource)), 1 );
839
+ throw ( (new FileOperationError(localizeWithPath(
840
+ _moduleId,
841
+ 23,
842
+ "Unable to delete nonexistent file '{0}'",
843
+ this.resourceForError(resource)
844
+ ), 1 )));
708
845
  }
709
846
  const recursive = !!options?.recursive;
710
847
  if (!recursive) {
711
848
  const stat = await this.resolve(resource);
712
849
  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)));
850
+ throw ( (new Error(localizeWithPath(
851
+ _moduleId,
852
+ 24,
853
+ "Unable to delete non-empty folder '{0}'.",
854
+ this.resourceForError(resource)
855
+ ))));
714
856
  }
715
857
  }
716
858
  return provider;
@@ -728,7 +870,7 @@ let FileService = class FileService extends Disposable {
728
870
  const recursive = !!deleteFileOptions?.recursive;
729
871
  const atomic = deleteFileOptions?.atomic ?? false;
730
872
  await provider.delete(resource, { recursive, useTrash, atomic });
731
- this._onDidRunOperation.fire(( new FileOperationEvent(resource, 1 )));
873
+ this._onDidRunOperation.fire(( (new FileOperationEvent(resource, 1 ))));
732
874
  }
733
875
  async cloneFile(source, target) {
734
876
  const sourceProvider = await this.withProvider(source);
@@ -753,7 +895,7 @@ let FileService = class FileService extends Disposable {
753
895
  });
754
896
  }
755
897
  watch(resource, options = { recursive: false, excludes: [] }) {
756
- const disposables = ( new DisposableStore());
898
+ const disposables = ( (new DisposableStore()));
757
899
  let watchDisposed = false;
758
900
  let disposeWatch = () => { watchDisposed = true; };
759
901
  disposables.add(toDisposable(() => disposeWatch()));
@@ -773,7 +915,7 @@ let FileService = class FileService extends Disposable {
773
915
  })();
774
916
  const correlationId = options.correlationId;
775
917
  if (typeof correlationId === 'number') {
776
- const fileChangeEmitter = disposables.add(( new Emitter()));
918
+ const fileChangeEmitter = disposables.add(( (new Emitter())));
777
919
  disposables.add(this.internalOnDidFilesChange.event(e => {
778
920
  if (e.correlates(correlationId)) {
779
921
  fileChangeEmitter.fire(e);
@@ -852,23 +994,25 @@ let FileService = class FileService extends Disposable {
852
994
  else {
853
995
  stream = streamOrBufferedStream;
854
996
  }
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
- }));
997
+ return (
998
+ (new Promise((resolve, reject) => {
999
+ listenStream(stream, {
1000
+ onData: async (chunk) => {
1001
+ stream.pause();
1002
+ try {
1003
+ await this.doWriteBuffer(provider, handle, chunk, chunk.byteLength, posInFile, 0);
1004
+ }
1005
+ catch (error) {
1006
+ return reject(error);
1007
+ }
1008
+ posInFile += chunk.byteLength;
1009
+ setTimeout(() => stream.resume());
1010
+ },
1011
+ onError: error => reject(error),
1012
+ onEnd: () => resolve()
1013
+ });
1014
+ }))
1015
+ );
872
1016
  }
873
1017
  async doWriteReadableBufferedQueued(provider, handle, readable) {
874
1018
  let posInFile = 0;
@@ -965,24 +1109,31 @@ let FileService = class FileService extends Disposable {
965
1109
  }
966
1110
  throwIfFileSystemIsReadonly(provider, resource) {
967
1111
  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 );
1112
+ throw ( (new FileOperationError(localizeWithPath(
1113
+ _moduleId,
1114
+ 25,
1115
+ "Unable to modify read-only file '{0}'",
1116
+ this.resourceForError(resource)
1117
+ ), 6 )));
969
1118
  }
970
1119
  return provider;
971
1120
  }
972
1121
  throwIfFileIsReadonly(resource, stat) {
973
1122
  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 );
1123
+ throw ( (new FileOperationError(localizeWithPath(
1124
+ _moduleId,
1125
+ 25,
1126
+ "Unable to modify read-only file '{0}'",
1127
+ this.resourceForError(resource)
1128
+ ), 6 )));
975
1129
  }
976
1130
  }
977
1131
  resourceForError(resource) {
978
- if (resource.scheme === Schemas.file) {
979
- return resource.fsPath;
980
- }
981
- return ( resource.toString(true));
1132
+ return resourceForError(resource);
982
1133
  }
983
1134
  };
984
- FileService = FileService_1 = ( __decorate([
985
- ( __param(0, ILogService))
986
- ], FileService));
1135
+ FileService = FileService_1 = ( (__decorate([
1136
+ ( (__param(0, ILogService)))
1137
+ ], FileService)));
987
1138
 
988
- export { FileService };
1139
+ export { FileService, mkdirp };