@zenfs/core 1.3.6 → 1.4.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.
Files changed (88) hide show
  1. package/dist/backends/memory.d.ts +4 -4
  2. package/dist/backends/memory.js +4 -4
  3. package/dist/backends/overlay.d.ts +5 -2
  4. package/dist/backends/overlay.js +7 -10
  5. package/dist/backends/port/fs.js +1 -4
  6. package/dist/config.js +4 -8
  7. package/dist/context.d.ts +32 -0
  8. package/dist/context.js +23 -0
  9. package/dist/credentials.d.ts +5 -5
  10. package/dist/credentials.js +10 -6
  11. package/dist/emulation/async.d.ts +90 -89
  12. package/dist/emulation/async.js +76 -75
  13. package/dist/emulation/dir.d.ts +3 -1
  14. package/dist/emulation/dir.js +6 -7
  15. package/dist/emulation/index.d.ts +1 -1
  16. package/dist/emulation/index.js +1 -1
  17. package/dist/emulation/promises.d.ts +50 -48
  18. package/dist/emulation/promises.js +78 -77
  19. package/dist/emulation/shared.d.ts +35 -8
  20. package/dist/emulation/shared.js +37 -11
  21. package/dist/emulation/sync.d.ts +63 -62
  22. package/dist/emulation/sync.js +72 -73
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/stats.d.ts +2 -1
  26. package/dist/stats.js +5 -4
  27. package/package.json +3 -5
  28. package/scripts/test.js +78 -17
  29. package/tests/assignment.ts +1 -1
  30. package/tests/common/context.test.ts +19 -0
  31. package/tests/{devices.test.ts → common/devices.test.ts} +3 -3
  32. package/tests/{handle.test.ts → common/handle.test.ts} +1 -1
  33. package/tests/common/mounts.test.ts +36 -0
  34. package/tests/{mutex.test.ts → common/mutex.test.ts} +3 -3
  35. package/tests/common/path.test.ts +34 -0
  36. package/tests/common.ts +4 -3
  37. package/tests/fs/dir.test.ts +11 -11
  38. package/tests/fs/directory.test.ts +17 -17
  39. package/tests/fs/errors.test.ts +29 -39
  40. package/tests/fs/watch.test.ts +2 -2
  41. package/tests/setup/context.ts +9 -0
  42. package/tests/setup/cow+fetch.ts +1 -1
  43. package/tests/setup/memory.ts +1 -1
  44. package/tests/{setup/common.ts → setup.ts} +6 -5
  45. package/src/backends/backend.ts +0 -161
  46. package/src/backends/fetch.ts +0 -180
  47. package/src/backends/file_index.ts +0 -206
  48. package/src/backends/memory.ts +0 -45
  49. package/src/backends/overlay.ts +0 -560
  50. package/src/backends/port/fs.ts +0 -329
  51. package/src/backends/port/readme.md +0 -54
  52. package/src/backends/port/rpc.ts +0 -167
  53. package/src/backends/readme.md +0 -3
  54. package/src/backends/store/fs.ts +0 -667
  55. package/src/backends/store/readme.md +0 -9
  56. package/src/backends/store/simple.ts +0 -154
  57. package/src/backends/store/store.ts +0 -189
  58. package/src/config.ts +0 -227
  59. package/src/credentials.ts +0 -49
  60. package/src/devices.ts +0 -521
  61. package/src/emulation/async.ts +0 -834
  62. package/src/emulation/cache.ts +0 -86
  63. package/src/emulation/config.ts +0 -21
  64. package/src/emulation/constants.ts +0 -182
  65. package/src/emulation/dir.ts +0 -138
  66. package/src/emulation/index.ts +0 -8
  67. package/src/emulation/path.ts +0 -440
  68. package/src/emulation/promises.ts +0 -1140
  69. package/src/emulation/shared.ts +0 -172
  70. package/src/emulation/streams.ts +0 -34
  71. package/src/emulation/sync.ts +0 -863
  72. package/src/emulation/watchers.ts +0 -194
  73. package/src/error.ts +0 -307
  74. package/src/file.ts +0 -631
  75. package/src/filesystem.ts +0 -174
  76. package/src/index.ts +0 -35
  77. package/src/inode.ts +0 -128
  78. package/src/mixins/async.ts +0 -230
  79. package/src/mixins/index.ts +0 -5
  80. package/src/mixins/mutexed.ts +0 -257
  81. package/src/mixins/readonly.ts +0 -96
  82. package/src/mixins/shared.ts +0 -25
  83. package/src/mixins/sync.ts +0 -58
  84. package/src/polyfills.ts +0 -21
  85. package/src/stats.ts +0 -405
  86. package/src/utils.ts +0 -276
  87. package/tests/mounts.test.ts +0 -18
  88. package/tests/path.test.ts +0 -34
