@theia/filesystem 1.48.0 → 1.48.1
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.
- package/README.md +30 -30
- package/lib/browser/breadcrumbs/filepath-breadcrumb.d.ts +15 -15
- package/lib/browser/breadcrumbs/filepath-breadcrumb.js +41 -41
- package/lib/browser/breadcrumbs/filepath-breadcrumbs-container.d.ts +13 -13
- package/lib/browser/breadcrumbs/filepath-breadcrumbs-container.js +70 -70
- package/lib/browser/breadcrumbs/filepath-breadcrumbs-contribution.d.ts +27 -27
- package/lib/browser/breadcrumbs/filepath-breadcrumbs-contribution.js +118 -118
- package/lib/browser/download/file-download-command-contribution.d.ts +18 -18
- package/lib/browser/download/file-download-command-contribution.js +75 -75
- package/lib/browser/download/file-download-frontend-module.d.ts +3 -3
- package/lib/browser/download/file-download-frontend-module.js +25 -25
- package/lib/browser/download/file-download-service.d.ts +28 -28
- package/lib/browser/download/file-download-service.js +167 -167
- package/lib/browser/file-dialog/file-dialog-container.d.ts +5 -5
- package/lib/browser/file-dialog/file-dialog-container.js +60 -60
- package/lib/browser/file-dialog/file-dialog-hidden-files-renderer.d.ts +15 -15
- package/lib/browser/file-dialog/file-dialog-hidden-files-renderer.js +59 -59
- package/lib/browser/file-dialog/file-dialog-model.d.ts +25 -25
- package/lib/browser/file-dialog/file-dialog-model.js +100 -100
- package/lib/browser/file-dialog/file-dialog-module.d.ts +3 -3
- package/lib/browser/file-dialog/file-dialog-module.js +45 -45
- package/lib/browser/file-dialog/file-dialog-service.d.ts +32 -32
- package/lib/browser/file-dialog/file-dialog-service.js +101 -101
- package/lib/browser/file-dialog/file-dialog-tree-filters-renderer.d.ts +39 -39
- package/lib/browser/file-dialog/file-dialog-tree-filters-renderer.js +81 -81
- package/lib/browser/file-dialog/file-dialog-tree.d.ts +26 -26
- package/lib/browser/file-dialog/file-dialog-tree.js +83 -83
- package/lib/browser/file-dialog/file-dialog-widget.d.ts +15 -15
- package/lib/browser/file-dialog/file-dialog-widget.js +75 -75
- package/lib/browser/file-dialog/file-dialog.d.ts +129 -129
- package/lib/browser/file-dialog/file-dialog.js +351 -351
- package/lib/browser/file-dialog/index.d.ts +4 -4
- package/lib/browser/file-dialog/index.js +22 -22
- package/lib/browser/file-resource.d.ts +67 -67
- package/lib/browser/file-resource.js +369 -369
- package/lib/browser/file-selection.d.ts +14 -14
- package/lib/browser/file-selection.js +36 -36
- package/lib/browser/file-service.d.ts +425 -425
- package/lib/browser/file-service.js +1366 -1366
- package/lib/browser/file-tree/file-tree-container.d.ts +3 -3
- package/lib/browser/file-tree/file-tree-container.js +35 -35
- package/lib/browser/file-tree/file-tree-decorator-adapter.d.ts +30 -30
- package/lib/browser/file-tree/file-tree-decorator-adapter.js +169 -169
- package/lib/browser/file-tree/file-tree-label-provider.d.ts +12 -12
- package/lib/browser/file-tree/file-tree-label-provider.js +54 -54
- package/lib/browser/file-tree/file-tree-model.d.ts +37 -37
- package/lib/browser/file-tree/file-tree-model.js +217 -217
- package/lib/browser/file-tree/file-tree-widget.d.ts +44 -44
- package/lib/browser/file-tree/file-tree-widget.js +317 -317
- package/lib/browser/file-tree/file-tree.d.ts +46 -46
- package/lib/browser/file-tree/file-tree.js +176 -176
- package/lib/browser/file-tree/index.d.ts +6 -6
- package/lib/browser/file-tree/index.js +24 -24
- package/lib/browser/file-upload-service.d.ts +109 -109
- package/lib/browser/file-upload-service.js +434 -434
- package/lib/browser/filesystem-frontend-contribution.d.ts +74 -74
- package/lib/browser/filesystem-frontend-contribution.js +356 -356
- package/lib/browser/filesystem-frontend-module.d.ts +5 -5
- package/lib/browser/filesystem-frontend-module.js +64 -64
- package/lib/browser/filesystem-preferences.d.ts +29 -29
- package/lib/browser/filesystem-preferences.js +110 -110
- package/lib/browser/filesystem-save-resource-service.d.ts +29 -29
- package/lib/browser/filesystem-save-resource-service.js +135 -135
- package/lib/browser/filesystem-watcher-error-handler.d.ts +10 -10
- package/lib/browser/filesystem-watcher-error-handler.js +61 -61
- package/lib/browser/index.d.ts +5 -5
- package/lib/browser/index.js +23 -23
- package/lib/browser/location/index.d.ts +2 -2
- package/lib/browser/location/index.js +20 -20
- package/lib/browser/location/location-renderer.d.ts +100 -100
- package/lib/browser/location/location-renderer.js +343 -343
- package/lib/browser/location/location-service.d.ts +5 -5
- package/lib/browser/location/location-service.js +17 -17
- package/lib/browser/remote-file-service-contribution.d.ts +6 -6
- package/lib/browser/remote-file-service-contribution.js +39 -39
- package/lib/browser-only/browser-only-filesystem-frontend-module.d.ts +3 -3
- package/lib/browser-only/browser-only-filesystem-frontend-module.js +40 -40
- package/lib/browser-only/browser-only-filesystem-provider-server.d.ts +11 -11
- package/lib/browser-only/browser-only-filesystem-provider-server.js +39 -39
- package/lib/browser-only/browserfs-filesystem-initialization.d.ts +12 -12
- package/lib/browser-only/browserfs-filesystem-initialization.js +54 -54
- package/lib/browser-only/browserfs-filesystem-provider.d.ts +45 -45
- package/lib/browser-only/browserfs-filesystem-provider.js +439 -439
- package/lib/common/delegating-file-system-provider.d.ts +76 -76
- package/lib/common/delegating-file-system-provider.js +168 -168
- package/lib/common/download/file-download-data.d.ts +6 -6
- package/lib/common/download/file-download-data.js +26 -26
- package/lib/common/file-upload.d.ts +1 -1
- package/lib/common/file-upload.js +19 -19
- package/lib/common/files.d.ts +659 -659
- package/lib/common/files.js +355 -355
- package/lib/common/files.spec.d.ts +1 -1
- package/lib/common/files.spec.js +51 -51
- package/lib/common/filesystem-utils.d.ts +14 -14
- package/lib/common/filesystem-utils.js +63 -63
- package/lib/common/filesystem-utils.spec.d.ts +1 -1
- package/lib/common/filesystem-utils.spec.js +378 -378
- package/lib/common/filesystem-watcher-protocol.d.ts +71 -71
- package/lib/common/filesystem-watcher-protocol.js +20 -20
- package/lib/common/filesystem.d.ts +22 -22
- package/lib/common/filesystem.js +42 -42
- package/lib/common/index.d.ts +2 -2
- package/lib/common/index.js +20 -20
- package/lib/common/io.d.ts +19 -19
- package/lib/common/io.js +110 -110
- package/lib/common/remote-file-system-provider.d.ts +173 -173
- package/lib/common/remote-file-system-provider.js +435 -435
- package/lib/electron-browser/file-dialog/electron-file-dialog-module.d.ts +3 -3
- package/lib/electron-browser/file-dialog/electron-file-dialog-module.js +24 -24
- package/lib/electron-browser/file-dialog/electron-file-dialog-service.d.ts +19 -19
- package/lib/electron-browser/file-dialog/electron-file-dialog-service.js +148 -148
- package/lib/electron-browser/preload.d.ts +1 -1
- package/lib/electron-browser/preload.js +30 -30
- package/lib/electron-common/electron-api.d.ts +34 -34
- package/lib/electron-common/electron-api.js +20 -20
- package/lib/electron-main/electron-api-main.d.ts +5 -5
- package/lib/electron-main/electron-api-main.js +73 -73
- package/lib/electron-main/electron-main-module.d.ts +3 -3
- package/lib/electron-main/electron-main-module.js +24 -24
- package/lib/node/disk-file-system-provider.d.ts +72 -72
- package/lib/node/disk-file-system-provider.js +787 -787
- package/lib/node/disk-file-system-provider.spec.d.ts +1 -1
- package/lib/node/disk-file-system-provider.spec.js +122 -122
- package/lib/node/download/directory-archiver.d.ts +9 -9
- package/lib/node/download/directory-archiver.js +127 -127
- package/lib/node/download/directory-archiver.spec.d.ts +1 -1
- package/lib/node/download/directory-archiver.spec.js +97 -97
- package/lib/node/download/file-download-backend-module.d.ts +3 -3
- package/lib/node/download/file-download-backend-module.js +32 -32
- package/lib/node/download/file-download-cache.d.ts +21 -21
- package/lib/node/download/file-download-cache.js +82 -82
- package/lib/node/download/file-download-endpoint.d.ts +11 -11
- package/lib/node/download/file-download-endpoint.js +67 -67
- package/lib/node/download/file-download-handler.d.ts +50 -50
- package/lib/node/download/file-download-handler.js +307 -307
- package/lib/node/download/test/mock-directory-archiver.d.ts +7 -7
- package/lib/node/download/test/mock-directory-archiver.js +29 -29
- package/lib/node/file-change-collection.d.ts +22 -22
- package/lib/node/file-change-collection.js +77 -77
- package/lib/node/file-change-collection.spec.d.ts +1 -1
- package/lib/node/file-change-collection.spec.js +90 -90
- package/lib/node/filesystem-backend-module.d.ts +26 -26
- package/lib/node/filesystem-backend-module.js +120 -120
- package/lib/node/filesystem-watcher-client.d.ts +23 -23
- package/lib/node/filesystem-watcher-client.js +75 -75
- package/lib/node/filesystem-watcher-dispatcher.d.ts +23 -23
- package/lib/node/filesystem-watcher-dispatcher.js +80 -80
- package/lib/node/node-file-upload-service.d.ts +16 -16
- package/lib/node/node-file-upload-service.js +79 -79
- package/lib/node/nsfw-watcher/index.d.ts +3 -3
- package/lib/node/nsfw-watcher/index.js +39 -39
- package/lib/node/nsfw-watcher/nsfw-filesystem-service.d.ts +191 -191
- package/lib/node/nsfw-watcher/nsfw-filesystem-service.js +405 -405
- package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.spec.d.ts +1 -1
- package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.spec.js +151 -151
- package/lib/node/nsfw-watcher/nsfw-options.d.ts +6 -6
- package/lib/node/nsfw-watcher/nsfw-options.js +22 -22
- package/package.json +4 -4
- package/src/browser/breadcrumbs/filepath-breadcrumb.ts +43 -43
- package/src/browser/breadcrumbs/filepath-breadcrumbs-container.ts +65 -65
- package/src/browser/breadcrumbs/filepath-breadcrumbs-contribution.ts +129 -129
- package/src/browser/download/file-download-command-contribution.ts +83 -83
- package/src/browser/download/file-download-frontend-module.ts +25 -25
- package/src/browser/download/file-download-service.ts +179 -179
- package/src/browser/file-dialog/file-dialog-container.ts +67 -67
- package/src/browser/file-dialog/file-dialog-hidden-files-renderer.tsx +59 -59
- package/src/browser/file-dialog/file-dialog-model.ts +96 -96
- package/src/browser/file-dialog/file-dialog-module.ts +44 -44
- package/src/browser/file-dialog/file-dialog-service.ts +99 -99
- package/src/browser/file-dialog/file-dialog-tree-filters-renderer.tsx +100 -100
- package/src/browser/file-dialog/file-dialog-tree.ts +89 -89
- package/src/browser/file-dialog/file-dialog-widget.ts +75 -75
- package/src/browser/file-dialog/file-dialog.ts +434 -434
- package/src/browser/file-dialog/index.ts +20 -20
- package/src/browser/file-resource.ts +390 -390
- package/src/browser/file-selection.ts +44 -44
- package/src/browser/file-service.ts +1841 -1841
- package/src/browser/file-tree/file-tree-container.ts +36 -36
- package/src/browser/file-tree/file-tree-decorator-adapter.ts +159 -159
- package/src/browser/file-tree/file-tree-label-provider.ts +53 -53
- package/src/browser/file-tree/file-tree-model.ts +212 -212
- package/src/browser/file-tree/file-tree-widget.tsx +327 -327
- package/src/browser/file-tree/file-tree.ts +183 -183
- package/src/browser/file-tree/index.ts +22 -22
- package/src/browser/file-upload-service.ts +539 -539
- package/src/browser/filesystem-frontend-contribution.ts +381 -381
- package/src/browser/filesystem-frontend-module.ts +77 -77
- package/src/browser/filesystem-preferences.ts +139 -139
- package/src/browser/filesystem-save-resource-service.ts +125 -125
- package/src/browser/filesystem-watcher-error-handler.ts +60 -60
- package/src/browser/index.ts +21 -21
- package/src/browser/location/index.ts +18 -18
- package/src/browser/location/location-renderer.tsx +404 -404
- package/src/browser/location/location-service.ts +22 -22
- package/src/browser/remote-file-service-contribution.ts +38 -38
- package/src/browser/style/file-dialog.css +208 -208
- package/src/browser/style/file-icons.css +64 -64
- package/src/browser/style/filepath-breadcrumbs.css +20 -20
- package/src/browser/style/index.css +36 -36
- package/src/browser-only/browser-only-filesystem-frontend-module.ts +38 -38
- package/src/browser-only/browser-only-filesystem-provider-server.ts +32 -32
- package/src/browser-only/browserfs-filesystem-initialization.ts +61 -61
- package/src/browser-only/browserfs-filesystem-provider.ts +462 -462
- package/src/common/delegating-file-system-provider.ts +226 -226
- package/src/common/download/README.md +30 -30
- package/src/common/download/file-download-data.ts +27 -27
- package/src/common/file-upload.ts +17 -17
- package/src/common/files.spec.ts +51 -51
- package/src/common/files.ts +996 -996
- package/src/common/filesystem-utils.spec.ts +411 -411
- package/src/common/filesystem-utils.ts +64 -64
- package/src/common/filesystem-watcher-protocol.ts +96 -96
- package/src/common/filesystem.ts +43 -43
- package/src/common/index.ts +18 -18
- package/src/common/io.ts +150 -150
- package/src/common/remote-file-system-provider.ts +549 -549
- package/src/electron-browser/file-dialog/electron-file-dialog-module.ts +24 -24
- package/src/electron-browser/file-dialog/electron-file-dialog-service.ts +165 -165
- package/src/electron-browser/preload.ts +31 -31
- package/src/electron-common/electron-api.ts +55 -55
- package/src/electron-main/electron-api-main.ts +78 -78
- package/src/electron-main/electron-main-module.ts +23 -23
- package/src/node/disk-file-system-provider.spec.ts +142 -142
- package/src/node/disk-file-system-provider.ts +915 -915
- package/src/node/download/directory-archiver.spec.ts +104 -104
- package/src/node/download/directory-archiver.ts +126 -126
- package/src/node/download/file-download-backend-module.ts +32 -32
- package/src/node/download/file-download-cache.ts +88 -88
- package/src/node/download/file-download-endpoint.ts +63 -63
- package/src/node/download/file-download-handler.ts +304 -304
- package/src/node/download/test/mock-directory-archiver.ts +30 -30
- package/src/node/file-change-collection.spec.ts +110 -110
- package/src/node/file-change-collection.ts +78 -78
- package/src/node/filesystem-backend-module.ts +140 -140
- package/src/node/filesystem-watcher-client.ts +72 -72
- package/src/node/filesystem-watcher-dispatcher.ts +82 -82
- package/src/node/node-file-upload-service.ts +80 -80
- package/src/node/nsfw-watcher/index.ts +45 -45
- package/src/node/nsfw-watcher/nsfw-filesystem-service.ts +481 -481
- package/src/node/nsfw-watcher/nsfw-filesystem-watcher.spec.ts +182 -182
- package/src/node/nsfw-watcher/nsfw-options.ts +23 -23
- package/src/typings/dom.webkit.d.ts +77 -77
- package/src/typings/mv/index.d.ts +21 -21
- package/src/typings/nsfw/index.d.ts +18 -18
- package/src/typings/trash/index.d.ts +20 -20
package/lib/common/files.js
CHANGED
|
@@ -1,356 +1,356 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
/*---------------------------------------------------------------------------------------------
|
|
18
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
20
|
-
*--------------------------------------------------------------------------------------------*/
|
|
21
|
-
// based on https://github.com/microsoft/vscode/blob/04c36be045a94fee58e5f8992d3e3fd980294a84/src/vs/platform/files/common/files.ts
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.BinarySize = exports.etag = exports.ETAG_DISABLED = exports.toFileOperationResult = exports.toFileSystemProviderErrorCode = exports.markAsFileSystemProviderError = exports.hasFileReadStreamCapability = exports.hasOpenReadWriteCloseCapability = exports.hasFileFolderCopyCapability = exports.hasReadWriteCapability = exports.ReadOnlyMessageFileSystemProvider = exports.hasUpdateCapability = exports.hasAccessCapability = exports.FileSystemProvider = exports.ensureFileSystemProviderError = exports.createFileSystemProviderError = exports.FileSystemProviderError = exports.FileSystemProviderErrorCode = exports.FilePermission = exports.FileType = exports.FileOperationError = exports.FileStat = exports.BaseStat = exports.FileChangesEvent = exports.FileOperationEvent = void 0;
|
|
24
|
-
const uri_1 = require("@theia/core/lib/common/uri");
|
|
25
|
-
const common_1 = require("@theia/core/lib/common");
|
|
26
|
-
class FileOperationEvent {
|
|
27
|
-
constructor(resource, operation, target) {
|
|
28
|
-
this.resource = resource;
|
|
29
|
-
this.operation = operation;
|
|
30
|
-
this.target = target;
|
|
31
|
-
}
|
|
32
|
-
isOperation(operation) {
|
|
33
|
-
return this.operation === operation;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.FileOperationEvent = FileOperationEvent;
|
|
37
|
-
class FileChangesEvent {
|
|
38
|
-
constructor(changes) {
|
|
39
|
-
this.changes = changes;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Returns true if this change event contains the provided file with the given change type (if provided). In case of
|
|
43
|
-
* type DELETED, this method will also return true if a folder got deleted that is the parent of the
|
|
44
|
-
* provided file path.
|
|
45
|
-
*/
|
|
46
|
-
contains(resource, type) {
|
|
47
|
-
if (!resource) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
const checkForChangeType = typeof type === 'number';
|
|
51
|
-
return this.changes.some(change => {
|
|
52
|
-
if (checkForChangeType && change.type !== type) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
// For deleted also return true when deleted folder is parent of target path
|
|
56
|
-
if (change.type === 2 /* DELETED */) {
|
|
57
|
-
return change.resource.isEqualOrParent(resource);
|
|
58
|
-
}
|
|
59
|
-
return change.resource.toString() === resource.toString();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns the changes that describe added files.
|
|
64
|
-
*/
|
|
65
|
-
getAdded() {
|
|
66
|
-
return this.getOfType(1 /* ADDED */);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Returns if this event contains added files.
|
|
70
|
-
*/
|
|
71
|
-
gotAdded() {
|
|
72
|
-
return this.hasType(1 /* ADDED */);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Returns the changes that describe deleted files.
|
|
76
|
-
*/
|
|
77
|
-
getDeleted() {
|
|
78
|
-
return this.getOfType(2 /* DELETED */);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Returns if this event contains deleted files.
|
|
82
|
-
*/
|
|
83
|
-
gotDeleted() {
|
|
84
|
-
return this.hasType(2 /* DELETED */);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Returns the changes that describe updated files.
|
|
88
|
-
*/
|
|
89
|
-
getUpdated() {
|
|
90
|
-
return this.getOfType(0 /* UPDATED */);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Returns if this event contains updated files.
|
|
94
|
-
*/
|
|
95
|
-
gotUpdated() {
|
|
96
|
-
return this.hasType(0 /* UPDATED */);
|
|
97
|
-
}
|
|
98
|
-
getOfType(type) {
|
|
99
|
-
return this.changes.filter(change => change.type === type);
|
|
100
|
-
}
|
|
101
|
-
hasType(type) {
|
|
102
|
-
return this.changes.some(change => change.type === type);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.FileChangesEvent = FileChangesEvent;
|
|
106
|
-
var BaseStat;
|
|
107
|
-
(function (BaseStat) {
|
|
108
|
-
function is(arg) {
|
|
109
|
-
return (0, common_1.isObject)(arg)
|
|
110
|
-
&& arg.resource instanceof uri_1.default
|
|
111
|
-
&& typeof arg.name === 'string';
|
|
112
|
-
}
|
|
113
|
-
BaseStat.is = is;
|
|
114
|
-
})(BaseStat = exports.BaseStat || (exports.BaseStat = {}));
|
|
115
|
-
var FileStat;
|
|
116
|
-
(function (FileStat) {
|
|
117
|
-
function is(arg) {
|
|
118
|
-
const fileStat = arg;
|
|
119
|
-
return BaseStat.is(fileStat) &&
|
|
120
|
-
('isFile' in fileStat && typeof fileStat.isFile === 'boolean') &&
|
|
121
|
-
('isDirectory' in fileStat && typeof fileStat.isDirectory === 'boolean') &&
|
|
122
|
-
('isSymbolicLink' in fileStat && typeof fileStat.isSymbolicLink === 'boolean');
|
|
123
|
-
}
|
|
124
|
-
FileStat.is = is;
|
|
125
|
-
function asFileType(stat) {
|
|
126
|
-
let res = 0;
|
|
127
|
-
if (stat.isFile) {
|
|
128
|
-
res += FileType.File;
|
|
129
|
-
}
|
|
130
|
-
else if (stat.isDirectory) {
|
|
131
|
-
res += FileType.Directory;
|
|
132
|
-
}
|
|
133
|
-
if (stat.isSymbolicLink) {
|
|
134
|
-
res += FileType.SymbolicLink;
|
|
135
|
-
}
|
|
136
|
-
return res;
|
|
137
|
-
}
|
|
138
|
-
FileStat.asFileType = asFileType;
|
|
139
|
-
function toStat(stat) {
|
|
140
|
-
return {
|
|
141
|
-
type: asFileType(stat),
|
|
142
|
-
ctime: stat.ctime,
|
|
143
|
-
mtime: stat.mtime,
|
|
144
|
-
size: stat.size
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
FileStat.toStat = toStat;
|
|
148
|
-
function fromStat(resource, stat) {
|
|
149
|
-
return {
|
|
150
|
-
resource,
|
|
151
|
-
name: resource.path.base || resource.path.toString(),
|
|
152
|
-
isFile: (stat.type & FileType.File) !== 0,
|
|
153
|
-
isDirectory: (stat.type & FileType.Directory) !== 0,
|
|
154
|
-
isSymbolicLink: (stat.type & FileType.SymbolicLink) !== 0,
|
|
155
|
-
isReadonly: !!stat.permissions && (stat.permissions & FilePermission.Readonly) !== 0,
|
|
156
|
-
mtime: stat.mtime,
|
|
157
|
-
ctime: stat.ctime,
|
|
158
|
-
size: stat.size,
|
|
159
|
-
etag: etag({ mtime: stat.mtime, size: stat.size })
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
FileStat.fromStat = fromStat;
|
|
163
|
-
function dir(resource, stat) {
|
|
164
|
-
return fromStat(resource instanceof uri_1.default ? resource : new uri_1.default(resource), { type: FileType.Directory, ...stat });
|
|
165
|
-
}
|
|
166
|
-
FileStat.dir = dir;
|
|
167
|
-
function file(resource, stat) {
|
|
168
|
-
return fromStat(resource instanceof uri_1.default ? resource : new uri_1.default(resource), { type: FileType.File, ...stat });
|
|
169
|
-
}
|
|
170
|
-
FileStat.file = file;
|
|
171
|
-
})(FileStat = exports.FileStat || (exports.FileStat = {}));
|
|
172
|
-
class FileOperationError extends Error {
|
|
173
|
-
constructor(message, fileOperationResult, options) {
|
|
174
|
-
super(message);
|
|
175
|
-
this.fileOperationResult = fileOperationResult;
|
|
176
|
-
this.options = options;
|
|
177
|
-
Object.setPrototypeOf(this, FileOperationError.prototype);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
exports.FileOperationError = FileOperationError;
|
|
181
|
-
var FileType;
|
|
182
|
-
(function (FileType) {
|
|
183
|
-
FileType[FileType["Unknown"] = 0] = "Unknown";
|
|
184
|
-
FileType[FileType["File"] = 1] = "File";
|
|
185
|
-
FileType[FileType["Directory"] = 2] = "Directory";
|
|
186
|
-
FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
|
|
187
|
-
})(FileType = exports.FileType || (exports.FileType = {}));
|
|
188
|
-
var FilePermission;
|
|
189
|
-
(function (FilePermission) {
|
|
190
|
-
/**
|
|
191
|
-
* File is readonly.
|
|
192
|
-
*/
|
|
193
|
-
FilePermission[FilePermission["Readonly"] = 1] = "Readonly";
|
|
194
|
-
})(FilePermission = exports.FilePermission || (exports.FilePermission = {}));
|
|
195
|
-
var FileSystemProviderErrorCode;
|
|
196
|
-
(function (FileSystemProviderErrorCode) {
|
|
197
|
-
FileSystemProviderErrorCode["FileExists"] = "EntryExists";
|
|
198
|
-
FileSystemProviderErrorCode["FileNotFound"] = "EntryNotFound";
|
|
199
|
-
FileSystemProviderErrorCode["FileNotADirectory"] = "EntryNotADirectory";
|
|
200
|
-
FileSystemProviderErrorCode["FileIsADirectory"] = "EntryIsADirectory";
|
|
201
|
-
FileSystemProviderErrorCode["FileExceedsMemoryLimit"] = "EntryExceedsMemoryLimit";
|
|
202
|
-
FileSystemProviderErrorCode["FileTooLarge"] = "EntryTooLarge";
|
|
203
|
-
FileSystemProviderErrorCode["NoPermissions"] = "NoPermissions";
|
|
204
|
-
FileSystemProviderErrorCode["Unavailable"] = "Unavailable";
|
|
205
|
-
FileSystemProviderErrorCode["Unknown"] = "Unknown";
|
|
206
|
-
})(FileSystemProviderErrorCode = exports.FileSystemProviderErrorCode || (exports.FileSystemProviderErrorCode = {}));
|
|
207
|
-
class FileSystemProviderError extends Error {
|
|
208
|
-
constructor(message, code) {
|
|
209
|
-
super(message);
|
|
210
|
-
this.code = code;
|
|
211
|
-
Object.setPrototypeOf(this, FileSystemProviderError.prototype);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
exports.FileSystemProviderError = FileSystemProviderError;
|
|
215
|
-
function createFileSystemProviderError(error, code) {
|
|
216
|
-
const providerError = new FileSystemProviderError(error.toString(), code);
|
|
217
|
-
markAsFileSystemProviderError(providerError, code);
|
|
218
|
-
return providerError;
|
|
219
|
-
}
|
|
220
|
-
exports.createFileSystemProviderError = createFileSystemProviderError;
|
|
221
|
-
function ensureFileSystemProviderError(error) {
|
|
222
|
-
if (!error) {
|
|
223
|
-
return createFileSystemProviderError('Unknown Error', FileSystemProviderErrorCode.Unknown); // https://github.com/Microsoft/vscode/issues/72798
|
|
224
|
-
}
|
|
225
|
-
return error;
|
|
226
|
-
}
|
|
227
|
-
exports.ensureFileSystemProviderError = ensureFileSystemProviderError;
|
|
228
|
-
exports.FileSystemProvider = Symbol('FileSystemProvider');
|
|
229
|
-
function hasAccessCapability(provider) {
|
|
230
|
-
return !!(provider.capabilities & 16777216 /* Access */);
|
|
231
|
-
}
|
|
232
|
-
exports.hasAccessCapability = hasAccessCapability;
|
|
233
|
-
function hasUpdateCapability(provider) {
|
|
234
|
-
return !!(provider.capabilities & 33554432 /* Update */);
|
|
235
|
-
}
|
|
236
|
-
exports.hasUpdateCapability = hasUpdateCapability;
|
|
237
|
-
var ReadOnlyMessageFileSystemProvider;
|
|
238
|
-
(function (ReadOnlyMessageFileSystemProvider) {
|
|
239
|
-
function is(arg) {
|
|
240
|
-
return (0, common_1.isObject)(arg)
|
|
241
|
-
&& 'readOnlyMessage' in arg;
|
|
242
|
-
}
|
|
243
|
-
ReadOnlyMessageFileSystemProvider.is = is;
|
|
244
|
-
})(ReadOnlyMessageFileSystemProvider = exports.ReadOnlyMessageFileSystemProvider || (exports.ReadOnlyMessageFileSystemProvider = {}));
|
|
245
|
-
function hasReadWriteCapability(provider) {
|
|
246
|
-
return !!(provider.capabilities & 2 /* FileReadWrite */);
|
|
247
|
-
}
|
|
248
|
-
exports.hasReadWriteCapability = hasReadWriteCapability;
|
|
249
|
-
function hasFileFolderCopyCapability(provider) {
|
|
250
|
-
return !!(provider.capabilities & 8 /* FileFolderCopy */);
|
|
251
|
-
}
|
|
252
|
-
exports.hasFileFolderCopyCapability = hasFileFolderCopyCapability;
|
|
253
|
-
function hasOpenReadWriteCloseCapability(provider) {
|
|
254
|
-
return !!(provider.capabilities & 4 /* FileOpenReadWriteClose */);
|
|
255
|
-
}
|
|
256
|
-
exports.hasOpenReadWriteCloseCapability = hasOpenReadWriteCloseCapability;
|
|
257
|
-
function hasFileReadStreamCapability(provider) {
|
|
258
|
-
return !!(provider.capabilities & 16 /* FileReadStream */);
|
|
259
|
-
}
|
|
260
|
-
exports.hasFileReadStreamCapability = hasFileReadStreamCapability;
|
|
261
|
-
function markAsFileSystemProviderError(error, code) {
|
|
262
|
-
error.name = code ? `${code} (FileSystemError)` : 'FileSystemError';
|
|
263
|
-
return error;
|
|
264
|
-
}
|
|
265
|
-
exports.markAsFileSystemProviderError = markAsFileSystemProviderError;
|
|
266
|
-
function toFileSystemProviderErrorCode(error) {
|
|
267
|
-
// Guard against abuse
|
|
268
|
-
if (!error) {
|
|
269
|
-
return FileSystemProviderErrorCode.Unknown;
|
|
270
|
-
}
|
|
271
|
-
// FileSystemProviderError comes with the code
|
|
272
|
-
if (error instanceof FileSystemProviderError) {
|
|
273
|
-
return error.code;
|
|
274
|
-
}
|
|
275
|
-
// Any other error, check for name match by assuming that the error
|
|
276
|
-
// went through the markAsFileSystemProviderError() method
|
|
277
|
-
const match = /^(.+) \(FileSystemError\)$/.exec(error.name);
|
|
278
|
-
if (!match) {
|
|
279
|
-
return FileSystemProviderErrorCode.Unknown;
|
|
280
|
-
}
|
|
281
|
-
switch (match[1]) {
|
|
282
|
-
case FileSystemProviderErrorCode.FileExists: return FileSystemProviderErrorCode.FileExists;
|
|
283
|
-
case FileSystemProviderErrorCode.FileIsADirectory: return FileSystemProviderErrorCode.FileIsADirectory;
|
|
284
|
-
case FileSystemProviderErrorCode.FileNotADirectory: return FileSystemProviderErrorCode.FileNotADirectory;
|
|
285
|
-
case FileSystemProviderErrorCode.FileNotFound: return FileSystemProviderErrorCode.FileNotFound;
|
|
286
|
-
case FileSystemProviderErrorCode.FileExceedsMemoryLimit: return FileSystemProviderErrorCode.FileExceedsMemoryLimit;
|
|
287
|
-
case FileSystemProviderErrorCode.FileTooLarge: return FileSystemProviderErrorCode.FileTooLarge;
|
|
288
|
-
case FileSystemProviderErrorCode.NoPermissions: return FileSystemProviderErrorCode.NoPermissions;
|
|
289
|
-
case FileSystemProviderErrorCode.Unavailable: return FileSystemProviderErrorCode.Unavailable;
|
|
290
|
-
}
|
|
291
|
-
return FileSystemProviderErrorCode.Unknown;
|
|
292
|
-
}
|
|
293
|
-
exports.toFileSystemProviderErrorCode = toFileSystemProviderErrorCode;
|
|
294
|
-
function toFileOperationResult(error) {
|
|
295
|
-
// FileSystemProviderError comes with the result already
|
|
296
|
-
if (error instanceof FileOperationError) {
|
|
297
|
-
return error.fileOperationResult;
|
|
298
|
-
}
|
|
299
|
-
// Otherwise try to find from code
|
|
300
|
-
switch (toFileSystemProviderErrorCode(error)) {
|
|
301
|
-
case FileSystemProviderErrorCode.FileNotFound:
|
|
302
|
-
return 1 /* FILE_NOT_FOUND */;
|
|
303
|
-
case FileSystemProviderErrorCode.FileIsADirectory:
|
|
304
|
-
return 0 /* FILE_IS_DIRECTORY */;
|
|
305
|
-
case FileSystemProviderErrorCode.FileNotADirectory:
|
|
306
|
-
return 10 /* FILE_NOT_DIRECTORY */;
|
|
307
|
-
case FileSystemProviderErrorCode.NoPermissions:
|
|
308
|
-
return 6 /* FILE_PERMISSION_DENIED */;
|
|
309
|
-
case FileSystemProviderErrorCode.FileExists:
|
|
310
|
-
return 4 /* FILE_MOVE_CONFLICT */;
|
|
311
|
-
case FileSystemProviderErrorCode.FileExceedsMemoryLimit:
|
|
312
|
-
return 9 /* FILE_EXCEEDS_MEMORY_LIMIT */;
|
|
313
|
-
case FileSystemProviderErrorCode.FileTooLarge:
|
|
314
|
-
return 7 /* FILE_TOO_LARGE */;
|
|
315
|
-
default:
|
|
316
|
-
return 11 /* FILE_OTHER_ERROR */;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
exports.toFileOperationResult = toFileOperationResult;
|
|
320
|
-
/**
|
|
321
|
-
* A hint to disable etag checking for reading/writing.
|
|
322
|
-
*/
|
|
323
|
-
exports.ETAG_DISABLED = '';
|
|
324
|
-
function etag(stat) {
|
|
325
|
-
if (typeof stat.size !== 'number' || typeof stat.mtime !== 'number') {
|
|
326
|
-
return undefined;
|
|
327
|
-
}
|
|
328
|
-
return stat.mtime.toString(29) + stat.size.toString(31);
|
|
329
|
-
}
|
|
330
|
-
exports.etag = etag;
|
|
331
|
-
/**
|
|
332
|
-
* Helper to format a raw byte size into a human readable label.
|
|
333
|
-
*/
|
|
334
|
-
class BinarySize {
|
|
335
|
-
static formatSize(size) {
|
|
336
|
-
if (size < BinarySize.KB) {
|
|
337
|
-
return size + 'B';
|
|
338
|
-
}
|
|
339
|
-
if (size < BinarySize.MB) {
|
|
340
|
-
return (size / BinarySize.KB).toFixed(2) + 'KB';
|
|
341
|
-
}
|
|
342
|
-
if (size < BinarySize.GB) {
|
|
343
|
-
return (size / BinarySize.MB).toFixed(2) + 'MB';
|
|
344
|
-
}
|
|
345
|
-
if (size < BinarySize.TB) {
|
|
346
|
-
return (size / BinarySize.GB).toFixed(2) + 'GB';
|
|
347
|
-
}
|
|
348
|
-
return (size / BinarySize.TB).toFixed(2) + 'TB';
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
exports.BinarySize = BinarySize;
|
|
352
|
-
BinarySize.KB = 1024;
|
|
353
|
-
BinarySize.MB = BinarySize.KB * BinarySize.KB;
|
|
354
|
-
BinarySize.GB = BinarySize.MB * BinarySize.KB;
|
|
355
|
-
BinarySize.TB = BinarySize.GB * BinarySize.KB;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
/*---------------------------------------------------------------------------------------------
|
|
18
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
19
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
20
|
+
*--------------------------------------------------------------------------------------------*/
|
|
21
|
+
// based on https://github.com/microsoft/vscode/blob/04c36be045a94fee58e5f8992d3e3fd980294a84/src/vs/platform/files/common/files.ts
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.BinarySize = exports.etag = exports.ETAG_DISABLED = exports.toFileOperationResult = exports.toFileSystemProviderErrorCode = exports.markAsFileSystemProviderError = exports.hasFileReadStreamCapability = exports.hasOpenReadWriteCloseCapability = exports.hasFileFolderCopyCapability = exports.hasReadWriteCapability = exports.ReadOnlyMessageFileSystemProvider = exports.hasUpdateCapability = exports.hasAccessCapability = exports.FileSystemProvider = exports.ensureFileSystemProviderError = exports.createFileSystemProviderError = exports.FileSystemProviderError = exports.FileSystemProviderErrorCode = exports.FilePermission = exports.FileType = exports.FileOperationError = exports.FileStat = exports.BaseStat = exports.FileChangesEvent = exports.FileOperationEvent = void 0;
|
|
24
|
+
const uri_1 = require("@theia/core/lib/common/uri");
|
|
25
|
+
const common_1 = require("@theia/core/lib/common");
|
|
26
|
+
class FileOperationEvent {
|
|
27
|
+
constructor(resource, operation, target) {
|
|
28
|
+
this.resource = resource;
|
|
29
|
+
this.operation = operation;
|
|
30
|
+
this.target = target;
|
|
31
|
+
}
|
|
32
|
+
isOperation(operation) {
|
|
33
|
+
return this.operation === operation;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.FileOperationEvent = FileOperationEvent;
|
|
37
|
+
class FileChangesEvent {
|
|
38
|
+
constructor(changes) {
|
|
39
|
+
this.changes = changes;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if this change event contains the provided file with the given change type (if provided). In case of
|
|
43
|
+
* type DELETED, this method will also return true if a folder got deleted that is the parent of the
|
|
44
|
+
* provided file path.
|
|
45
|
+
*/
|
|
46
|
+
contains(resource, type) {
|
|
47
|
+
if (!resource) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const checkForChangeType = typeof type === 'number';
|
|
51
|
+
return this.changes.some(change => {
|
|
52
|
+
if (checkForChangeType && change.type !== type) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
// For deleted also return true when deleted folder is parent of target path
|
|
56
|
+
if (change.type === 2 /* DELETED */) {
|
|
57
|
+
return change.resource.isEqualOrParent(resource);
|
|
58
|
+
}
|
|
59
|
+
return change.resource.toString() === resource.toString();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns the changes that describe added files.
|
|
64
|
+
*/
|
|
65
|
+
getAdded() {
|
|
66
|
+
return this.getOfType(1 /* ADDED */);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns if this event contains added files.
|
|
70
|
+
*/
|
|
71
|
+
gotAdded() {
|
|
72
|
+
return this.hasType(1 /* ADDED */);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns the changes that describe deleted files.
|
|
76
|
+
*/
|
|
77
|
+
getDeleted() {
|
|
78
|
+
return this.getOfType(2 /* DELETED */);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns if this event contains deleted files.
|
|
82
|
+
*/
|
|
83
|
+
gotDeleted() {
|
|
84
|
+
return this.hasType(2 /* DELETED */);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns the changes that describe updated files.
|
|
88
|
+
*/
|
|
89
|
+
getUpdated() {
|
|
90
|
+
return this.getOfType(0 /* UPDATED */);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns if this event contains updated files.
|
|
94
|
+
*/
|
|
95
|
+
gotUpdated() {
|
|
96
|
+
return this.hasType(0 /* UPDATED */);
|
|
97
|
+
}
|
|
98
|
+
getOfType(type) {
|
|
99
|
+
return this.changes.filter(change => change.type === type);
|
|
100
|
+
}
|
|
101
|
+
hasType(type) {
|
|
102
|
+
return this.changes.some(change => change.type === type);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.FileChangesEvent = FileChangesEvent;
|
|
106
|
+
var BaseStat;
|
|
107
|
+
(function (BaseStat) {
|
|
108
|
+
function is(arg) {
|
|
109
|
+
return (0, common_1.isObject)(arg)
|
|
110
|
+
&& arg.resource instanceof uri_1.default
|
|
111
|
+
&& typeof arg.name === 'string';
|
|
112
|
+
}
|
|
113
|
+
BaseStat.is = is;
|
|
114
|
+
})(BaseStat = exports.BaseStat || (exports.BaseStat = {}));
|
|
115
|
+
var FileStat;
|
|
116
|
+
(function (FileStat) {
|
|
117
|
+
function is(arg) {
|
|
118
|
+
const fileStat = arg;
|
|
119
|
+
return BaseStat.is(fileStat) &&
|
|
120
|
+
('isFile' in fileStat && typeof fileStat.isFile === 'boolean') &&
|
|
121
|
+
('isDirectory' in fileStat && typeof fileStat.isDirectory === 'boolean') &&
|
|
122
|
+
('isSymbolicLink' in fileStat && typeof fileStat.isSymbolicLink === 'boolean');
|
|
123
|
+
}
|
|
124
|
+
FileStat.is = is;
|
|
125
|
+
function asFileType(stat) {
|
|
126
|
+
let res = 0;
|
|
127
|
+
if (stat.isFile) {
|
|
128
|
+
res += FileType.File;
|
|
129
|
+
}
|
|
130
|
+
else if (stat.isDirectory) {
|
|
131
|
+
res += FileType.Directory;
|
|
132
|
+
}
|
|
133
|
+
if (stat.isSymbolicLink) {
|
|
134
|
+
res += FileType.SymbolicLink;
|
|
135
|
+
}
|
|
136
|
+
return res;
|
|
137
|
+
}
|
|
138
|
+
FileStat.asFileType = asFileType;
|
|
139
|
+
function toStat(stat) {
|
|
140
|
+
return {
|
|
141
|
+
type: asFileType(stat),
|
|
142
|
+
ctime: stat.ctime,
|
|
143
|
+
mtime: stat.mtime,
|
|
144
|
+
size: stat.size
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
FileStat.toStat = toStat;
|
|
148
|
+
function fromStat(resource, stat) {
|
|
149
|
+
return {
|
|
150
|
+
resource,
|
|
151
|
+
name: resource.path.base || resource.path.toString(),
|
|
152
|
+
isFile: (stat.type & FileType.File) !== 0,
|
|
153
|
+
isDirectory: (stat.type & FileType.Directory) !== 0,
|
|
154
|
+
isSymbolicLink: (stat.type & FileType.SymbolicLink) !== 0,
|
|
155
|
+
isReadonly: !!stat.permissions && (stat.permissions & FilePermission.Readonly) !== 0,
|
|
156
|
+
mtime: stat.mtime,
|
|
157
|
+
ctime: stat.ctime,
|
|
158
|
+
size: stat.size,
|
|
159
|
+
etag: etag({ mtime: stat.mtime, size: stat.size })
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
FileStat.fromStat = fromStat;
|
|
163
|
+
function dir(resource, stat) {
|
|
164
|
+
return fromStat(resource instanceof uri_1.default ? resource : new uri_1.default(resource), { type: FileType.Directory, ...stat });
|
|
165
|
+
}
|
|
166
|
+
FileStat.dir = dir;
|
|
167
|
+
function file(resource, stat) {
|
|
168
|
+
return fromStat(resource instanceof uri_1.default ? resource : new uri_1.default(resource), { type: FileType.File, ...stat });
|
|
169
|
+
}
|
|
170
|
+
FileStat.file = file;
|
|
171
|
+
})(FileStat = exports.FileStat || (exports.FileStat = {}));
|
|
172
|
+
class FileOperationError extends Error {
|
|
173
|
+
constructor(message, fileOperationResult, options) {
|
|
174
|
+
super(message);
|
|
175
|
+
this.fileOperationResult = fileOperationResult;
|
|
176
|
+
this.options = options;
|
|
177
|
+
Object.setPrototypeOf(this, FileOperationError.prototype);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.FileOperationError = FileOperationError;
|
|
181
|
+
var FileType;
|
|
182
|
+
(function (FileType) {
|
|
183
|
+
FileType[FileType["Unknown"] = 0] = "Unknown";
|
|
184
|
+
FileType[FileType["File"] = 1] = "File";
|
|
185
|
+
FileType[FileType["Directory"] = 2] = "Directory";
|
|
186
|
+
FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
|
|
187
|
+
})(FileType = exports.FileType || (exports.FileType = {}));
|
|
188
|
+
var FilePermission;
|
|
189
|
+
(function (FilePermission) {
|
|
190
|
+
/**
|
|
191
|
+
* File is readonly.
|
|
192
|
+
*/
|
|
193
|
+
FilePermission[FilePermission["Readonly"] = 1] = "Readonly";
|
|
194
|
+
})(FilePermission = exports.FilePermission || (exports.FilePermission = {}));
|
|
195
|
+
var FileSystemProviderErrorCode;
|
|
196
|
+
(function (FileSystemProviderErrorCode) {
|
|
197
|
+
FileSystemProviderErrorCode["FileExists"] = "EntryExists";
|
|
198
|
+
FileSystemProviderErrorCode["FileNotFound"] = "EntryNotFound";
|
|
199
|
+
FileSystemProviderErrorCode["FileNotADirectory"] = "EntryNotADirectory";
|
|
200
|
+
FileSystemProviderErrorCode["FileIsADirectory"] = "EntryIsADirectory";
|
|
201
|
+
FileSystemProviderErrorCode["FileExceedsMemoryLimit"] = "EntryExceedsMemoryLimit";
|
|
202
|
+
FileSystemProviderErrorCode["FileTooLarge"] = "EntryTooLarge";
|
|
203
|
+
FileSystemProviderErrorCode["NoPermissions"] = "NoPermissions";
|
|
204
|
+
FileSystemProviderErrorCode["Unavailable"] = "Unavailable";
|
|
205
|
+
FileSystemProviderErrorCode["Unknown"] = "Unknown";
|
|
206
|
+
})(FileSystemProviderErrorCode = exports.FileSystemProviderErrorCode || (exports.FileSystemProviderErrorCode = {}));
|
|
207
|
+
class FileSystemProviderError extends Error {
|
|
208
|
+
constructor(message, code) {
|
|
209
|
+
super(message);
|
|
210
|
+
this.code = code;
|
|
211
|
+
Object.setPrototypeOf(this, FileSystemProviderError.prototype);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
exports.FileSystemProviderError = FileSystemProviderError;
|
|
215
|
+
function createFileSystemProviderError(error, code) {
|
|
216
|
+
const providerError = new FileSystemProviderError(error.toString(), code);
|
|
217
|
+
markAsFileSystemProviderError(providerError, code);
|
|
218
|
+
return providerError;
|
|
219
|
+
}
|
|
220
|
+
exports.createFileSystemProviderError = createFileSystemProviderError;
|
|
221
|
+
function ensureFileSystemProviderError(error) {
|
|
222
|
+
if (!error) {
|
|
223
|
+
return createFileSystemProviderError('Unknown Error', FileSystemProviderErrorCode.Unknown); // https://github.com/Microsoft/vscode/issues/72798
|
|
224
|
+
}
|
|
225
|
+
return error;
|
|
226
|
+
}
|
|
227
|
+
exports.ensureFileSystemProviderError = ensureFileSystemProviderError;
|
|
228
|
+
exports.FileSystemProvider = Symbol('FileSystemProvider');
|
|
229
|
+
function hasAccessCapability(provider) {
|
|
230
|
+
return !!(provider.capabilities & 16777216 /* Access */);
|
|
231
|
+
}
|
|
232
|
+
exports.hasAccessCapability = hasAccessCapability;
|
|
233
|
+
function hasUpdateCapability(provider) {
|
|
234
|
+
return !!(provider.capabilities & 33554432 /* Update */);
|
|
235
|
+
}
|
|
236
|
+
exports.hasUpdateCapability = hasUpdateCapability;
|
|
237
|
+
var ReadOnlyMessageFileSystemProvider;
|
|
238
|
+
(function (ReadOnlyMessageFileSystemProvider) {
|
|
239
|
+
function is(arg) {
|
|
240
|
+
return (0, common_1.isObject)(arg)
|
|
241
|
+
&& 'readOnlyMessage' in arg;
|
|
242
|
+
}
|
|
243
|
+
ReadOnlyMessageFileSystemProvider.is = is;
|
|
244
|
+
})(ReadOnlyMessageFileSystemProvider = exports.ReadOnlyMessageFileSystemProvider || (exports.ReadOnlyMessageFileSystemProvider = {}));
|
|
245
|
+
function hasReadWriteCapability(provider) {
|
|
246
|
+
return !!(provider.capabilities & 2 /* FileReadWrite */);
|
|
247
|
+
}
|
|
248
|
+
exports.hasReadWriteCapability = hasReadWriteCapability;
|
|
249
|
+
function hasFileFolderCopyCapability(provider) {
|
|
250
|
+
return !!(provider.capabilities & 8 /* FileFolderCopy */);
|
|
251
|
+
}
|
|
252
|
+
exports.hasFileFolderCopyCapability = hasFileFolderCopyCapability;
|
|
253
|
+
function hasOpenReadWriteCloseCapability(provider) {
|
|
254
|
+
return !!(provider.capabilities & 4 /* FileOpenReadWriteClose */);
|
|
255
|
+
}
|
|
256
|
+
exports.hasOpenReadWriteCloseCapability = hasOpenReadWriteCloseCapability;
|
|
257
|
+
function hasFileReadStreamCapability(provider) {
|
|
258
|
+
return !!(provider.capabilities & 16 /* FileReadStream */);
|
|
259
|
+
}
|
|
260
|
+
exports.hasFileReadStreamCapability = hasFileReadStreamCapability;
|
|
261
|
+
function markAsFileSystemProviderError(error, code) {
|
|
262
|
+
error.name = code ? `${code} (FileSystemError)` : 'FileSystemError';
|
|
263
|
+
return error;
|
|
264
|
+
}
|
|
265
|
+
exports.markAsFileSystemProviderError = markAsFileSystemProviderError;
|
|
266
|
+
function toFileSystemProviderErrorCode(error) {
|
|
267
|
+
// Guard against abuse
|
|
268
|
+
if (!error) {
|
|
269
|
+
return FileSystemProviderErrorCode.Unknown;
|
|
270
|
+
}
|
|
271
|
+
// FileSystemProviderError comes with the code
|
|
272
|
+
if (error instanceof FileSystemProviderError) {
|
|
273
|
+
return error.code;
|
|
274
|
+
}
|
|
275
|
+
// Any other error, check for name match by assuming that the error
|
|
276
|
+
// went through the markAsFileSystemProviderError() method
|
|
277
|
+
const match = /^(.+) \(FileSystemError\)$/.exec(error.name);
|
|
278
|
+
if (!match) {
|
|
279
|
+
return FileSystemProviderErrorCode.Unknown;
|
|
280
|
+
}
|
|
281
|
+
switch (match[1]) {
|
|
282
|
+
case FileSystemProviderErrorCode.FileExists: return FileSystemProviderErrorCode.FileExists;
|
|
283
|
+
case FileSystemProviderErrorCode.FileIsADirectory: return FileSystemProviderErrorCode.FileIsADirectory;
|
|
284
|
+
case FileSystemProviderErrorCode.FileNotADirectory: return FileSystemProviderErrorCode.FileNotADirectory;
|
|
285
|
+
case FileSystemProviderErrorCode.FileNotFound: return FileSystemProviderErrorCode.FileNotFound;
|
|
286
|
+
case FileSystemProviderErrorCode.FileExceedsMemoryLimit: return FileSystemProviderErrorCode.FileExceedsMemoryLimit;
|
|
287
|
+
case FileSystemProviderErrorCode.FileTooLarge: return FileSystemProviderErrorCode.FileTooLarge;
|
|
288
|
+
case FileSystemProviderErrorCode.NoPermissions: return FileSystemProviderErrorCode.NoPermissions;
|
|
289
|
+
case FileSystemProviderErrorCode.Unavailable: return FileSystemProviderErrorCode.Unavailable;
|
|
290
|
+
}
|
|
291
|
+
return FileSystemProviderErrorCode.Unknown;
|
|
292
|
+
}
|
|
293
|
+
exports.toFileSystemProviderErrorCode = toFileSystemProviderErrorCode;
|
|
294
|
+
function toFileOperationResult(error) {
|
|
295
|
+
// FileSystemProviderError comes with the result already
|
|
296
|
+
if (error instanceof FileOperationError) {
|
|
297
|
+
return error.fileOperationResult;
|
|
298
|
+
}
|
|
299
|
+
// Otherwise try to find from code
|
|
300
|
+
switch (toFileSystemProviderErrorCode(error)) {
|
|
301
|
+
case FileSystemProviderErrorCode.FileNotFound:
|
|
302
|
+
return 1 /* FILE_NOT_FOUND */;
|
|
303
|
+
case FileSystemProviderErrorCode.FileIsADirectory:
|
|
304
|
+
return 0 /* FILE_IS_DIRECTORY */;
|
|
305
|
+
case FileSystemProviderErrorCode.FileNotADirectory:
|
|
306
|
+
return 10 /* FILE_NOT_DIRECTORY */;
|
|
307
|
+
case FileSystemProviderErrorCode.NoPermissions:
|
|
308
|
+
return 6 /* FILE_PERMISSION_DENIED */;
|
|
309
|
+
case FileSystemProviderErrorCode.FileExists:
|
|
310
|
+
return 4 /* FILE_MOVE_CONFLICT */;
|
|
311
|
+
case FileSystemProviderErrorCode.FileExceedsMemoryLimit:
|
|
312
|
+
return 9 /* FILE_EXCEEDS_MEMORY_LIMIT */;
|
|
313
|
+
case FileSystemProviderErrorCode.FileTooLarge:
|
|
314
|
+
return 7 /* FILE_TOO_LARGE */;
|
|
315
|
+
default:
|
|
316
|
+
return 11 /* FILE_OTHER_ERROR */;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
exports.toFileOperationResult = toFileOperationResult;
|
|
320
|
+
/**
|
|
321
|
+
* A hint to disable etag checking for reading/writing.
|
|
322
|
+
*/
|
|
323
|
+
exports.ETAG_DISABLED = '';
|
|
324
|
+
function etag(stat) {
|
|
325
|
+
if (typeof stat.size !== 'number' || typeof stat.mtime !== 'number') {
|
|
326
|
+
return undefined;
|
|
327
|
+
}
|
|
328
|
+
return stat.mtime.toString(29) + stat.size.toString(31);
|
|
329
|
+
}
|
|
330
|
+
exports.etag = etag;
|
|
331
|
+
/**
|
|
332
|
+
* Helper to format a raw byte size into a human readable label.
|
|
333
|
+
*/
|
|
334
|
+
class BinarySize {
|
|
335
|
+
static formatSize(size) {
|
|
336
|
+
if (size < BinarySize.KB) {
|
|
337
|
+
return size + 'B';
|
|
338
|
+
}
|
|
339
|
+
if (size < BinarySize.MB) {
|
|
340
|
+
return (size / BinarySize.KB).toFixed(2) + 'KB';
|
|
341
|
+
}
|
|
342
|
+
if (size < BinarySize.GB) {
|
|
343
|
+
return (size / BinarySize.MB).toFixed(2) + 'MB';
|
|
344
|
+
}
|
|
345
|
+
if (size < BinarySize.TB) {
|
|
346
|
+
return (size / BinarySize.GB).toFixed(2) + 'GB';
|
|
347
|
+
}
|
|
348
|
+
return (size / BinarySize.TB).toFixed(2) + 'TB';
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
exports.BinarySize = BinarySize;
|
|
352
|
+
BinarySize.KB = 1024;
|
|
353
|
+
BinarySize.MB = BinarySize.KB * BinarySize.KB;
|
|
354
|
+
BinarySize.GB = BinarySize.MB * BinarySize.KB;
|
|
355
|
+
BinarySize.TB = BinarySize.GB * BinarySize.KB;
|
|
356
356
|
//# sourceMappingURL=files.js.map
|