@zenfs/core 0.0.12 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ApiError.d.ts +1 -1
- package/dist/ApiError.js +17 -16
- package/dist/backends/AsyncMirror.js +40 -46
- package/dist/backends/AsyncStore.js +326 -383
- package/dist/backends/FolderAdapter.js +8 -19
- package/dist/backends/Locked.js +91 -137
- package/dist/backends/OverlayFS.js +234 -279
- package/dist/backends/SyncStore.js +2 -2
- package/dist/backends/backend.d.ts +6 -6
- package/dist/browser.min.js +23 -6
- package/dist/browser.min.js.map +4 -4
- package/dist/emulation/callbacks.d.ts +109 -72
- package/dist/emulation/callbacks.js +40 -47
- package/dist/emulation/dir.d.ts +55 -0
- package/dist/emulation/dir.js +104 -0
- package/dist/emulation/fs.d.ts +1 -2
- package/dist/emulation/fs.js +0 -1
- package/dist/emulation/index.d.ts +3 -0
- package/dist/emulation/index.js +3 -0
- package/dist/emulation/promises.d.ts +71 -50
- package/dist/emulation/promises.js +243 -342
- package/dist/emulation/shared.d.ts +14 -0
- package/dist/emulation/shared.js +4 -3
- package/dist/emulation/streams.d.ts +102 -0
- package/dist/emulation/streams.js +55 -0
- package/dist/emulation/sync.d.ts +81 -52
- package/dist/emulation/sync.js +98 -65
- package/dist/file.d.ts +11 -5
- package/dist/file.js +79 -76
- package/dist/filesystem.d.ts +3 -3
- package/dist/filesystem.js +181 -262
- package/dist/index.d.ts +3 -3
- package/dist/index.js +39 -53
- package/dist/stats.d.ts +80 -27
- package/dist/stats.js +142 -93
- package/dist/utils.d.ts +2 -6
- package/dist/utils.js +79 -78
- package/package.json +4 -2
- package/readme.md +2 -40
package/dist/filesystem.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
// disable no-unused-vars since BaseFileSystem uses them a lot
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
3
|
var _a;
|
|
13
4
|
import { ApiError, ErrorCode } from './ApiError.js';
|
|
14
5
|
import { FileFlag, ActionType } from './file.js';
|
|
@@ -60,83 +51,71 @@ export class BaseFileSystem extends FileSystem {
|
|
|
60
51
|
* @param p The path to open.
|
|
61
52
|
* @param flag The flag to use when opening the file.
|
|
62
53
|
*/
|
|
63
|
-
openFile(p, flag, cred) {
|
|
64
|
-
|
|
65
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
66
|
-
});
|
|
54
|
+
async openFile(p, flag, cred) {
|
|
55
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
67
56
|
}
|
|
68
57
|
/**
|
|
69
58
|
* Create the file at path p with the given mode. Then, open it with the given
|
|
70
59
|
* flag.
|
|
71
60
|
*/
|
|
72
|
-
createFile(p, flag, mode, cred) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return this.openFile(p, flag, cred);
|
|
97
|
-
default:
|
|
98
|
-
throw new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');
|
|
99
|
-
}
|
|
100
|
-
// File exists.
|
|
61
|
+
async createFile(p, flag, mode, cred) {
|
|
62
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
63
|
+
}
|
|
64
|
+
async open(p, flag, mode, cred) {
|
|
65
|
+
try {
|
|
66
|
+
const stats = await this.stat(p, cred);
|
|
67
|
+
switch (flag.pathExistsAction()) {
|
|
68
|
+
case ActionType.THROW_EXCEPTION:
|
|
69
|
+
throw ApiError.EEXIST(p);
|
|
70
|
+
case ActionType.TRUNCATE_FILE:
|
|
71
|
+
// NOTE: In a previous implementation, we deleted the file and
|
|
72
|
+
// re-created it. However, this created a race condition if another
|
|
73
|
+
// asynchronous request was trying to read the file, as the file
|
|
74
|
+
// would not exist for a small period of time.
|
|
75
|
+
const fd = await this.openFile(p, flag, cred);
|
|
76
|
+
if (!fd)
|
|
77
|
+
throw new Error('BFS has reached an impossible code path; please file a bug.');
|
|
78
|
+
await fd.truncate(0);
|
|
79
|
+
await fd.sync();
|
|
80
|
+
return fd;
|
|
81
|
+
case ActionType.NOP:
|
|
82
|
+
return this.openFile(p, flag, cred);
|
|
83
|
+
default:
|
|
84
|
+
throw new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');
|
|
101
85
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
86
|
+
// File exists.
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
// File does not exist.
|
|
90
|
+
switch (flag.pathNotExistsAction()) {
|
|
91
|
+
case ActionType.CREATE_FILE:
|
|
92
|
+
// Ensure parent exists.
|
|
93
|
+
const parentStats = await this.stat(path.dirname(p), cred);
|
|
94
|
+
if (parentStats && !parentStats.isDirectory()) {
|
|
95
|
+
throw ApiError.ENOTDIR(path.dirname(p));
|
|
96
|
+
}
|
|
97
|
+
return this.createFile(p, flag, mode, cred);
|
|
98
|
+
case ActionType.THROW_EXCEPTION:
|
|
99
|
+
throw ApiError.ENOENT(p);
|
|
100
|
+
default:
|
|
101
|
+
throw new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');
|
|
117
102
|
}
|
|
118
|
-
}
|
|
103
|
+
}
|
|
119
104
|
}
|
|
120
|
-
access(p, mode, cred) {
|
|
121
|
-
|
|
122
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
123
|
-
});
|
|
105
|
+
async access(p, mode, cred) {
|
|
106
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
124
107
|
}
|
|
125
108
|
accessSync(p, mode, cred) {
|
|
126
109
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
127
110
|
}
|
|
128
|
-
rename(oldPath, newPath, cred) {
|
|
129
|
-
|
|
130
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
131
|
-
});
|
|
111
|
+
async rename(oldPath, newPath, cred) {
|
|
112
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
132
113
|
}
|
|
133
114
|
renameSync(oldPath, newPath, cred) {
|
|
134
115
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
135
116
|
}
|
|
136
|
-
stat(p, cred) {
|
|
137
|
-
|
|
138
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
139
|
-
});
|
|
117
|
+
async stat(p, cred) {
|
|
118
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
140
119
|
}
|
|
141
120
|
statSync(p, cred) {
|
|
142
121
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
@@ -200,48 +179,38 @@ export class BaseFileSystem extends FileSystem {
|
|
|
200
179
|
throw new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');
|
|
201
180
|
}
|
|
202
181
|
}
|
|
203
|
-
unlink(p, cred) {
|
|
204
|
-
|
|
205
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
206
|
-
});
|
|
182
|
+
async unlink(p, cred) {
|
|
183
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
207
184
|
}
|
|
208
185
|
unlinkSync(p, cred) {
|
|
209
186
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
210
187
|
}
|
|
211
|
-
rmdir(p, cred) {
|
|
212
|
-
|
|
213
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
214
|
-
});
|
|
188
|
+
async rmdir(p, cred) {
|
|
189
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
215
190
|
}
|
|
216
191
|
rmdirSync(p, cred) {
|
|
217
192
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
218
193
|
}
|
|
219
|
-
mkdir(p, mode, cred) {
|
|
220
|
-
|
|
221
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
222
|
-
});
|
|
194
|
+
async mkdir(p, mode, cred) {
|
|
195
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
223
196
|
}
|
|
224
197
|
mkdirSync(p, mode, cred) {
|
|
225
198
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
226
199
|
}
|
|
227
|
-
readdir(p, cred) {
|
|
228
|
-
|
|
229
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
230
|
-
});
|
|
200
|
+
async readdir(p, cred) {
|
|
201
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
231
202
|
}
|
|
232
203
|
readdirSync(p, cred) {
|
|
233
204
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
234
205
|
}
|
|
235
|
-
exists(p, cred) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
});
|
|
206
|
+
async exists(p, cred) {
|
|
207
|
+
try {
|
|
208
|
+
await this.stat(p, cred);
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
245
214
|
}
|
|
246
215
|
existsSync(p, cred) {
|
|
247
216
|
try {
|
|
@@ -252,27 +221,25 @@ export class BaseFileSystem extends FileSystem {
|
|
|
252
221
|
return false;
|
|
253
222
|
}
|
|
254
223
|
}
|
|
255
|
-
realpath(p, cred) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
splitPath[i] = path.join(...addPaths);
|
|
265
|
-
}
|
|
266
|
-
return splitPath.join(path.sep);
|
|
224
|
+
async realpath(p, cred) {
|
|
225
|
+
if (this.metadata.supportsLinks) {
|
|
226
|
+
// The path could contain symlinks. Split up the path,
|
|
227
|
+
// resolve any symlinks, return the resolved string.
|
|
228
|
+
const splitPath = p.split(path.sep);
|
|
229
|
+
// TODO: Simpler to just pass through file, find sep and such.
|
|
230
|
+
for (let i = 0; i < splitPath.length; i++) {
|
|
231
|
+
const addPaths = splitPath.slice(0, i + 1);
|
|
232
|
+
splitPath[i] = path.join(...addPaths);
|
|
267
233
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
234
|
+
return splitPath.join(path.sep);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// No symlinks. We just need to verify that it exists.
|
|
238
|
+
if (!(await this.exists(p, cred))) {
|
|
239
|
+
throw ApiError.ENOENT(p);
|
|
274
240
|
}
|
|
275
|
-
|
|
241
|
+
return p;
|
|
242
|
+
}
|
|
276
243
|
}
|
|
277
244
|
realpathSync(p, cred) {
|
|
278
245
|
if (this.metadata.supportsLinks) {
|
|
@@ -296,16 +263,14 @@ export class BaseFileSystem extends FileSystem {
|
|
|
296
263
|
}
|
|
297
264
|
}
|
|
298
265
|
}
|
|
299
|
-
truncate(p, len, cred) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
});
|
|
266
|
+
async truncate(p, len, cred) {
|
|
267
|
+
const fd = await this.open(p, FileFlag.getFileFlag('r+'), 0o644, cred);
|
|
268
|
+
try {
|
|
269
|
+
await fd.truncate(len);
|
|
270
|
+
}
|
|
271
|
+
finally {
|
|
272
|
+
await fd.close();
|
|
273
|
+
}
|
|
309
274
|
}
|
|
310
275
|
truncateSync(p, len, cred) {
|
|
311
276
|
const fd = this.openSync(p, FileFlag.getFileFlag('r+'), 0o644, cred);
|
|
@@ -317,22 +282,20 @@ export class BaseFileSystem extends FileSystem {
|
|
|
317
282
|
fd.closeSync();
|
|
318
283
|
}
|
|
319
284
|
}
|
|
320
|
-
readFile(fname, flag, cred) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
});
|
|
285
|
+
async readFile(fname, flag, cred) {
|
|
286
|
+
// Get file.
|
|
287
|
+
const fd = await this.open(fname, flag, 0o644, cred);
|
|
288
|
+
try {
|
|
289
|
+
const stat = await fd.stat();
|
|
290
|
+
// Allocate buffer.
|
|
291
|
+
const buf = new Uint8Array(stat.size);
|
|
292
|
+
await fd.read(buf, 0, stat.size, 0);
|
|
293
|
+
await fd.close();
|
|
294
|
+
return buf;
|
|
295
|
+
}
|
|
296
|
+
finally {
|
|
297
|
+
await fd.close();
|
|
298
|
+
}
|
|
336
299
|
}
|
|
337
300
|
readFileSync(fname, flag, cred) {
|
|
338
301
|
// Get file.
|
|
@@ -349,21 +312,19 @@ export class BaseFileSystem extends FileSystem {
|
|
|
349
312
|
fd.closeSync();
|
|
350
313
|
}
|
|
351
314
|
}
|
|
352
|
-
writeFile(fname, data, flag, mode, cred) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
data = encode(data);
|
|
359
|
-
}
|
|
360
|
-
// Write into file.
|
|
361
|
-
yield fd.write(data, 0, data.length, 0);
|
|
362
|
-
}
|
|
363
|
-
finally {
|
|
364
|
-
yield fd.close();
|
|
315
|
+
async writeFile(fname, data, flag, mode, cred) {
|
|
316
|
+
// Get file.
|
|
317
|
+
const fd = await this.open(fname, flag, mode, cred);
|
|
318
|
+
try {
|
|
319
|
+
if (typeof data === 'string') {
|
|
320
|
+
data = encode(data);
|
|
365
321
|
}
|
|
366
|
-
|
|
322
|
+
// Write into file.
|
|
323
|
+
await fd.write(data, 0, data.length, 0);
|
|
324
|
+
}
|
|
325
|
+
finally {
|
|
326
|
+
await fd.close();
|
|
327
|
+
}
|
|
367
328
|
}
|
|
368
329
|
writeFileSync(fname, data, flag, mode, cred) {
|
|
369
330
|
// Get file.
|
|
@@ -379,19 +340,17 @@ export class BaseFileSystem extends FileSystem {
|
|
|
379
340
|
fd.closeSync();
|
|
380
341
|
}
|
|
381
342
|
}
|
|
382
|
-
appendFile(fname, data, flag, mode, cred) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
data = encode(data);
|
|
388
|
-
}
|
|
389
|
-
yield fd.write(data, 0, data.length, null);
|
|
390
|
-
}
|
|
391
|
-
finally {
|
|
392
|
-
yield fd.close();
|
|
343
|
+
async appendFile(fname, data, flag, mode, cred) {
|
|
344
|
+
const fd = await this.open(fname, flag, mode, cred);
|
|
345
|
+
try {
|
|
346
|
+
if (typeof data === 'string') {
|
|
347
|
+
data = encode(data);
|
|
393
348
|
}
|
|
394
|
-
|
|
349
|
+
await fd.write(data, 0, data.length, null);
|
|
350
|
+
}
|
|
351
|
+
finally {
|
|
352
|
+
await fd.close();
|
|
353
|
+
}
|
|
395
354
|
}
|
|
396
355
|
appendFileSync(fname, data, flag, mode, cred) {
|
|
397
356
|
const fd = this.openSync(fname, flag, mode, cred);
|
|
@@ -405,50 +364,38 @@ export class BaseFileSystem extends FileSystem {
|
|
|
405
364
|
fd.closeSync();
|
|
406
365
|
}
|
|
407
366
|
}
|
|
408
|
-
chmod(p, mode, cred) {
|
|
409
|
-
|
|
410
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
411
|
-
});
|
|
367
|
+
async chmod(p, mode, cred) {
|
|
368
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
412
369
|
}
|
|
413
370
|
chmodSync(p, mode, cred) {
|
|
414
371
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
415
372
|
}
|
|
416
|
-
chown(p, new_uid, new_gid, cred) {
|
|
417
|
-
|
|
418
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
419
|
-
});
|
|
373
|
+
async chown(p, new_uid, new_gid, cred) {
|
|
374
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
420
375
|
}
|
|
421
376
|
chownSync(p, new_uid, new_gid, cred) {
|
|
422
377
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
423
378
|
}
|
|
424
|
-
utimes(p, atime, mtime, cred) {
|
|
425
|
-
|
|
426
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
427
|
-
});
|
|
379
|
+
async utimes(p, atime, mtime, cred) {
|
|
380
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
428
381
|
}
|
|
429
382
|
utimesSync(p, atime, mtime, cred) {
|
|
430
383
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
431
384
|
}
|
|
432
|
-
link(srcpath, dstpath, cred) {
|
|
433
|
-
|
|
434
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
435
|
-
});
|
|
385
|
+
async link(srcpath, dstpath, cred) {
|
|
386
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
436
387
|
}
|
|
437
388
|
linkSync(srcpath, dstpath, cred) {
|
|
438
389
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
439
390
|
}
|
|
440
|
-
symlink(srcpath, dstpath, type, cred) {
|
|
441
|
-
|
|
442
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
443
|
-
});
|
|
391
|
+
async symlink(srcpath, dstpath, type, cred) {
|
|
392
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
444
393
|
}
|
|
445
394
|
symlinkSync(srcpath, dstpath, type, cred) {
|
|
446
395
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
447
396
|
}
|
|
448
|
-
readlink(p, cred) {
|
|
449
|
-
|
|
450
|
-
throw new ApiError(ErrorCode.ENOTSUP);
|
|
451
|
-
});
|
|
397
|
+
async readlink(p, cred) {
|
|
398
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
452
399
|
}
|
|
453
400
|
readlinkSync(p, cred) {
|
|
454
401
|
throw new ApiError(ErrorCode.ENOTSUP);
|
|
@@ -461,76 +408,48 @@ BaseFileSystem.Name = _a.name;
|
|
|
461
408
|
*/
|
|
462
409
|
export class SynchronousFileSystem extends BaseFileSystem {
|
|
463
410
|
get metadata() {
|
|
464
|
-
return
|
|
465
|
-
}
|
|
466
|
-
access(p, mode, cred) {
|
|
467
|
-
return
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
return
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
return
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
508
|
-
return this.chmodSync(p, mode, cred);
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
chown(p, new_uid, new_gid, cred) {
|
|
512
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
513
|
-
return this.chownSync(p, new_uid, new_gid, cred);
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
utimes(p, atime, mtime, cred) {
|
|
517
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
518
|
-
return this.utimesSync(p, atime, mtime, cred);
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
link(srcpath, dstpath, cred) {
|
|
522
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
523
|
-
return this.linkSync(srcpath, dstpath, cred);
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
symlink(srcpath, dstpath, type, cred) {
|
|
527
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
528
|
-
return this.symlinkSync(srcpath, dstpath, type, cred);
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
readlink(p, cred) {
|
|
532
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
533
|
-
return this.readlinkSync(p, cred);
|
|
534
|
-
});
|
|
411
|
+
return { ...super.metadata, synchronous: true };
|
|
412
|
+
}
|
|
413
|
+
async access(p, mode, cred) {
|
|
414
|
+
return this.accessSync(p, mode, cred);
|
|
415
|
+
}
|
|
416
|
+
async rename(oldPath, newPath, cred) {
|
|
417
|
+
return this.renameSync(oldPath, newPath, cred);
|
|
418
|
+
}
|
|
419
|
+
async stat(p, cred) {
|
|
420
|
+
return this.statSync(p, cred);
|
|
421
|
+
}
|
|
422
|
+
async open(p, flags, mode, cred) {
|
|
423
|
+
return this.openSync(p, flags, mode, cred);
|
|
424
|
+
}
|
|
425
|
+
async unlink(p, cred) {
|
|
426
|
+
return this.unlinkSync(p, cred);
|
|
427
|
+
}
|
|
428
|
+
async rmdir(p, cred) {
|
|
429
|
+
return this.rmdirSync(p, cred);
|
|
430
|
+
}
|
|
431
|
+
async mkdir(p, mode, cred) {
|
|
432
|
+
return this.mkdirSync(p, mode, cred);
|
|
433
|
+
}
|
|
434
|
+
async readdir(p, cred) {
|
|
435
|
+
return this.readdirSync(p, cred);
|
|
436
|
+
}
|
|
437
|
+
async chmod(p, mode, cred) {
|
|
438
|
+
return this.chmodSync(p, mode, cred);
|
|
439
|
+
}
|
|
440
|
+
async chown(p, new_uid, new_gid, cred) {
|
|
441
|
+
return this.chownSync(p, new_uid, new_gid, cred);
|
|
442
|
+
}
|
|
443
|
+
async utimes(p, atime, mtime, cred) {
|
|
444
|
+
return this.utimesSync(p, atime, mtime, cred);
|
|
445
|
+
}
|
|
446
|
+
async link(srcpath, dstpath, cred) {
|
|
447
|
+
return this.linkSync(srcpath, dstpath, cred);
|
|
448
|
+
}
|
|
449
|
+
async symlink(srcpath, dstpath, type, cred) {
|
|
450
|
+
return this.symlinkSync(srcpath, dstpath, type, cred);
|
|
451
|
+
}
|
|
452
|
+
async readlink(p, cred) {
|
|
453
|
+
return this.readlinkSync(p, cred);
|
|
535
454
|
}
|
|
536
455
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ZenFS's main module. This is exposed in the browser via the ZenFS global.
|
|
3
3
|
*/
|
|
4
4
|
import fs from './emulation/fs.js';
|
|
5
|
-
import { FileSystem, type
|
|
5
|
+
import { FileSystem, type NoArgCallback, type TwoArgCallback } from './filesystem.js';
|
|
6
6
|
import { backends } from './backends/index.js';
|
|
7
7
|
/**
|
|
8
8
|
* Initializes ZenFS with the given file systems.
|
|
@@ -25,7 +25,7 @@ export type Configuration = FileSystem | FileSystemConfiguration | ConfigMapping
|
|
|
25
25
|
* See the FileSystemConfiguration type for more info on the configuration object.
|
|
26
26
|
*/
|
|
27
27
|
export declare function configure(config: Configuration): Promise<void>;
|
|
28
|
-
export declare function configure(config: Configuration, cb:
|
|
28
|
+
export declare function configure(config: Configuration, cb: NoArgCallback): void;
|
|
29
29
|
/**
|
|
30
30
|
* Asynchronously creates a file system with the given configuration, and initializes ZenFS with it.
|
|
31
31
|
* See the FileSystemConfiguration type for more info on the configuration object.
|
|
@@ -62,7 +62,7 @@ export interface FileSystemConfiguration {
|
|
|
62
62
|
* @param cb Called when the file system is constructed, or when an error occurs.
|
|
63
63
|
*/
|
|
64
64
|
export declare function getFileSystem(config: FileSystemConfiguration): Promise<FileSystem>;
|
|
65
|
-
export declare function getFileSystem(config: FileSystemConfiguration, cb:
|
|
65
|
+
export declare function getFileSystem(config: FileSystemConfiguration, cb: TwoArgCallback<FileSystem>): void;
|
|
66
66
|
export * from './backends/index.js';
|
|
67
67
|
export * from './backends/AsyncStore.js';
|
|
68
68
|
export * from './backends/SyncStore.js';
|