@@ -4,7 +4,7 @@ import { BigIntStats } from '../stats.js';
4
4
  import { normalizeMode, normalizePath } from '../utils.js';
5
5
  import { R_OK } from './constants.js';
6
6
  import * as promises from './promises.js';
7
- import { fd2file } from './shared.js';
7
+ import { fd2file, fdMap } from './shared.js';
8
8
  import { ReadStream, WriteStream } from './streams.js';
9
9
  import { FSWatcher, StatWatcher } from './watchers.js';
10
10
  const nop = () => { };
@@ -12,8 +12,8 @@ const nop = () => { };
12
12
  * Asynchronous rename. No arguments other than a possible exception are given to the completion callback.
13
13
  */
14
14
  export function rename(oldPath, newPath, cb = nop) {
15
- promises
16
- .rename(oldPath, newPath)
15
+ promises.rename
16
+ .call(this, oldPath, newPath)
17
17
  .then(() => cb())
18
18
  .catch(cb);
19
19
  }
@@ -24,24 +24,24 @@ rename;
24
24
  * @deprecated Use {@link stat} or {@link access} instead.
25
25
  */
26
26
  export function exists(path, cb = nop) {
27
- promises
28
- .exists(path)
27
+ promises.exists
28
+ .call(this, path)
29
29
  .then(cb)
30
30
  .catch(() => cb(false));
31
31
  }
32
32
  exists;
33
33
  export function stat(path, options, callback = nop) {
34
34
  callback = typeof options == 'function' ? options : callback;
35
- promises
36
- .stat(path, typeof options != 'function' ? options : {})
35
+ promises.stat
36
+ .call(this, path, typeof options != 'function' ? options : {})
37
37
  .then(stats => callback(undefined, stats))
38
38
  .catch(callback);
39
39
  }
40
40
  stat;
41
41
  export function lstat(path, options, callback = nop) {
42
42
  callback = typeof options == 'function' ? options : callback;
43
- promises
44
- .lstat(path, typeof options != 'function' ? options : {})
43
+ promises.lstat
44
+ .call(this, path, typeof options != 'function' ? options : {})
45
45
  .then(stats => callback(undefined, stats))
46
46
  .catch(callback);
47
47
  }
@@ -49,15 +49,15 @@ lstat;
49
49
  export function truncate(path, cbLen = 0, cb = nop) {
50
50
  cb = typeof cbLen === 'function' ? cbLen : cb;
51
51
  const len = typeof cbLen === 'number' ? cbLen : 0;
52
- promises
53
- .truncate(path, len)
52
+ promises.truncate
53
+ .call(this, path, len)
54
54
  .then(() => cb())
55
55
  .catch(cb);
56
56
  }
57
57
  truncate;
58
58
  export function unlink(path, cb = nop) {
59
- promises
60
- .unlink(path)
59
+ promises.unlink
60
+ .call(this, path)
61
61
  .then(() => cb())
62
62
  .catch(cb);
63
63
  }
