@bytecodealliance/preview2-shim 0.18.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/cli.d.ts +16 -0
- package/dist/browser/cli.js +109 -0
- package/dist/browser/clocks.d.ts +3 -0
- package/dist/browser/clocks.js +36 -0
- package/dist/browser/config.d.ts +2 -0
- package/{lib → dist}/browser/config.js +2 -4
- package/dist/browser/environment.d.ts +5 -0
- package/dist/browser/environment.js +24 -0
- package/dist/browser/filesystem.d.ts +132 -0
- package/dist/browser/filesystem.js +464 -0
- package/dist/browser/http.d.ts +4 -0
- package/dist/browser/http.js +643 -0
- package/dist/browser/index.d.ts +7 -0
- package/dist/browser/index.js +7 -0
- package/dist/browser/io.d.ts +58 -0
- package/dist/browser/io.js +205 -0
- package/dist/browser/random.d.ts +4 -0
- package/dist/browser/random.js +49 -0
- package/dist/browser/sockets.d.ts +8 -0
- package/dist/browser/sockets.js +66 -0
- package/dist/common/instantiation.d.ts +97 -0
- package/dist/common/instantiation.js +227 -0
- package/dist/io/calls.d.ts +91 -0
- package/{lib → dist}/io/calls.js +4 -19
- package/dist/io/worker-http.d.ts +17 -0
- package/dist/io/worker-http.js +192 -0
- package/dist/io/worker-io.d.ts +84 -0
- package/dist/io/worker-io.js +375 -0
- package/dist/io/worker-socket-tcp.d.ts +34 -0
- package/dist/io/worker-socket-tcp.js +251 -0
- package/dist/io/worker-socket-udp.d.ts +54 -0
- package/dist/io/worker-socket-udp.js +492 -0
- package/dist/io/worker-sockets.d.ts +32 -0
- package/dist/io/worker-sockets.js +265 -0
- package/dist/io/worker-thread.d.ts +73 -0
- package/dist/io/worker-thread.js +791 -0
- package/dist/nodejs/cli.d.ts +30 -0
- package/dist/nodejs/cli.js +86 -0
- package/dist/nodejs/clocks.d.ts +3 -0
- package/dist/nodejs/clocks.js +61 -0
- package/dist/nodejs/filesystem.d.ts +113 -0
- package/dist/nodejs/filesystem.js +758 -0
- package/dist/nodejs/http.d.ts +82 -0
- package/dist/nodejs/http.js +674 -0
- package/dist/nodejs/index.d.ts +7 -0
- package/dist/nodejs/index.js +7 -0
- package/dist/nodejs/io.d.ts +1 -0
- package/dist/nodejs/io.js +1 -0
- package/dist/nodejs/random.d.ts +4 -0
- package/dist/nodejs/random.js +42 -0
- package/dist/nodejs/sockets.d.ts +21 -0
- package/dist/nodejs/sockets.js +482 -0
- package/dist/synckit/index.d.ts +2 -0
- package/dist/synckit/index.js +117 -0
- package/package.json +26 -13
- package/types/instantiation.d.ts +7 -7
- package/lib/browser/cli.js +0 -135
- package/lib/browser/clocks.js +0 -39
- package/lib/browser/environment.js +0 -29
- package/lib/browser/filesystem.js +0 -503
- package/lib/browser/http.js +0 -707
- package/lib/browser/index.js +0 -9
- package/lib/browser/io.js +0 -262
- package/lib/browser/random.js +0 -56
- package/lib/browser/sockets.js +0 -88
- package/lib/common/instantiation.js +0 -253
- package/lib/io/worker-http.js +0 -206
- package/lib/io/worker-io.js +0 -468
- package/lib/io/worker-socket-tcp.js +0 -331
- package/lib/io/worker-socket-udp.js +0 -587
- package/lib/io/worker-sockets.js +0 -364
- package/lib/io/worker-thread.js +0 -1051
- package/lib/nodejs/cli.js +0 -109
- package/lib/nodejs/clocks.js +0 -67
- package/lib/nodejs/filesystem.js +0 -829
- package/lib/nodejs/http.js +0 -764
- package/lib/nodejs/index.js +0 -9
- package/lib/nodejs/io.js +0 -1
- package/lib/nodejs/random.js +0 -49
- package/lib/nodejs/sockets.js +0 -565
- package/lib/synckit/index.js +0 -127
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
import { streams } from "./io.js";
|
|
2
|
-
import { environment } from "./environment.js";
|
|
3
|
-
|
|
4
|
-
import { _setCwd, _getCwd } from "./config.js";
|
|
5
|
-
export { _setCwd } from "./config.js";
|
|
6
|
-
|
|
7
|
-
const { InputStream, OutputStream } = streams;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {Object} FileDataEntry
|
|
11
|
-
* @property {Record<string, FileDataEntry>} [dir] - Directory contents (present for directories)
|
|
12
|
-
* @property {Uint8Array|string} [source] - File contents (present for files)
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {FileDataEntry} FileData
|
|
17
|
-
* Root file data structure representing a filesystem tree.
|
|
18
|
-
* Each entry is either a directory (has `dir` property) or a file (has `source` property).
|
|
19
|
-
* @example
|
|
20
|
-
* // A simple filesystem with one directory containing one file:
|
|
21
|
-
* const fileData = {
|
|
22
|
-
* dir: {
|
|
23
|
-
* 'myfile.txt': { source: new Uint8Array([72, 101, 108, 108, 111]) }
|
|
24
|
-
* }
|
|
25
|
-
* };
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
export function _setFileData(fileData) {
|
|
29
|
-
_fileData = fileData;
|
|
30
|
-
_rootPreopen[0] = new Descriptor(fileData);
|
|
31
|
-
const cwd = environment.initialCwd();
|
|
32
|
-
_setCwd(cwd || "/");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function _getFileData() {
|
|
36
|
-
return JSON.stringify(_fileData);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let _fileData = { dir: {} };
|
|
40
|
-
|
|
41
|
-
const timeZero = {
|
|
42
|
-
seconds: BigInt(0),
|
|
43
|
-
nanoseconds: 0,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/** Coerce the given object to a safe integer */
|
|
47
|
-
function coerceToSafeIntegerNumber(obj) {
|
|
48
|
-
let n;
|
|
49
|
-
if (typeof obj === "number") {
|
|
50
|
-
n = obj;
|
|
51
|
-
} else if (typeof obj == "bigint") {
|
|
52
|
-
n = Number(obj);
|
|
53
|
-
} else {
|
|
54
|
-
throw new TypeError(`unexpected non-numeric type: ${obj}`);
|
|
55
|
-
}
|
|
56
|
-
if (n > Number.MAX_SAFE_INTEGER) {
|
|
57
|
-
throw new TypeError(`excessively large number: ${n}`);
|
|
58
|
-
}
|
|
59
|
-
return n;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function getChildEntry(parentEntry, subpath, openFlags) {
|
|
63
|
-
if (subpath === "." && _rootPreopen && descriptorGetEntry(_rootPreopen[0]) === parentEntry) {
|
|
64
|
-
subpath = _getCwd();
|
|
65
|
-
if (subpath.startsWith("/") && subpath !== "/") {
|
|
66
|
-
subpath = subpath.slice(1);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
let entry = parentEntry;
|
|
70
|
-
let segmentIdx;
|
|
71
|
-
do {
|
|
72
|
-
if (!entry || !entry.dir) {
|
|
73
|
-
throw "not-directory";
|
|
74
|
-
}
|
|
75
|
-
segmentIdx = subpath.indexOf("/");
|
|
76
|
-
const segment = segmentIdx === -1 ? subpath : subpath.slice(0, segmentIdx);
|
|
77
|
-
if (segment === "..") {
|
|
78
|
-
throw "no-entry";
|
|
79
|
-
}
|
|
80
|
-
if (segment === "." || segment === "") {
|
|
81
|
-
} else if (!entry.dir[segment] && openFlags.create) {
|
|
82
|
-
entry = entry.dir[segment] = openFlags.directory
|
|
83
|
-
? { dir: {} }
|
|
84
|
-
: { source: new Uint8Array([]) };
|
|
85
|
-
} else {
|
|
86
|
-
entry = entry.dir[segment];
|
|
87
|
-
}
|
|
88
|
-
subpath = subpath.slice(segmentIdx + 1);
|
|
89
|
-
} while (segmentIdx !== -1);
|
|
90
|
-
if (!entry) {
|
|
91
|
-
throw "no-entry";
|
|
92
|
-
}
|
|
93
|
-
return entry;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function getSource(fileEntry) {
|
|
97
|
-
if (typeof fileEntry.source === "string") {
|
|
98
|
-
fileEntry.source = new TextEncoder().encode(fileEntry.source);
|
|
99
|
-
}
|
|
100
|
-
return fileEntry.source;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
class DirectoryEntryStream {
|
|
104
|
-
constructor(entries) {
|
|
105
|
-
this.idx = 0;
|
|
106
|
-
this.entries = entries;
|
|
107
|
-
}
|
|
108
|
-
readDirectoryEntry() {
|
|
109
|
-
if (this.idx === this.entries.length) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
const [name, entry] = this.entries[this.idx];
|
|
113
|
-
this.idx += 1;
|
|
114
|
-
return {
|
|
115
|
-
name,
|
|
116
|
-
type: entry.dir ? "directory" : "regular-file",
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
class Descriptor {
|
|
122
|
-
#stream;
|
|
123
|
-
#entry;
|
|
124
|
-
#mtime = 0;
|
|
125
|
-
|
|
126
|
-
_getEntry(descriptor) {
|
|
127
|
-
return descriptor.#entry;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
constructor(entry, isStream) {
|
|
131
|
-
if (isStream) {
|
|
132
|
-
this.#stream = entry;
|
|
133
|
-
} else {
|
|
134
|
-
this.#entry = entry;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
readViaStream(_offset) {
|
|
139
|
-
const source = getSource(this.#entry);
|
|
140
|
-
let offset = Number(_offset);
|
|
141
|
-
return new InputStream({
|
|
142
|
-
blockingRead(len) {
|
|
143
|
-
if (offset === source.byteLength) {
|
|
144
|
-
throw { tag: "closed" };
|
|
145
|
-
}
|
|
146
|
-
const bytes = source.slice(offset, offset + Number(len));
|
|
147
|
-
offset += bytes.byteLength;
|
|
148
|
-
return bytes;
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
writeViaStream(_offset) {
|
|
154
|
-
const entry = this.#entry;
|
|
155
|
-
let offset = Number(_offset);
|
|
156
|
-
return new OutputStream({
|
|
157
|
-
write(buf) {
|
|
158
|
-
const newSource = new Uint8Array(buf.byteLength + entry.source.byteLength);
|
|
159
|
-
newSource.set(entry.source, 0);
|
|
160
|
-
newSource.set(buf, offset);
|
|
161
|
-
offset += buf.byteLength;
|
|
162
|
-
entry.source = newSource;
|
|
163
|
-
return buf.byteLength;
|
|
164
|
-
},
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
appendViaStream() {
|
|
169
|
-
console.log(`[filesystem] APPEND STREAM`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
advise(descriptor, offset, length, advice) {
|
|
173
|
-
console.log(`[filesystem] ADVISE`, descriptor, offset, length, advice);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
syncData() {
|
|
177
|
-
console.log(`[filesystem] SYNC DATA`);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
getFlags() {
|
|
181
|
-
console.log(`[filesystem] FLAGS FOR`);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
getType() {
|
|
185
|
-
if (this.#stream) {
|
|
186
|
-
return "fifo";
|
|
187
|
-
}
|
|
188
|
-
if (this.#entry.dir) {
|
|
189
|
-
return "directory";
|
|
190
|
-
}
|
|
191
|
-
if (this.#entry.source) {
|
|
192
|
-
return "regular-file";
|
|
193
|
-
}
|
|
194
|
-
return "unknown";
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
setSize(size) {
|
|
198
|
-
console.log(`[filesystem] SET SIZE`, size);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
setTimes(dataAccessTimestamp, dataModificationTimestamp) {
|
|
202
|
-
console.log(`[filesystem] SET TIMES`, dataAccessTimestamp, dataModificationTimestamp);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
read(length, offset) {
|
|
206
|
-
const source = getSource(this.#entry);
|
|
207
|
-
const off = coerceToSafeIntegerNumber(offset);
|
|
208
|
-
const len = coerceToSafeIntegerNumber(length);
|
|
209
|
-
return [source.slice(off, off + len), off + len >= source.byteLength];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
write(buffer, offset) {
|
|
213
|
-
if (offset !== 0) {
|
|
214
|
-
throw "invalid-seek";
|
|
215
|
-
}
|
|
216
|
-
this.#entry.source = buffer;
|
|
217
|
-
return buffer.byteLength;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
readDirectory() {
|
|
221
|
-
if (!this.#entry?.dir) {
|
|
222
|
-
throw "bad-descriptor";
|
|
223
|
-
}
|
|
224
|
-
return new DirectoryEntryStream(
|
|
225
|
-
Object.entries(this.#entry.dir).sort(([a], [b]) => (a > b ? 1 : -1)),
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
sync() {
|
|
230
|
-
console.log(`[filesystem] SYNC`);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
createDirectoryAt(path) {
|
|
234
|
-
const entry = getChildEntry(this.#entry, path, {
|
|
235
|
-
create: true,
|
|
236
|
-
directory: true,
|
|
237
|
-
});
|
|
238
|
-
if (entry.source) {
|
|
239
|
-
throw "exist";
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
stat() {
|
|
244
|
-
let type = "unknown",
|
|
245
|
-
size = BigInt(0);
|
|
246
|
-
if (this.#entry.source) {
|
|
247
|
-
type = "regular-file";
|
|
248
|
-
const source = getSource(this.#entry);
|
|
249
|
-
size = BigInt(source.byteLength);
|
|
250
|
-
} else if (this.#entry.dir) {
|
|
251
|
-
type = "directory";
|
|
252
|
-
}
|
|
253
|
-
return {
|
|
254
|
-
type,
|
|
255
|
-
linkCount: BigInt(0),
|
|
256
|
-
size,
|
|
257
|
-
dataAccessTimestamp: timeZero,
|
|
258
|
-
dataModificationTimestamp: timeZero,
|
|
259
|
-
statusChangeTimestamp: timeZero,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
statAt(_pathFlags, path) {
|
|
264
|
-
const entry = getChildEntry(this.#entry, path, {
|
|
265
|
-
create: false,
|
|
266
|
-
directory: false,
|
|
267
|
-
});
|
|
268
|
-
let type = "unknown",
|
|
269
|
-
size = BigInt(0);
|
|
270
|
-
if (entry.source) {
|
|
271
|
-
type = "regular-file";
|
|
272
|
-
const source = getSource(entry);
|
|
273
|
-
size = BigInt(source.byteLength);
|
|
274
|
-
} else if (entry.dir) {
|
|
275
|
-
type = "directory";
|
|
276
|
-
}
|
|
277
|
-
return {
|
|
278
|
-
type,
|
|
279
|
-
linkCount: BigInt(0),
|
|
280
|
-
size,
|
|
281
|
-
dataAccessTimestamp: timeZero,
|
|
282
|
-
dataModificationTimestamp: timeZero,
|
|
283
|
-
statusChangeTimestamp: timeZero,
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
setTimesAt() {
|
|
288
|
-
console.log(`[filesystem] SET TIMES AT`);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
linkAt() {
|
|
292
|
-
console.log(`[filesystem] LINK AT`);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
openAt(_pathFlags, path, openFlags, _descriptorFlags, _modes) {
|
|
296
|
-
const childEntry = getChildEntry(this.#entry, path, openFlags);
|
|
297
|
-
return new Descriptor(childEntry);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
readlinkAt() {
|
|
301
|
-
console.log(`[filesystem] READLINK AT`);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
removeDirectoryAt() {
|
|
305
|
-
console.log(`[filesystem] REMOVE DIR AT`);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
renameAt() {
|
|
309
|
-
console.log(`[filesystem] RENAME AT`);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
symlinkAt() {
|
|
313
|
-
console.log(`[filesystem] SYMLINK AT`);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
unlinkFileAt() {
|
|
317
|
-
console.log(`[filesystem] UNLINK FILE AT`);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
isSameObject(other) {
|
|
321
|
-
return other === this;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
metadataHash() {
|
|
325
|
-
let upper = BigInt(0);
|
|
326
|
-
upper += BigInt(this.#mtime);
|
|
327
|
-
return { upper, lower: BigInt(0) };
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
metadataHashAt(_pathFlags, _path) {
|
|
331
|
-
let upper = BigInt(0);
|
|
332
|
-
upper += BigInt(this.#mtime);
|
|
333
|
-
return { upper, lower: BigInt(0) };
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
const descriptorGetEntry = Descriptor.prototype._getEntry;
|
|
337
|
-
delete Descriptor.prototype._getEntry;
|
|
338
|
-
|
|
339
|
-
let _preopens = [[new Descriptor(_fileData), "/"]],
|
|
340
|
-
_rootPreopen = _preopens[0];
|
|
341
|
-
|
|
342
|
-
export const preopens = {
|
|
343
|
-
getDirectories() {
|
|
344
|
-
return _preopens;
|
|
345
|
-
},
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Replace all preopens with the given set.
|
|
350
|
-
* @param {Record<string, FileData>} preopensConfig - Map of virtual paths to file data entries
|
|
351
|
-
*/
|
|
352
|
-
export function _setPreopens(preopensConfig) {
|
|
353
|
-
_preopens = [];
|
|
354
|
-
for (const [virtualPath, fileData] of Object.entries(preopensConfig)) {
|
|
355
|
-
_addPreopen(virtualPath, fileData);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Add a single preopen mapping.
|
|
361
|
-
* @param {string} virtualPath - The virtual path visible to the guest
|
|
362
|
-
* @param {FileData} fileData - The file data object representing the directory
|
|
363
|
-
*/
|
|
364
|
-
export function _addPreopen(virtualPath, fileData) {
|
|
365
|
-
const descriptor = new Descriptor(fileData);
|
|
366
|
-
_preopens.push([descriptor, virtualPath]);
|
|
367
|
-
if (virtualPath === "/") {
|
|
368
|
-
_rootPreopen = [descriptor, virtualPath];
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Clear all preopens, giving the guest no filesystem access.
|
|
374
|
-
*
|
|
375
|
-
* This functionality exists mostly to maintain backwards compatibility. Prefer setting preopens
|
|
376
|
-
* via `WASIShim` rather than making top level changes to preopens using these functions.
|
|
377
|
-
*/
|
|
378
|
-
export function _clearPreopens() {
|
|
379
|
-
_preopens = [];
|
|
380
|
-
_rootPreopen = null;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Get current preopens configuration.
|
|
385
|
-
* @returns {Array<[Descriptor, string]>} Array of [descriptor, virtualPath] pairs
|
|
386
|
-
*/
|
|
387
|
-
export function _getPreopens() {
|
|
388
|
-
return [..._preopens];
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Create a preopen descriptor for file data.
|
|
393
|
-
* This is used internally to create isolated preopen instances.
|
|
394
|
-
* @param {FileData} fileData - The file data object representing the directory
|
|
395
|
-
* @returns {Descriptor} A preopen descriptor
|
|
396
|
-
*/
|
|
397
|
-
export function _createPreopenDescriptor(fileData) {
|
|
398
|
-
return new Descriptor(fileData);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
export const types = {
|
|
402
|
-
Descriptor,
|
|
403
|
-
DirectoryEntryStream,
|
|
404
|
-
filesystemErrorCode(err) {
|
|
405
|
-
return convertFsError(err.payload);
|
|
406
|
-
},
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
function convertFsError(e) {
|
|
410
|
-
switch (e.code) {
|
|
411
|
-
case "EACCES":
|
|
412
|
-
return "access";
|
|
413
|
-
case "EAGAIN":
|
|
414
|
-
case "EWOULDBLOCK":
|
|
415
|
-
return "would-block";
|
|
416
|
-
case "EALREADY":
|
|
417
|
-
return "already";
|
|
418
|
-
case "EBADF":
|
|
419
|
-
return "bad-descriptor";
|
|
420
|
-
case "EBUSY":
|
|
421
|
-
return "busy";
|
|
422
|
-
case "EDEADLK":
|
|
423
|
-
return "deadlock";
|
|
424
|
-
case "EDQUOT":
|
|
425
|
-
return "quota";
|
|
426
|
-
case "EEXIST":
|
|
427
|
-
return "exist";
|
|
428
|
-
case "EFBIG":
|
|
429
|
-
return "file-too-large";
|
|
430
|
-
case "EILSEQ":
|
|
431
|
-
return "illegal-byte-sequence";
|
|
432
|
-
case "EINPROGRESS":
|
|
433
|
-
return "in-progress";
|
|
434
|
-
case "EINTR":
|
|
435
|
-
return "interrupted";
|
|
436
|
-
case "EINVAL":
|
|
437
|
-
return "invalid";
|
|
438
|
-
case "EIO":
|
|
439
|
-
return "io";
|
|
440
|
-
case "EISDIR":
|
|
441
|
-
return "is-directory";
|
|
442
|
-
case "ELOOP":
|
|
443
|
-
return "loop";
|
|
444
|
-
case "EMLINK":
|
|
445
|
-
return "too-many-links";
|
|
446
|
-
case "EMSGSIZE":
|
|
447
|
-
return "message-size";
|
|
448
|
-
case "ENAMETOOLONG":
|
|
449
|
-
return "name-too-long";
|
|
450
|
-
case "ENODEV":
|
|
451
|
-
return "no-device";
|
|
452
|
-
case "ENOENT":
|
|
453
|
-
return "no-entry";
|
|
454
|
-
case "ENOLCK":
|
|
455
|
-
return "no-lock";
|
|
456
|
-
case "ENOMEM":
|
|
457
|
-
return "insufficient-memory";
|
|
458
|
-
case "ENOSPC":
|
|
459
|
-
return "insufficient-space";
|
|
460
|
-
case "ENOTDIR":
|
|
461
|
-
case "ERR_FS_EISDIR":
|
|
462
|
-
return "not-directory";
|
|
463
|
-
case "ENOTEMPTY":
|
|
464
|
-
return "not-empty";
|
|
465
|
-
case "ENOTRECOVERABLE":
|
|
466
|
-
return "not-recoverable";
|
|
467
|
-
case "ENOTSUP":
|
|
468
|
-
return "unsupported";
|
|
469
|
-
case "ENOTTY":
|
|
470
|
-
return "no-tty";
|
|
471
|
-
// windows gives this error for badly structured `//` reads
|
|
472
|
-
// this seems like a slightly better error than unknown given
|
|
473
|
-
// that it's a common footgun
|
|
474
|
-
case -4094:
|
|
475
|
-
case "ENXIO":
|
|
476
|
-
return "no-such-device";
|
|
477
|
-
case "EOVERFLOW":
|
|
478
|
-
return "overflow";
|
|
479
|
-
case "EPERM":
|
|
480
|
-
return "not-permitted";
|
|
481
|
-
case "EPIPE":
|
|
482
|
-
return "pipe";
|
|
483
|
-
case "EROFS":
|
|
484
|
-
return "read-only";
|
|
485
|
-
case "ESPIPE":
|
|
486
|
-
return "invalid-seek";
|
|
487
|
-
case "ETXTBSY":
|
|
488
|
-
return "text-file-busy";
|
|
489
|
-
case "EXDEV":
|
|
490
|
-
return "cross-device";
|
|
491
|
-
case "UNKNOWN":
|
|
492
|
-
switch (e.errno) {
|
|
493
|
-
case -4094:
|
|
494
|
-
return "no-such-device";
|
|
495
|
-
default:
|
|
496
|
-
throw e;
|
|
497
|
-
}
|
|
498
|
-
default:
|
|
499
|
-
throw e;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
export { types as filesystemTypes };
|