@theia/filesystem 1.26.0-next.41 → 1.26.0-next.45
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/lib/browser/file-tree/file-tree-widget.js +1 -1
- package/lib/browser/file-tree/file-tree-widget.js.map +1 -1
- package/lib/browser/file-tree/file-tree.d.ts +1 -2
- package/lib/browser/file-tree/file-tree.d.ts.map +1 -1
- package/lib/browser/file-tree/file-tree.js.map +1 -1
- package/lib/browser/filesystem-frontend-module.d.ts.map +1 -1
- package/lib/browser/filesystem-frontend-module.js +0 -165
- package/lib/browser/filesystem-frontend-module.js.map +1 -1
- package/lib/browser/index.d.ts +0 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/common/files.d.ts +1 -1
- package/lib/common/filesystem-watcher-protocol.d.ts +1 -22
- package/lib/common/filesystem-watcher-protocol.d.ts.map +1 -1
- package/lib/common/filesystem-watcher-protocol.js +1 -68
- package/lib/common/filesystem-watcher-protocol.js.map +1 -1
- package/lib/common/filesystem.d.ts +0 -226
- package/lib/common/filesystem.d.ts.map +1 -1
- package/lib/common/filesystem.js +1 -48
- package/lib/common/filesystem.js.map +1 -1
- package/lib/common/remote-file-system-provider.d.ts +9 -9
- package/lib/common/remote-file-system-provider.d.ts.map +1 -1
- package/lib/common/remote-file-system-provider.js +10 -9
- package/lib/common/remote-file-system-provider.js.map +1 -1
- package/package.json +3 -3
- package/src/browser/file-tree/file-tree-widget.tsx +1 -1
- package/src/browser/file-tree/file-tree.ts +1 -2
- package/src/browser/filesystem-frontend-module.ts +0 -162
- package/src/browser/index.ts +0 -1
- package/src/common/files.ts +1 -1
- package/src/common/filesystem-watcher-protocol.ts +1 -67
- package/src/common/filesystem.ts +0 -259
- package/src/common/remote-file-system-provider.ts +19 -18
- package/lib/browser/filesystem-watcher.d.ts +0 -134
- package/lib/browser/filesystem-watcher.d.ts.map +0 -1
- package/lib/browser/filesystem-watcher.js +0 -240
- package/lib/browser/filesystem-watcher.js.map +0 -1
- package/lib/node/node-file-upload.d.ts +0 -19
- package/lib/node/node-file-upload.d.ts.map +0 -1
- package/lib/node/node-file-upload.js +0 -55
- package/lib/node/node-file-upload.js.map +0 -1
- package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.d.ts +0 -53
- package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.d.ts.map +0 -1
- package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.js +0 -197
- package/lib/node/nsfw-watcher/nsfw-filesystem-watcher.js.map +0 -1
- package/src/browser/filesystem-watcher.ts +0 -249
- package/src/node/node-file-upload.ts +0 -64
- package/src/node/nsfw-watcher/nsfw-filesystem-watcher.ts +0 -255
|
@@ -21,21 +21,14 @@ import { ResourceResolver, CommandContribution } from '@theia/core/lib/common';
|
|
|
21
21
|
import { WebSocketConnectionProvider, FrontendApplicationContribution, LabelProviderContribution, BreadcrumbsContribution } from '@theia/core/lib/browser';
|
|
22
22
|
import { FileResourceResolver } from './file-resource';
|
|
23
23
|
import { bindFileSystemPreferences } from './filesystem-preferences';
|
|
24
|
-
import { FileSystemWatcher } from './filesystem-watcher';
|
|
25
24
|
import { FileSystemFrontendContribution } from './filesystem-frontend-contribution';
|
|
26
25
|
import { FileUploadService } from './file-upload-service';
|
|
27
26
|
import { FileTreeDecoratorAdapter, FileTreeLabelProvider } from './file-tree';
|
|
28
27
|
import { FileService, FileServiceContribution } from './file-service';
|
|
29
28
|
import { RemoteFileSystemProvider, RemoteFileSystemServer, remoteFileSystemPath, RemoteFileSystemProxyFactory } from '../common/remote-file-system-provider';
|
|
30
|
-
import { FileSystem, FileStat, FileMoveOptions, FileDeleteOptions, FileSystemError } from '../common/filesystem';
|
|
31
|
-
import URI from '@theia/core/lib/common/uri';
|
|
32
|
-
import { FileOperationError, FileOperationResult, BaseStatWithMetadata, FileStatWithMetadata, etag } from '../common/files';
|
|
33
|
-
import { TextDocumentContentChangeEvent } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
34
|
-
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
35
29
|
import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
|
|
36
30
|
import { RemoteFileServiceContribution } from './remote-file-service-contribution';
|
|
37
31
|
import { FileSystemWatcherErrorHandler } from './filesystem-watcher-error-handler';
|
|
38
|
-
import { UTF8 } from '@theia/core/lib/common/encodings';
|
|
39
32
|
import { FilepathBreadcrumbsContribution } from './breadcrumbs/filepath-breadcrumbs-contribution';
|
|
40
33
|
import { BreadcrumbsFileTreeWidget, createFileTreeBreadcrumbsWidget } from './breadcrumbs/filepath-breadcrumbs-container';
|
|
41
34
|
import { FilesystemSaveResourceService } from './filesystem-save-resource-service';
|
|
@@ -54,163 +47,8 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
|
54
47
|
bind(RemoteFileServiceContribution).toSelf().inSingletonScope();
|
|
55
48
|
bind(FileServiceContribution).toService(RemoteFileServiceContribution);
|
|
56
49
|
|
|
57
|
-
bind(FileSystemWatcher).toSelf().inSingletonScope();
|
|
58
50
|
bind(FileSystemWatcherErrorHandler).toSelf().inSingletonScope();
|
|
59
51
|
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
-
bind(FileSystem).toDynamicValue(({ container }) => {
|
|
62
|
-
const fileService = container.get(FileService);
|
|
63
|
-
const environments = container.get<EnvVariablesServer>(EnvVariablesServer);
|
|
64
|
-
const convertStat: (stat: BaseStatWithMetadata | FileStatWithMetadata) => FileStat = stat => ({
|
|
65
|
-
uri: stat.resource.toString(),
|
|
66
|
-
lastModification: stat.mtime,
|
|
67
|
-
size: stat.size,
|
|
68
|
-
isDirectory: 'isDirectory' in stat && stat.isDirectory,
|
|
69
|
-
children: 'children' in stat ? stat.children?.map(convertStat) : undefined
|
|
70
|
-
});
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
-
const rethrowError: (uri: string, error: any) => never = (uri, error) => {
|
|
73
|
-
if (error instanceof FileOperationError) {
|
|
74
|
-
if (error.fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
|
|
75
|
-
throw FileSystemError.FileNotFound(uri);
|
|
76
|
-
}
|
|
77
|
-
if (error.fileOperationResult === FileOperationResult.FILE_IS_DIRECTORY) {
|
|
78
|
-
throw FileSystemError.FileIsDirectory(uri);
|
|
79
|
-
}
|
|
80
|
-
if (error.fileOperationResult === FileOperationResult.FILE_NOT_DIRECTORY) {
|
|
81
|
-
throw FileSystemError.FileNotDirectory(uri);
|
|
82
|
-
}
|
|
83
|
-
if (error.fileOperationResult === FileOperationResult.FILE_MODIFIED_SINCE) {
|
|
84
|
-
throw FileSystemError.FileIsOutOfSync(uri);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
throw error;
|
|
88
|
-
};
|
|
89
|
-
return new class implements FileSystem {
|
|
90
|
-
async getFileStat(uri: string): Promise<FileStat | undefined> {
|
|
91
|
-
try {
|
|
92
|
-
const stat = await fileService.resolve(new URI(uri), { resolveMetadata: true });
|
|
93
|
-
return convertStat(stat);
|
|
94
|
-
} catch (e) {
|
|
95
|
-
if (e instanceof FileOperationError && e.fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
rethrowError(uri, e);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exists(uri: string): Promise<boolean> {
|
|
102
|
-
return fileService.exists(new URI(uri));
|
|
103
|
-
}
|
|
104
|
-
async resolveContent(uri: string, options?: { encoding?: string | undefined; } | undefined): Promise<{ stat: FileStat; content: string; }> {
|
|
105
|
-
try {
|
|
106
|
-
const content = await fileService.read(new URI(uri), options);
|
|
107
|
-
return {
|
|
108
|
-
stat: convertStat(content),
|
|
109
|
-
content: content.value
|
|
110
|
-
};
|
|
111
|
-
} catch (e) {
|
|
112
|
-
rethrowError(uri, e);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async setContent(file: FileStat, content: string, options?: { encoding?: string | undefined; } | undefined): Promise<FileStat> {
|
|
116
|
-
try {
|
|
117
|
-
const result = await fileService.write(new URI(file.uri), content, {
|
|
118
|
-
...options,
|
|
119
|
-
mtime: file.lastModification
|
|
120
|
-
});
|
|
121
|
-
return convertStat(result);
|
|
122
|
-
} catch (e) {
|
|
123
|
-
rethrowError(file.uri, e);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async updateContent(file: FileStat, contentChanges: TextDocumentContentChangeEvent[], options?: {
|
|
127
|
-
encoding?: string | undefined;
|
|
128
|
-
overwriteEncoding?: string | undefined;
|
|
129
|
-
} | undefined): Promise<FileStat> {
|
|
130
|
-
try {
|
|
131
|
-
const result = await fileService.update(new URI(file.uri), contentChanges, {
|
|
132
|
-
mtime: file.lastModification,
|
|
133
|
-
etag: etag({ size: file.size, mtime: file.lastModification }),
|
|
134
|
-
readEncoding: options?.encoding || UTF8,
|
|
135
|
-
encoding: options?.overwriteEncoding,
|
|
136
|
-
overwriteEncoding: !!options?.overwriteEncoding
|
|
137
|
-
});
|
|
138
|
-
return convertStat(result);
|
|
139
|
-
} catch (e) {
|
|
140
|
-
rethrowError(file.uri, e);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
async move(sourceUri: string, targetUri: string, options?: FileMoveOptions | undefined): Promise<FileStat> {
|
|
144
|
-
try {
|
|
145
|
-
const result = await fileService.move(new URI(sourceUri), new URI(targetUri), options);
|
|
146
|
-
return convertStat(result);
|
|
147
|
-
} catch (e) {
|
|
148
|
-
rethrowError(sourceUri, e);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
async copy(sourceUri: string, targetUri: string, options?: { overwrite?: boolean | undefined; recursive?: boolean | undefined; } | undefined): Promise<FileStat> {
|
|
152
|
-
try {
|
|
153
|
-
const result = await fileService.copy(new URI(sourceUri), new URI(targetUri), options);
|
|
154
|
-
return convertStat(result);
|
|
155
|
-
} catch (e) {
|
|
156
|
-
rethrowError(sourceUri, e);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
async createFile(uri: string, options?: { content?: string | undefined; encoding?: string | undefined; } | undefined): Promise<FileStat> {
|
|
160
|
-
try {
|
|
161
|
-
const result = await fileService.create(new URI(uri), options?.content, { encoding: options?.encoding });
|
|
162
|
-
return convertStat(result);
|
|
163
|
-
} catch (e) {
|
|
164
|
-
rethrowError(uri, e);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
async createFolder(uri: string): Promise<FileStat> {
|
|
168
|
-
try {
|
|
169
|
-
const result = await fileService.createFolder(new URI(uri));
|
|
170
|
-
return convertStat(result);
|
|
171
|
-
} catch (e) {
|
|
172
|
-
rethrowError(uri, e);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
touchFile(uri: string): Promise<FileStat> {
|
|
176
|
-
throw new Error('Method not implemented.');
|
|
177
|
-
}
|
|
178
|
-
async delete(uri: string, options?: FileDeleteOptions | undefined): Promise<void> {
|
|
179
|
-
try {
|
|
180
|
-
return await fileService.delete(new URI(uri), { useTrash: options?.moveToTrash, recursive: true });
|
|
181
|
-
} catch (e) {
|
|
182
|
-
rethrowError(uri, e);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
async getEncoding(uri: string): Promise<string> {
|
|
186
|
-
const { encoding } = await fileService.read(new URI(uri));
|
|
187
|
-
return encoding;
|
|
188
|
-
}
|
|
189
|
-
async guessEncoding(uri: string): Promise<string | undefined> {
|
|
190
|
-
const { encoding } = await fileService.read(new URI(uri), { autoGuessEncoding: true });
|
|
191
|
-
return encoding;
|
|
192
|
-
}
|
|
193
|
-
async getRoots(): Promise<FileStat[]> {
|
|
194
|
-
const drives = await environments.getDrives();
|
|
195
|
-
const roots = await Promise.all(drives.map(uri => this.getFileStat(uri)));
|
|
196
|
-
return roots.filter(root => !!root) as FileStat[];
|
|
197
|
-
}
|
|
198
|
-
async getCurrentUserHome(): Promise<FileStat | undefined> {
|
|
199
|
-
return this.getFileStat(await environments.getHomeDirUri());
|
|
200
|
-
}
|
|
201
|
-
getDrives(): Promise<string[]> {
|
|
202
|
-
return environments.getDrives();
|
|
203
|
-
}
|
|
204
|
-
access(uri: string, mode?: number | undefined): Promise<boolean> {
|
|
205
|
-
return fileService.access(new URI(uri), mode);
|
|
206
|
-
}
|
|
207
|
-
getFsPath(uri: string): Promise<string | undefined> {
|
|
208
|
-
return fileService.fsPath(new URI(uri));
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
};
|
|
212
|
-
}).inSingletonScope();
|
|
213
|
-
|
|
214
52
|
bindFileResource(bind);
|
|
215
53
|
|
|
216
54
|
bind(FileUploadService).toSelf().inSingletonScope();
|
package/src/browser/index.ts
CHANGED
package/src/common/files.ts
CHANGED
|
@@ -846,7 +846,7 @@ export function hasOpenReadWriteCloseCapability(provider: FileSystemProvider): p
|
|
|
846
846
|
*/
|
|
847
847
|
export interface FileSystemProviderWithFileReadStreamCapability extends FileSystemProvider {
|
|
848
848
|
/**
|
|
849
|
-
* Read the
|
|
849
|
+
* Read the contents of the given file as stream.
|
|
850
850
|
* @param resource The `URI` of the file.
|
|
851
851
|
*
|
|
852
852
|
* @return The `ReadableStreamEvents` for the readable stream of the given file.
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
import { JsonRpcServer, JsonRpcProxy } from '@theia/core';
|
|
17
|
+
import { JsonRpcServer } from '@theia/core';
|
|
19
18
|
import { FileChangeType } from './files';
|
|
20
19
|
export { FileChangeType };
|
|
21
20
|
|
|
@@ -95,68 +94,3 @@ export interface FileChange {
|
|
|
95
94
|
uri: string;
|
|
96
95
|
type: FileChangeType;
|
|
97
96
|
}
|
|
98
|
-
|
|
99
|
-
export const FileSystemWatcherServerProxy = Symbol('FileSystemWatcherServerProxy');
|
|
100
|
-
export type FileSystemWatcherServerProxy = JsonRpcProxy<FileSystemWatcherServer>;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @deprecated not used internally anymore.
|
|
104
|
-
*/
|
|
105
|
-
@injectable()
|
|
106
|
-
export class ReconnectingFileSystemWatcherServer implements FileSystemWatcherServer {
|
|
107
|
-
|
|
108
|
-
protected watcherSequence = 1;
|
|
109
|
-
protected readonly watchParams = new Map<number, {
|
|
110
|
-
uri: string;
|
|
111
|
-
options?: WatchOptions
|
|
112
|
-
}>();
|
|
113
|
-
protected readonly localToRemoteWatcher = new Map<number, number>();
|
|
114
|
-
|
|
115
|
-
constructor(
|
|
116
|
-
@inject(FileSystemWatcherServerProxy) protected readonly proxy: FileSystemWatcherServerProxy
|
|
117
|
-
) {
|
|
118
|
-
const onInitialized = this.proxy.onDidOpenConnection(() => {
|
|
119
|
-
// skip reconnection on the first connection
|
|
120
|
-
onInitialized.dispose();
|
|
121
|
-
this.proxy.onDidOpenConnection(() => this.reconnect());
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
protected reconnect(): void {
|
|
126
|
-
for (const [watcher, { uri, options }] of this.watchParams.entries()) {
|
|
127
|
-
this.doWatchFileChanges(watcher, uri, options);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
dispose(): void {
|
|
132
|
-
this.proxy.dispose();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
watchFileChanges(uri: string, options?: WatchOptions): Promise<number> {
|
|
136
|
-
const watcher = this.watcherSequence++;
|
|
137
|
-
this.watchParams.set(watcher, { uri, options });
|
|
138
|
-
return this.doWatchFileChanges(watcher, uri, options);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
protected doWatchFileChanges(watcher: number, uri: string, options?: WatchOptions): Promise<number> {
|
|
142
|
-
return this.proxy.watchFileChanges(uri, options).then(remote => {
|
|
143
|
-
this.localToRemoteWatcher.set(watcher, remote);
|
|
144
|
-
return watcher;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
unwatchFileChanges(watcher: number): Promise<void> {
|
|
149
|
-
this.watchParams.delete(watcher);
|
|
150
|
-
const remote = this.localToRemoteWatcher.get(watcher);
|
|
151
|
-
if (remote) {
|
|
152
|
-
this.localToRemoteWatcher.delete(watcher);
|
|
153
|
-
return this.proxy.unwatchFileChanges(remote);
|
|
154
|
-
}
|
|
155
|
-
return Promise.resolve();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
setClient(client: FileSystemWatcherClient | undefined): void {
|
|
159
|
-
this.proxy.setClient(client);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
}
|
package/src/common/filesystem.ts
CHANGED
|
@@ -14,179 +14,6 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
/* eslint-disable max-len */
|
|
18
|
-
|
|
19
|
-
import { TextDocumentContentChangeEvent } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
20
|
-
import { ApplicationError } from '@theia/core/lib/common';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService` instead
|
|
24
|
-
*/
|
|
25
|
-
export const FileSystem = Symbol('FileSystem');
|
|
26
|
-
export interface FileSystem {
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Returns the file stat for the given URI.
|
|
30
|
-
*
|
|
31
|
-
* If the uri points to a folder it will contain one level of unresolved children.
|
|
32
|
-
*
|
|
33
|
-
* `undefined` if a file for the given URI does not exist.
|
|
34
|
-
*
|
|
35
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.resolve` instead
|
|
36
|
-
*/
|
|
37
|
-
getFileStat(uri: string): Promise<FileStat | undefined>;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Finds out if a file identified by the resource exists.
|
|
41
|
-
*
|
|
42
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.exists` instead
|
|
43
|
-
*/
|
|
44
|
-
exists(uri: string): Promise<boolean>;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Resolve the contents of a file identified by the resource.
|
|
48
|
-
*
|
|
49
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.read` instead
|
|
50
|
-
*/
|
|
51
|
-
resolveContent(uri: string, options?: { encoding?: string }): Promise<{ stat: FileStat, content: string }>;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Updates the content replacing its previous value.
|
|
55
|
-
*
|
|
56
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.write` instead
|
|
57
|
-
*/
|
|
58
|
-
setContent(file: FileStat, content: string, options?: { encoding?: string }): Promise<FileStat>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Updates the content replacing its previous value.
|
|
62
|
-
*
|
|
63
|
-
* The optional parameter `overwriteEncoding` can be used to transform the encoding of a file.
|
|
64
|
-
*
|
|
65
|
-
* | | encoding | overwriteEncoding | behaviour |
|
|
66
|
-
* |---|----------|-------------------|-----------|
|
|
67
|
-
* | 1 | undefined | undefined | read & write file in default encoding |
|
|
68
|
-
* | 2 | undefined | ✓ | read file in default encoding; write file in `overwriteEncoding` |
|
|
69
|
-
* | 3 | ✓ | undefined | read & write file in `encoding` |
|
|
70
|
-
* | 4 | ✓ | ✓ | read file in `encoding`; write file in `overwriteEncoding` |
|
|
71
|
-
*
|
|
72
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.write` instead
|
|
73
|
-
*/
|
|
74
|
-
updateContent(file: FileStat, contentChanges: TextDocumentContentChangeEvent[], options?: { encoding?: string, overwriteEncoding?: string }): Promise<FileStat>;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Moves the file to a new path identified by the resource.
|
|
78
|
-
*
|
|
79
|
-
* The optional parameter overwrite can be set to replace an existing file at the location.
|
|
80
|
-
*
|
|
81
|
-
* | | missing | file | empty dir | dir |
|
|
82
|
-
* |-----------|---------|------|-----------|-----------|
|
|
83
|
-
* | missing | x | x | x | x |
|
|
84
|
-
* | file | ✓ | x | x | x |
|
|
85
|
-
* | empty dir | ✓ | x | x | overwrite |
|
|
86
|
-
* | dir | ✓ | x | overwrite | overwrite |
|
|
87
|
-
*
|
|
88
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.move` instead
|
|
89
|
-
*/
|
|
90
|
-
move(sourceUri: string, targetUri: string, options?: FileMoveOptions): Promise<FileStat>;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Copies the file to a path identified by the resource.
|
|
94
|
-
*
|
|
95
|
-
* The optional parameter overwrite can be set to replace an existing file at the location.
|
|
96
|
-
*
|
|
97
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.copy` instead
|
|
98
|
-
*/
|
|
99
|
-
copy(sourceUri: string, targetUri: string, options?: { overwrite?: boolean, recursive?: boolean }): Promise<FileStat>;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Creates a new file with the given path. The returned promise
|
|
103
|
-
* will have the stat model object as a result.
|
|
104
|
-
*
|
|
105
|
-
* The optional parameter content can be used as value to fill into the new file.
|
|
106
|
-
*
|
|
107
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.create` instead
|
|
108
|
-
*/
|
|
109
|
-
createFile(uri: string, options?: { content?: string, encoding?: string }): Promise<FileStat>;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Creates a new folder with the given path. The returned promise
|
|
113
|
-
* will have the stat model object as a result.
|
|
114
|
-
*
|
|
115
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.createFolder` instead
|
|
116
|
-
*/
|
|
117
|
-
createFolder(uri: string): Promise<FileStat>;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Creates a new empty file if the given path does not exist and otherwise
|
|
121
|
-
* will set the mtime and atime of the file to the current date.
|
|
122
|
-
*/
|
|
123
|
-
touchFile(uri: string): Promise<FileStat>;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Deletes the provided file. The optional moveToTrash parameter allows to
|
|
127
|
-
* move the file to trash.
|
|
128
|
-
*
|
|
129
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.delete` instead
|
|
130
|
-
*/
|
|
131
|
-
delete(uri: string, options?: FileDeleteOptions): Promise<void>;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Returns the encoding of the given file resource.
|
|
135
|
-
*
|
|
136
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908) use `FileService.read` without `autoGuessEncoding` option instead
|
|
137
|
-
*/
|
|
138
|
-
getEncoding(uri: string): Promise<string>;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Guess encoding of a given file based on its content.
|
|
142
|
-
*
|
|
143
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.read` with `autoGuessEncoding` option instead
|
|
144
|
-
*/
|
|
145
|
-
guessEncoding(uri: string): Promise<string | undefined>;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Return list of available roots.
|
|
149
|
-
*/
|
|
150
|
-
getRoots(): Promise<FileStat[]>;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Returns a promise that resolves to a file stat representing the current user's home directory.
|
|
154
|
-
*
|
|
155
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `EnvVariablesServer.getHomeDirUri` instead
|
|
156
|
-
*/
|
|
157
|
-
getCurrentUserHome(): Promise<FileStat | undefined>;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Resolves to an array of URIs pointing to the available drives on the filesystem.
|
|
161
|
-
*
|
|
162
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `EnvVariablesServer.getDrives` instead
|
|
163
|
-
*/
|
|
164
|
-
getDrives(): Promise<string[]>;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Tests a user's permissions for the file or directory specified by URI.
|
|
168
|
-
* The mode argument is an optional integer that specifies the accessibility checks to be performed.
|
|
169
|
-
* Check `FileAccess.Constants` for possible values of mode.
|
|
170
|
-
* It is possible to create a mask consisting of the bitwise `OR` of two or more values (e.g. FileAccess.Constants.W_OK | FileAccess.Constants.R_OK).
|
|
171
|
-
* If `mode` is not defined, `FileAccess.Constants.F_OK` will be used instead.
|
|
172
|
-
*
|
|
173
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.access` instead
|
|
174
|
-
*/
|
|
175
|
-
access(uri: string, mode?: number): Promise<boolean>
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Returns the path of the given file URI, specific to the backend's operating system.
|
|
179
|
-
* If the URI is not a file URI, undefined is returned.
|
|
180
|
-
*
|
|
181
|
-
* USE WITH CAUTION: You should always prefer URIs to paths if possible, as they are
|
|
182
|
-
* portable and platform independent. Paths should only be used in cases you directly
|
|
183
|
-
* interact with the OS, e.g. when running a command on the shell.
|
|
184
|
-
*
|
|
185
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileService.fsPath` instead
|
|
186
|
-
*/
|
|
187
|
-
getFsPath(uri: string): Promise<string | undefined>
|
|
188
|
-
}
|
|
189
|
-
|
|
190
17
|
export namespace FileAccess {
|
|
191
18
|
|
|
192
19
|
export namespace Constants {
|
|
@@ -212,91 +39,5 @@ export namespace FileAccess {
|
|
|
212
39
|
* This has no effect on Windows (will behave like `FileAccess.F_OK`).
|
|
213
40
|
*/
|
|
214
41
|
export const X_OK: number = 1;
|
|
215
|
-
|
|
216
42
|
}
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export interface FileMoveOptions {
|
|
221
|
-
overwrite?: boolean;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export interface FileDeleteOptions {
|
|
225
|
-
moveToTrash?: boolean
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* A file resource with meta information.
|
|
230
|
-
*
|
|
231
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileStat` from `@theia/filesystem/lib/common/files` instead
|
|
232
|
-
*/
|
|
233
|
-
export interface FileStat {
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* The URI of the file.
|
|
237
|
-
*/
|
|
238
|
-
uri: string;
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* The last modification of this file.
|
|
242
|
-
*/
|
|
243
|
-
lastModification: number;
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* `true` if the resource is a directory. Otherwise, `false`.
|
|
247
|
-
*/
|
|
248
|
-
isDirectory: boolean;
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* The children of the file stat.
|
|
252
|
-
* If it is `undefined` and `isDirectory` is `true`, then this file stat is unresolved.
|
|
253
|
-
*/
|
|
254
|
-
children?: FileStat[];
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* The size of the file if known.
|
|
258
|
-
*/
|
|
259
|
-
size?: number;
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export namespace FileStat {
|
|
264
|
-
export function is(candidate: Object | undefined): candidate is FileStat {
|
|
265
|
-
return typeof candidate === 'object' && ('uri' in candidate) && ('lastModification' in candidate) && ('isDirectory' in candidate);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export function equals(one: object | undefined, other: object | undefined): boolean {
|
|
269
|
-
if (!one || !other || !is(one) || !is(other)) {
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
return one.uri === other.uri
|
|
273
|
-
&& one.lastModification === other.lastModification
|
|
274
|
-
&& one.isDirectory === other.isDirectory;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* @deprecated since 1.4.0 - in order to support VS Code FS API (https://github.com/eclipse-theia/theia/pull/7908), use `FileOperationError` instead
|
|
280
|
-
*/
|
|
281
|
-
export namespace FileSystemError {
|
|
282
|
-
export const FileNotFound = ApplicationError.declare(-33000, (uri: string, prefix?: string) => ({
|
|
283
|
-
message: `${prefix ? prefix + ' ' : ''}'${uri}' has not been found.`,
|
|
284
|
-
data: { uri }
|
|
285
|
-
}));
|
|
286
|
-
export const FileExists = ApplicationError.declare(-33001, (uri: string, prefix?: string) => ({
|
|
287
|
-
message: `${prefix ? prefix + ' ' : ''}'${uri}' already exists.`,
|
|
288
|
-
data: { uri }
|
|
289
|
-
}));
|
|
290
|
-
export const FileIsDirectory = ApplicationError.declare(-33002, (uri: string, prefix?: string) => ({
|
|
291
|
-
message: `${prefix ? prefix + ' ' : ''}'${uri}' is a directory.`,
|
|
292
|
-
data: { uri }
|
|
293
|
-
}));
|
|
294
|
-
export const FileNotDirectory = ApplicationError.declare(-33003, (uri: string, prefix?: string) => ({
|
|
295
|
-
message: `${prefix ? prefix + ' ' : ''}'${uri}' is not a directory.`,
|
|
296
|
-
data: { uri }
|
|
297
|
-
}));
|
|
298
|
-
export const FileIsOutOfSync = ApplicationError.declare(-33004, (file: FileStat, stat: FileStat) => ({
|
|
299
|
-
message: `'${file.uri}' is out of sync.`,
|
|
300
|
-
data: { file, stat }
|
|
301
|
-
}));
|
|
302
43
|
}
|
|
@@ -42,11 +42,11 @@ export interface RemoteFileSystemServer extends JsonRpcServer<RemoteFileSystemCl
|
|
|
42
42
|
fsPath(resource: string): Promise<string>;
|
|
43
43
|
open(resource: string, opts: FileOpenOptions): Promise<number>;
|
|
44
44
|
close(fd: number): Promise<void>;
|
|
45
|
-
read(fd: number, pos: number, length: number): Promise<{ bytes:
|
|
45
|
+
read(fd: number, pos: number, length: number): Promise<{ bytes: number[]; bytesRead: number; }>;
|
|
46
46
|
readFileStream(resource: string, opts: FileReadStreamOptions, token: CancellationToken): Promise<number>;
|
|
47
|
-
readFile(resource: string): Promise<
|
|
48
|
-
write(fd: number, pos: number, data:
|
|
49
|
-
writeFile(resource: string, content:
|
|
47
|
+
readFile(resource: string): Promise<number[]>;
|
|
48
|
+
write(fd: number, pos: number, data: number[], offset: number, length: number): Promise<number>;
|
|
49
|
+
writeFile(resource: string, content: number[], opts: FileWriteOptions): Promise<void>;
|
|
50
50
|
delete(resource: string, opts: FileDeleteOptions): Promise<void>;
|
|
51
51
|
mkdir(resource: string): Promise<void>;
|
|
52
52
|
readdir(resource: string): Promise<[string, FileType][]>;
|
|
@@ -70,7 +70,7 @@ export interface RemoteFileSystemClient {
|
|
|
70
70
|
notifyDidChangeFile(event: { changes: RemoteFileChange[] }): void;
|
|
71
71
|
notifyFileWatchError(): void;
|
|
72
72
|
notifyDidChangeCapabilities(capabilities: FileSystemProviderCapabilities): void;
|
|
73
|
-
onFileStreamData(handle: number, data:
|
|
73
|
+
onFileStreamData(handle: number, data: number[]): void;
|
|
74
74
|
onFileStreamEnd(handle: number, error: RemoteFileStreamError | undefined): void;
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -169,7 +169,7 @@ export class RemoteFileSystemProvider implements Required<FileSystemProvider>, D
|
|
|
169
169
|
this.onFileWatchErrorEmitter.fire();
|
|
170
170
|
},
|
|
171
171
|
notifyDidChangeCapabilities: capabilities => this.setCapabilities(capabilities),
|
|
172
|
-
onFileStreamData: (handle, data) => this.onFileStreamDataEmitter.fire([handle, data]),
|
|
172
|
+
onFileStreamData: (handle, data) => this.onFileStreamDataEmitter.fire([handle, Uint8Array.from(data)]),
|
|
173
173
|
onFileStreamEnd: (handle, error) => this.onFileStreamEndEmitter.fire([handle, error])
|
|
174
174
|
});
|
|
175
175
|
const onInitialized = this.server.onDidOpenConnection(() => {
|
|
@@ -224,7 +224,7 @@ export class RemoteFileSystemProvider implements Required<FileSystemProvider>, D
|
|
|
224
224
|
|
|
225
225
|
async readFile(resource: URI): Promise<Uint8Array> {
|
|
226
226
|
const bytes = await this.server.readFile(resource.toString());
|
|
227
|
-
return bytes;
|
|
227
|
+
return Uint8Array.from(bytes);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
readFileStream(resource: URI, opts: FileReadStreamOptions, token: CancellationToken): ReadableStreamEvents<Uint8Array> {
|
|
@@ -264,11 +264,11 @@ export class RemoteFileSystemProvider implements Required<FileSystemProvider>, D
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
write(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> {
|
|
267
|
-
return this.server.write(fd, pos, data, offset, length);
|
|
267
|
+
return this.server.write(fd, pos, [...data.values()], offset, length);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
writeFile(resource: URI, content: Uint8Array, opts: FileWriteOptions): Promise<void> {
|
|
271
|
-
return this.server.writeFile(resource.toString(), content, opts);
|
|
271
|
+
return this.server.writeFile(resource.toString(), [...content.values()], opts);
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
delete(resource: URI, opts: FileDeleteOptions): Promise<void> {
|
|
@@ -412,33 +412,34 @@ export class FileSystemProviderServer implements RemoteFileSystemServer {
|
|
|
412
412
|
throw new Error('not supported');
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
async read(fd: number, pos: number, length: number): Promise<{ bytes:
|
|
415
|
+
async read(fd: number, pos: number, length: number): Promise<{ bytes: number[]; bytesRead: number; }> {
|
|
416
416
|
if (hasOpenReadWriteCloseCapability(this.provider)) {
|
|
417
417
|
const buffer = BinaryBuffer.alloc(this.BUFFER_SIZE);
|
|
418
418
|
const bytes = buffer.buffer;
|
|
419
419
|
const bytesRead = await this.provider.read(fd, pos, bytes, 0, length);
|
|
420
|
-
return { bytes, bytesRead };
|
|
420
|
+
return { bytes: [...bytes.values()], bytesRead };
|
|
421
421
|
}
|
|
422
422
|
throw new Error('not supported');
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
write(fd: number, pos: number, data:
|
|
425
|
+
write(fd: number, pos: number, data: number[], offset: number, length: number): Promise<number> {
|
|
426
426
|
if (hasOpenReadWriteCloseCapability(this.provider)) {
|
|
427
|
-
return this.provider.write(fd, pos, data, offset, length);
|
|
427
|
+
return this.provider.write(fd, pos, Uint8Array.from(data), offset, length);
|
|
428
428
|
}
|
|
429
429
|
throw new Error('not supported');
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
async readFile(resource: string): Promise<
|
|
432
|
+
async readFile(resource: string): Promise<number[]> {
|
|
433
433
|
if (hasReadWriteCapability(this.provider)) {
|
|
434
|
-
|
|
434
|
+
const buffer = await this.provider.readFile(new URI(resource));
|
|
435
|
+
return [...buffer.values()];
|
|
435
436
|
}
|
|
436
437
|
throw new Error('not supported');
|
|
437
438
|
}
|
|
438
439
|
|
|
439
|
-
writeFile(resource: string, content:
|
|
440
|
+
writeFile(resource: string, content: number[], opts: FileWriteOptions): Promise<void> {
|
|
440
441
|
if (hasReadWriteCapability(this.provider)) {
|
|
441
|
-
return this.provider.writeFile(new URI(resource), content, opts);
|
|
442
|
+
return this.provider.writeFile(new URI(resource), Uint8Array.from(content), opts);
|
|
442
443
|
}
|
|
443
444
|
throw new Error('not supported');
|
|
444
445
|
}
|
|
@@ -496,7 +497,7 @@ export class FileSystemProviderServer implements RemoteFileSystemServer {
|
|
|
496
497
|
if (hasFileReadStreamCapability(this.provider)) {
|
|
497
498
|
const handle = this.readFileStreamSeq++;
|
|
498
499
|
const stream = this.provider.readFileStream(new URI(resource), opts, token);
|
|
499
|
-
stream.on('data', data => this.client?.onFileStreamData(handle, data));
|
|
500
|
+
stream.on('data', data => this.client?.onFileStreamData(handle, [...data.values()]));
|
|
500
501
|
stream.on('error', error => {
|
|
501
502
|
const code = error instanceof FileSystemProviderError ? error.code : undefined;
|
|
502
503
|
const { name, message, stack } = error;
|