@@ -65,24 +65,24 @@ unlink;
65
65
  export function open(path, flag, cbMode, cb = nop) {
66
66
  const mode = normalizeMode(cbMode, 0o644);
67
67
  cb = typeof cbMode === 'function' ? cbMode : cb;
68
- promises
69
- .open(path, flag, mode)
68
+ promises.open
69
+ .call(this, path, flag, mode)
70
70
  .then(handle => cb(undefined, handle.fd))
71
71
  .catch(cb);
72
72
  }
73
73
  open;
74
74
  export function readFile(filename, options, cb = nop) {
75
75
  cb = typeof options === 'function' ? options : cb;
76
- promises
77
- .readFile(filename, typeof options === 'function' ? null : options)
76
+ promises.readFile
77
+ .call(this, filename, typeof options === 'function' ? null : options)
78
78
  .then(data => cb(undefined, data))
79
79
  .catch(cb);
80
80
  }
81
81
  readFile;
82
82
  export function writeFile(filename, data, cbEncOpts, cb = nop) {
83
83
  cb = typeof cbEncOpts === 'function' ? cbEncOpts : cb;
84
- promises
85
- .writeFile(filename, data, typeof cbEncOpts != 'function' ? cbEncOpts : null)
84
+ promises.writeFile
85
+ .call(this, filename, data, typeof cbEncOpts != 'function' ? cbEncOpts : null)
86
86
  .then(() => cb(undefined))
87
87
  .catch(cb);
88
88
  }
@@ -90,8 +90,8 @@ writeFile;
90
90
  export function appendFile(filename, data, cbEncOpts, cb = nop) {
91
91
  const optionsOrEncoding = typeof cbEncOpts != 'function' ? cbEncOpts : undefined;
92
92
  cb = typeof cbEncOpts === 'function' ? cbEncOpts : cb;
93
- promises
94
- .appendFile(filename, data, optionsOrEncoding)
93
+ promises.appendFile
94
+ .call(this, filename, data, optionsOrEncoding)
95
95
  .then(() => cb())
96
96
  .catch(cb);
97
97
  }
@@ -105,10 +105,9 @@ export function fstat(fd, options, cb = nop) {
105
105
  }
106
106
  fstat;
107
107
  export function close(fd, cb = nop) {
108
- new promises.FileHandle(fd)
109
- .close()
110
- .then(() => cb())
111
- .catch(cb);
108
+ const close = fd2file(fd).close();
109
+ fdMap.delete(fd);
110
+ close.then(() => cb()).catch(cb);
112
111
  }
113
112
  close;
114
113
  export function ftruncate(fd, lenOrCB, cb = nop) {
@@ -139,7 +138,7 @@ export function fdatasync(fd, cb = nop) {
139
138
  fdatasync;
140
139
  export function write(fd, data, cbPosOff, cbLenEnc, cbPosEnc, cb = nop) {
141
140
  let buffer, offset, length, position, encoding;
142
- const handle = new promises.FileHandle(fd);
141
+ const handle = new promises.FileHandle(fd, this);
143
142
  if (typeof data === 'string') {
144
143
  // Signature 1: (fd, string, [position?, [encoding?]], cb?)
145
144
  encoding = 'utf8';
@@ -193,21 +192,21 @@ write;
193
192
  * @param cb The number is the number of bytes read
194
193
  */
195
194
  export function read(fd, buffer, offset, length, position, cb = nop) {
196
- new promises.FileHandle(fd)
195
+ new promises.FileHandle(fd, this)
197
196
  .read(buffer, offset, length, position)
198
197
  .then(({ bytesRead, buffer }) => cb(undefined, bytesRead, buffer))
199
198
  .catch(cb);
200
199
  }
201
200
  read;
202
201
  export function fchown(fd, uid, gid, cb = nop) {
203
- new promises.FileHandle(fd)
202
+ new promises.FileHandle(fd, this)
204
203
  .chown(uid, gid)
205
204
  .then(() => cb())
206
205
  .catch(cb);
207
206
  }
208
207
  fchown;
209
208
  export function fchmod(fd, mode, cb) {
210
- new promises.FileHandle(fd)
209
+ new promises.FileHandle(fd, this)
211
210
  .chmod(mode)
212
211
  .then(() => cb())
213
212
  .catch(cb);
@@ -217,15 +216,15 @@ fchmod;
217
216
  * Change the file timestamps of a file referenced by the supplied file descriptor.
218
217
  */
219
218
  export function futimes(fd, atime, mtime, cb = nop) {
220
- new promises.FileHandle(fd)
219
+ new promises.FileHandle(fd, this)
221
220
  .utimes(atime, mtime)
222
221
  .then(() => cb())
223
222
  .catch(cb);
224
223
  }
225
224
  futimes;
226
225
  export function rmdir(path, cb = nop) {
227
- promises
228
- .rmdir(path)
226
+ promises.rmdir
227
+ .call(this, path)
229
228
  .then(() => cb())
230
229
  .catch(cb);
231
230
  }
@@ -235,8 +234,8 @@ rmdir;
235
234
  * @param mode defaults to `0777`
236
235
  */
237
236
  export function mkdir(path, mode, cb = nop) {
238
- promises
239
- .mkdir(path, mode)
237
+ promises.mkdir
238
+ .call(this, path, mode)
240
239
  .then(() => cb())
241
240
  .catch(cb);
242
241
  }
@@ -244,15 +243,15 @@ mkdir;
244
243
  export function readdir(path, _options, cb = nop) {
245
244
  cb = typeof _options == 'function' ? _options : cb;
246
245
  const options = typeof _options != 'function' ? _options : {};
247
- promises
248
- .readdir(path, options)
246
+ promises.readdir
247
+ .call(this, path, options)
249
248
  .then(entries => cb(undefined, entries))
250
249
  .catch(cb);
251
250
  }
252
251
  readdir;
253
252
  export function link(existing, newpath, cb = nop) {
254
- promises
255
- .link(existing, newpath)
253
+ promises.link
254
+ .call(this, existing, newpath)
256
255
  .then(() => cb())
257
256
  .catch(cb);
258
257
  }
@@ -260,44 +259,44 @@ link;
260
259
  export function symlink(target, path, typeOrCB, cb = nop) {
261
260
  const type = typeof typeOrCB === 'string' ? typeOrCB : 'file';
262
261
  cb = typeof typeOrCB === 'function' ? typeOrCB : cb;
263
- promises
264
- .symlink(target, path, type)
262
+ promises.symlink
263
+ .call(this, target, path, type)
265
264
  .then(() => cb())
266
265
  .catch(cb);
267
266
  }
268
267
  symlink;
269
268
  export function readlink(path, options, callback = nop) {
270
269
  callback = typeof options == 'function' ? options : callback;
271
- promises
272
- .readlink(path)
270
+ promises.readlink
271
+ .call(this, path)
273
272
  .then(result => callback(undefined, result))
274
273
  .catch(callback);
275
274
  }
276
275
  readlink;
277
276
  export function chown(path, uid, gid, cb = nop) {
278
- promises
279
- .chown(path, uid, gid)
277
+ promises.chown
278
+ .call(this, path, uid, gid)
280
279
  .then(() => cb())
281
280
  .catch(cb);
282
281
  }
283
282
  chown;
284
283
  export function lchown(path, uid, gid, cb = nop) {
285
- promises
286
- .lchown(path, uid, gid)
284
+ promises.lchown
285
+ .call(this, path, uid, gid)
287
286
  .then(() => cb())
288
287
  .catch(cb);
289
288
  }
290
289
  lchown;
291
290
  export function chmod(path, mode, cb = nop) {
292
- promises
293
- .chmod(path, mode)
291
+ promises.chmod
292
+ .call(this, path, mode)
294
293
  .then(() => cb())
295
294
  .catch(cb);
296
295
  }
297
296
  chmod;
298
297
  export function lchmod(path, mode, cb = nop) {
299
- promises
300
- .lchmod(path, mode)
298
+ promises.lchmod
299
+ .call(this, path, mode)
301
300
  .then(() => cb())
302
301
  .catch(cb);
303
302
  }
@@ -306,8 +305,8 @@ lchmod;
306
305
  * Change file timestamps of the file referenced by the supplied path.
307
306
  */
308
307
  export function utimes(path, atime, mtime, cb = nop) {
309
- promises
310
- .utimes(path, atime, mtime)
308
+ promises.utimes
309
+ .call(this, path, atime, mtime)
311
310
  .then(() => cb())
312
311
  .catch(cb);
313
312
  }
@@ -316,16 +315,16 @@ utimes;
316
315
  * Change file timestamps of the file referenced by the supplied path.
317
316
  */
318
317
  export function lutimes(path, atime, mtime, cb = nop) {
319
- promises
320
- .lutimes(path, atime, mtime)
318
+ promises.lutimes
319
+ .call(this, path, atime, mtime)
321
320
  .then(() => cb())
322
321
  .catch(cb);
323
322
  }
324
323
  lutimes;
325
324
  export function realpath(path, arg2, cb = nop) {
326
325
  cb = typeof arg2 === 'function' ? arg2 : cb;
327
- promises
328
- .realpath(path, typeof arg2 === 'function' ? null : arg2)
326
+ promises.realpath
327
+ .call(this, path, typeof arg2 === 'function' ? null : arg2)
329
328
  .then(result => cb(undefined, result))
330
329
  .catch(cb);
331
330
  }
@@ -333,8 +332,8 @@ realpath;
333
332
  export function access(path, cbMode, cb = nop) {
334
333
  const mode = typeof cbMode === 'number' ? cbMode : R_OK;
335
334
  cb = typeof cbMode === 'function' ? cbMode : cb;
336
- promises
337
- .access(path, mode)
335
+ promises.access
336
+ .call(this, path, mode)
338
337
  .then(() => cb())
339
338
  .catch(cb);
340
339
  }
@@ -412,6 +411,7 @@ watch;
412
411
  * @returns A ReadStream object for interacting with the file's contents.
413
412
  */
414
413
  export function createReadStream(path, options) {
414
+ const context = this;
415
415
  options = typeof options == 'object' ? options : { encoding: options };
416
416
  let handle;
417
417
  const stream = new ReadStream({
@@ -419,7 +419,7 @@ export function createReadStream(path, options) {
419
419
  encoding: options.encoding || 'utf8',
420
420
  async read(size) {
421
421
  try {
422
- handle || (handle = await promises.open(path, 'r', options?.mode));
422
+ handle || (handle = await promises.open.call(context, path, 'r', options?.mode));
423
423
  const result = await handle.read(new Uint8Array(size), 0, size, handle.file.position);
424
424
  stream.push(!result.bytesRead ? null : result.buffer.slice(0, result.bytesRead));
425
425
  handle.file.position += result.bytesRead;
@@ -451,13 +451,14 @@ createReadStream;
451
451
  * @returns A WriteStream object for writing to the file.
452
452
  */
453
453
  export function createWriteStream(path, options) {
454
+ const context = this;
454
455
  options = typeof options == 'object' ? options : { encoding: options };
455
456
  let handle;
456
457
  const stream = new WriteStream({
457
458
  highWaterMark: options?.highWaterMark,
458
459
  async write(chunk, encoding, callback) {
459
460
  try {
460
- handle || (handle = await promises.open(path, 'w', options?.mode || 0o666));
461
+ handle || (handle = await promises.open.call(context, path, 'w', options?.mode || 0o666));
461
462
  await handle.write(chunk, 0, encoding);
462
463
  callback(undefined);
463
464
  }
@@ -486,31 +487,31 @@ export function createWriteStream(path, options) {
486
487
  createWriteStream;
487
488
  export function rm(path, options, callback = nop) {
488
489
  callback = typeof options === 'function' ? options : callback;
489
- promises
490
- .rm(path, typeof options === 'function' ? undefined : options)
490
+ promises.rm
491
+ .call(this, path, typeof options === 'function' ? undefined : options)
491
492
  .then(() => callback(undefined))
492
493
  .catch(callback);
493
494
  }
494
495
  rm;
495
496
  export function mkdtemp(prefix, options, callback = nop) {
496
497
  callback = typeof options === 'function' ? options : callback;
497
- promises
498
- .mkdtemp(prefix, typeof options != 'function' ? options : null)
498
+ promises.mkdtemp
499
+ .call(this, prefix, typeof options != 'function' ? options : null)
499
500
  .then(result => callback(undefined, result))
500
501
  .catch(callback);
501
502
  }
502
503
  mkdtemp;
503
504
  export function copyFile(src, dest, flags, callback = nop) {
504
505
  callback = typeof flags === 'function' ? flags : callback;
505
- promises
506
- .copyFile(src, dest, typeof flags === 'function' ? undefined : flags)
506
+ promises.copyFile
507
+ .call(this, src, dest, typeof flags === 'function' ? undefined : flags)
507
508
  .then(() => callback(undefined))
508
509
  .catch(callback);
509
510
  }
510
511
  copyFile;
511
512
  export function readv(fd, buffers, position, cb = nop) {
512
513
  cb = typeof position === 'function' ? position : cb;
513
- new promises.FileHandle(fd)
514
+ new promises.FileHandle(fd, this)
514
515
  .readv(buffers, typeof position === 'function' ? undefined : position)
515
516
  .then(({ buffers, bytesRead }) => cb(undefined, bytesRead, buffers))
516
517
  .catch(cb);
@@ -518,7 +519,7 @@ export function readv(fd, buffers, position, cb = nop) {
518
519
  readv;
519
520
  export function writev(fd, buffers, position, cb = nop) {
520
521
  cb = typeof position === 'function' ? position : cb;
521
- new promises.FileHandle(fd)
522
+ new promises.FileHandle(fd, this)
522
523
  .writev(buffers, typeof position === 'function' ? undefined : position)
523
524
  .then(({ buffers, bytesWritten }) => cb(undefined, bytesWritten, buffers))
524
525
  .catch(cb);
@@ -526,30 +527,30 @@ export function writev(fd, buffers, position, cb = nop) {
526
527
  writev;
527
528
  export function opendir(path, options, cb = nop) {
528
529
  cb = typeof options === 'function' ? options : cb;
529
- promises
530
- .opendir(path, typeof options === 'function' ? undefined : options)
530
+ promises.opendir
531
+ .call(this, path, typeof options === 'function' ? undefined : options)
531
532
  .then(result => cb(undefined, result))
532
533
  .catch(cb);
533
534
  }
534
535
  opendir;
535
536
  export function cp(source, destination, opts, callback = nop) {
536
537
  callback = typeof opts === 'function' ? opts : callback;
537
- promises
538
- .cp(source, destination, typeof opts === 'function' ? undefined : opts)
538
+ promises.cp
539
+ .call(this, source, destination, typeof opts === 'function' ? undefined : opts)
539
540
  .then(() => callback(undefined))
540
541
  .catch(callback);
541
542
  }
542
543
  cp;
543
544
  export function statfs(path, options, callback = nop) {
544
545
  callback = typeof options === 'function' ? options : callback;
545
- promises
546
- .statfs(path, typeof options === 'function' ? undefined : options)
546
+ promises.statfs
547
+ .call(this, path, typeof options === 'function' ? undefined : options)
547
548
  .then(result => callback(undefined, result))
548
549
  .catch(callback);
549
550
  }
550
551
  statfs;
551
552
  export async function openAsBlob(path, options) {
552
- const handle = await promises.open(path.toString(), 'r');
553
+ const handle = await promises.open.call(this, path.toString(), 'r');
553
554
  const buffer = await handle.readFile();
554
555
  await handle.close();
555
556
  return new Blob([buffer], options);
@@ -1,6 +1,7 @@
1
1
  import type { Dir as _Dir, Dirent as _Dirent } from 'node:fs';
2
2
  import type { Stats } from '../stats.js';
3
3
  import type { Callback } from '../utils.js';
4
+ import type { V_Context } from '../context.js';
4
5
  export declare class Dirent implements _Dirent {
5
6
  path: string;
6
7
  protected stats: Stats;
@@ -20,10 +21,11 @@ export declare class Dirent implements _Dirent {
20
21
  */
21
22
  export declare class Dir implements _Dir {
22
23
  readonly path: string;
24
+ protected readonly context: V_Context;
23
25
  protected closed: boolean;
24
26
  protected checkClosed(): void;
25
27
  protected _entries?: Dirent[];
26
- constructor(path: string);
28
+ constructor(path: string, context: V_Context);
27
29
  /**
28
30
  * Asynchronously close the directory's underlying resource handle.
29
31
  * Subsequent reads will result in errors.
@@ -44,8 +44,9 @@ export class Dir {
44
44
  throw new ErrnoError(Errno.EBADF, 'Can not use closed Dir');
45
45
  }
46
46
  }
47
- constructor(path) {
47
+ constructor(path, context) {
48
48
  this.path = path;
49
+ this.context = context;
49
50
  this.closed = false;
50
51
  }
51
52
  close(cb) {
@@ -64,10 +65,9 @@ export class Dir {
64
65
  }
65
66
  async _read() {
66
67
  this.checkClosed();
67
- this._entries ?? (this._entries = await readdir(this.path, { withFileTypes: true }));
68
- if (!this._entries.length) {
68
+ this._entries ?? (this._entries = await readdir.call(this.context, this.path, { withFileTypes: true }));
69
+ if (!this._entries.length)
69
70
  return null;
70
- }
71
71
  return this._entries.shift() ?? null;
72
72
  }
73
73
  read(cb) {
@@ -83,10 +83,9 @@ export class Dir {
83
83
  */
84
84
  readSync() {
85
85
  this.checkClosed();
86
- this._entries ?? (this._entries = readdirSync(this.path, { withFileTypes: true }));
87
- if (!this._entries.length) {
86
+ this._entries ?? (this._entries = readdirSync.call(this.context, this.path, { withFileTypes: true }));
87
+ if (!this._entries.length)
88
88
  return null;
89
- }
90
89
  return this._entries.shift() ?? null;
91
90
  }
92
91
  async next() {
@@ -4,5 +4,5 @@ export * as promises from './promises.js';
4
4
  export * as constants from './constants.js';
5
5
  export * from './streams.js';
6
6
  export * from './dir.js';
7
- export { mountObject, mounts, mount, umount, _synced } from './shared.js';
7
+ export { mountObject, mounts, mount, umount, _synced, chroot } from './shared.js';
8
8
  export { Stats, StatsFs, BigIntStatsFs } from '../stats.js';
@@ -4,5 +4,5 @@ export * as promises from './promises.js';
4
4
  export * as constants from './constants.js';
5
5
  export * from './streams.js';
6
6
  export * from './dir.js';
7
- export { mountObject, mounts, mount, umount, _synced } from './shared.js';
7
+ export { mountObject, mounts, mount, umount, _synced, chroot } from './shared.js';
8
8
  export { Stats, StatsFs, BigIntStatsFs } from '../stats.js';