@zenfs/core 2.4.1 → 2.4.3

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 (101) hide show
  1. package/COPYING.md +24 -0
  2. package/{readme.md → README.md} +16 -74
  3. package/dist/backends/backend.d.ts +1 -1
  4. package/dist/backends/fetch.js +1 -1
  5. package/dist/backends/memory.js +1 -1
  6. package/dist/backends/passthrough.d.ts +1 -2
  7. package/dist/backends/single_buffer.d.ts +1 -1
  8. package/dist/backends/single_buffer.js +27 -24
  9. package/dist/backends/store/fs.js +4 -4
  10. package/dist/config.js +15 -15
  11. package/dist/context.js +3 -2
  12. package/dist/index.d.ts +9 -3
  13. package/dist/index.js +9 -4
  14. package/dist/internal/contexts.d.ts +5 -4
  15. package/dist/internal/devices.js +1 -1
  16. package/dist/internal/error.d.ts +11 -2
  17. package/dist/internal/error.js +38 -2
  18. package/dist/internal/file_index.js +1 -1
  19. package/dist/internal/index.d.ts +1 -0
  20. package/dist/internal/index.js +2 -1
  21. package/dist/internal/index_fs.js +1 -1
  22. package/dist/internal/inode.d.ts +51 -2
  23. package/dist/internal/inode.js +18 -2
  24. package/dist/mixins/shared.js +1 -1
  25. package/dist/node/async.d.ts +278 -0
  26. package/dist/node/async.js +518 -0
  27. package/dist/node/compat.d.ts +4 -0
  28. package/dist/node/compat.js +6 -0
  29. package/dist/node/dir.d.ts +78 -0
  30. package/dist/node/dir.js +150 -0
  31. package/dist/node/index.d.ts +8 -0
  32. package/dist/node/index.js +8 -0
  33. package/dist/{vfs → node}/promises.d.ts +10 -66
  34. package/dist/{vfs → node}/promises.js +141 -478
  35. package/dist/{vfs → node}/stats.d.ts +0 -4
  36. package/dist/{vfs → node}/stats.js +1 -16
  37. package/dist/{vfs → node}/streams.js +2 -2
  38. package/dist/node/sync.d.ts +252 -0
  39. package/dist/node/sync.js +682 -0
  40. package/dist/node/types.d.ts +21 -0
  41. package/dist/utils.d.ts +1 -7
  42. package/dist/utils.js +0 -6
  43. package/dist/vfs/acl.js +1 -1
  44. package/dist/vfs/async.d.ts +22 -278
  45. package/dist/vfs/async.js +212 -501
  46. package/dist/vfs/dir.d.ts +5 -82
  47. package/dist/vfs/dir.js +5 -233
  48. package/dist/vfs/file.d.ts +52 -13
  49. package/dist/vfs/file.js +167 -25
  50. package/dist/vfs/flags.js +1 -1
  51. package/dist/vfs/index.d.ts +2 -5
  52. package/dist/vfs/index.js +2 -5
  53. package/dist/vfs/shared.d.ts +25 -1
  54. package/dist/vfs/shared.js +6 -4
  55. package/dist/vfs/sync.d.ts +17 -245
  56. package/dist/vfs/sync.js +129 -773
  57. package/dist/vfs/watchers.d.ts +1 -1
  58. package/dist/vfs/watchers.js +2 -2
  59. package/dist/vfs/xattr.js +1 -1
  60. package/eslint.shared.js +1 -0
  61. package/package.json +7 -5
  62. package/scripts/make-index.js +5 -29
  63. package/scripts/test.js +59 -51
  64. package/tests/backend/fetch.test.ts +2 -2
  65. package/tests/backend/port.test.ts +2 -3
  66. package/tests/backend/single-buffer.test.ts +48 -1
  67. package/tests/common/casefold.test.ts +1 -1
  68. package/tests/common/context.test.ts +11 -4
  69. package/tests/common/devices.test.ts +3 -3
  70. package/tests/common/handle.test.ts +4 -3
  71. package/tests/common/inode.test.ts +2 -2
  72. package/tests/common/mounts.test.ts +1 -3
  73. package/tests/common/mutex.test.ts +1 -3
  74. package/tests/common/path.test.ts +2 -2
  75. package/tests/common/readline.test.ts +1 -1
  76. package/tests/common.ts +5 -4
  77. package/tests/fetch/fetch.ts +1 -1
  78. package/tests/fs/dir.test.ts +3 -43
  79. package/tests/fs/directory.test.ts +4 -4
  80. package/tests/fs/errors.test.ts +2 -2
  81. package/tests/fs/links.test.ts +1 -1
  82. package/tests/fs/permissions.test.ts +3 -3
  83. package/tests/fs/read.test.ts +1 -1
  84. package/tests/fs/scaling.test.ts +1 -1
  85. package/tests/fs/stat.test.ts +1 -2
  86. package/tests/fs/times.test.ts +1 -1
  87. package/tests/fs/watch.test.ts +3 -2
  88. package/tests/setup/context.ts +1 -2
  89. package/tests/setup/cow.ts +1 -1
  90. package/tests/setup/index.ts +2 -2
  91. package/tests/setup/port.ts +1 -1
  92. package/tests/setup/single-buffer.ts +1 -1
  93. package/tests/setup.ts +4 -3
  94. package/dist/vfs/types.d.ts +0 -24
  95. package/tests/assignment.ts +0 -21
  96. /package/dist/{vfs/constants.d.ts → constants.d.ts} +0 -0
  97. /package/dist/{vfs/constants.js → constants.js} +0 -0
  98. /package/dist/{readline.d.ts → node/readline.d.ts} +0 -0
  99. /package/dist/{readline.js → node/readline.js} +0 -0
  100. /package/dist/{vfs → node}/streams.d.ts +0 -0
  101. /package/dist/{vfs → node}/types.js +0 -0
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
- import { Exception, setUVMessage } from 'kerium';
2
+ import { Errno, Exception, setUVMessage, UV } from 'kerium';
3
3
  /**
4
4
  * @deprecated Use {@link Exception} instead
5
5
  * @category Internals
@@ -9,7 +9,11 @@ export function withPath(e, path) {
9
9
  e.path = path;
10
10
  return e;
11
11
  }
12
+ /**
13
+ * @internal @hidden
14
+ */
12
15
  export function wrap(fs, prop, path, dest) {
16
+ const extra = typeof path === 'string' ? { path, dest, syscall: prop.endsWith('Sync') ? prop.slice(0, -4) : prop } : path;
13
17
  const fn = fs[prop];
14
18
  if (typeof fn !== 'function')
15
19
  throw new TypeError(`${prop} is not a function`);
@@ -18,7 +22,39 @@ export function wrap(fs, prop, path, dest) {
18
22
  return fn.call(fs, ...args);
19
23
  }
20
24
  catch (e) {
21
- throw setUVMessage(Object.assign(e, { path, dest, syscall: prop.endsWith('Sync') ? prop.slice(0, -4) : prop }));
25
+ throw setUVMessage(Object.assign(e, extra));
22
26
  }
23
27
  };
24
28
  }
29
+ /**
30
+ * @internal
31
+ * Wraps an `fs` so that thrown errors aren't empty
32
+ */
33
+ export function withExceptionContext(fs, context) {
34
+ return new Proxy(fs, {
35
+ get(target, prop) {
36
+ const value = Reflect.get(target, prop);
37
+ if (typeof value != 'function')
38
+ return value;
39
+ return function __withContext(...args) {
40
+ try {
41
+ const result = value.apply(target, args);
42
+ if (!(result instanceof Promise))
43
+ return result;
44
+ return result.catch((e) => {
45
+ if ('code' in e)
46
+ throw setUVMessage(Object.assign(e, context));
47
+ if (e in Errno) {
48
+ const ex = UV(e, context);
49
+ Error.captureStackTrace(ex, __withContext);
50
+ }
51
+ throw e;
52
+ });
53
+ }
54
+ catch (e) {
55
+ throw setUVMessage(Object.assign(e, context));
56
+ }
57
+ };
58
+ },
59
+ });
60
+ }
@@ -4,7 +4,7 @@ import { withErrno } from 'kerium';
4
4
  import { sizeof } from 'memium';
5
5
  import { isJSON, randomInt } from 'utilium';
6
6
  import { basename, dirname } from '../path.js';
7
- import { S_IFDIR, S_IFMT, size_max } from '../vfs/constants.js';
7
+ import { S_IFDIR, S_IFMT, size_max } from '../constants.js';
8
8
  import { Inode } from './inode.js';
9
9
  export const version = 1;
10
10
  /**
@@ -1,4 +1,5 @@
1
1
  export { log } from 'kerium';
2
+ export * from './contexts.js';
2
3
  export * from './credentials.js';
3
4
  export * from './devices.js';
4
5
  export * from './error.js';
@@ -1,5 +1,6 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
- export { log } from 'kerium'; // DO NOT USE
2
+ export { log } from 'kerium'; // DO NOT USE @todo [BREAKING] Remove this
3
+ export * from './contexts.js';
3
4
  export * from './credentials.js';
4
5
  export * from './devices.js';
5
6
  export * from './error.js';
@@ -3,7 +3,7 @@
3
3
  import { withErrno } from 'kerium';
4
4
  import { _throw } from 'utilium';
5
5
  import { dirname, join, relative } from '../path.js';
6
- import { S_IFDIR, S_IFMT, S_IFREG, S_ISGID, S_ISUID } from '../vfs/constants.js';
6
+ import { S_IFDIR, S_IFMT, S_IFREG, S_ISGID, S_ISUID } from '../constants.js';
7
7
  import { Index } from './file_index.js';
8
8
  import { FileSystem } from './filesystem.js';
9
9
  import { Inode } from './inode.js';
@@ -1,5 +1,5 @@
1
1
  import { BufferView } from 'utilium/buffer.js';
2
- import { Stats, type StatsLike } from '../vfs/stats.js';
2
+ import { Stats } from '../node/stats.js';
3
3
  import { type V_Context } from './contexts.js';
4
4
  /**
5
5
  * Root inode
@@ -36,7 +36,51 @@ export interface InodeFields {
36
36
  * @category Internals
37
37
  * @internal
38
38
  */
39
- export interface InodeLike extends StatsLike<number>, InodeFields {
39
+ export interface InodeLike<T extends number | bigint = number> extends InodeFields {
40
+ /**
41
+ * Size of the item in bytes.
42
+ * For directories/symlinks, this is normally the size of the struct that represents the item.
43
+ */
44
+ size: T;
45
+ /**
46
+ * Unix-style file mode (e.g. 0o644) that includes the item type
47
+ */
48
+ mode: T;
49
+ /**
50
+ * Time of last access, since epoch
51
+ */
52
+ atimeMs: T;
53
+ /**
54
+ * Time of last modification, since epoch
55
+ */
56
+ mtimeMs: T;
57
+ /**
58
+ * Time of last time file status was changed, since epoch
59
+ */
60
+ ctimeMs: T;
61
+ /**
62
+ * Time of file creation, since epoch
63
+ */
64
+ birthtimeMs: T;
65
+ /**
66
+ * The id of the user that owns the file
67
+ */
68
+ uid: T;
69
+ /**
70
+ * The id of the group that owns the file
71
+ */
72
+ gid: T;
73
+ /**
74
+ * Inode number
75
+ */
76
+ ino: T;
77
+ /**
78
+ * Number of hard links
79
+ */
80
+ nlink: T;
81
+ /**
82
+ * Extended attributes
83
+ */
40
84
  attributes?: Attributes;
41
85
  }
42
86
  /**
@@ -153,6 +197,7 @@ export declare class Inode extends Inode_base implements InodeLike {
153
197
  toJSON(): InodeLike;
154
198
  /**
155
199
  * Handy function that converts the Inode to a Node Stats object.
200
+ * @deprecated Use `new Stats(inode)` instead.
156
201
  */
157
202
  toStats(): Stats;
158
203
  /**
@@ -194,4 +239,8 @@ export declare function isFIFO(metadata: {
194
239
  * @internal
195
240
  */
196
241
  export declare function hasAccess($: V_Context, inode: Pick<InodeLike, 'mode' | 'uid' | 'gid'>, access: number): boolean;
242
+ /**
243
+ * @hidden @internal
244
+ */
245
+ export declare function _chown(stats: Partial<InodeLike>, uid: number, gid: number): boolean;
197
246
  export {};
@@ -39,8 +39,8 @@ import { sizeof } from 'memium';
39
39
  import { $from, field, struct, types as t } from 'memium/decorators';
40
40
  import { decodeUTF8, encodeUTF8, pick } from 'utilium';
41
41
  import { BufferView } from 'utilium/buffer.js';
42
- import * as c from '../vfs/constants.js';
43
- import { Stats } from '../vfs/stats.js';
42
+ import { Stats } from '../node/stats.js';
43
+ import * as c from '../constants.js';
44
44
  import { defaultContext } from './contexts.js';
45
45
  /**
46
46
  * Root inode
@@ -549,6 +549,7 @@ let Inode = (() => {
549
549
  }
550
550
  /**
551
551
  * Handy function that converts the Inode to a Node Stats object.
552
+ * @deprecated Use `new Stats(inode)` instead.
552
553
  */
553
554
  toStats() {
554
555
  return new Stats(this);
@@ -647,3 +648,18 @@ export function hasAccess($, inode, access) {
647
648
  perm |= c.X_OK;
648
649
  return (perm & access) === access;
649
650
  }
651
+ /**
652
+ * @hidden @internal
653
+ */
654
+ export function _chown(stats, uid, gid) {
655
+ let valid = true;
656
+ if (!isNaN(uid) && uid >= 0 && uid < c.size_max)
657
+ stats.uid = uid;
658
+ else
659
+ valid = false;
660
+ if (!isNaN(gid) && gid >= 0 && gid < c.size_max)
661
+ stats.gid = gid;
662
+ else
663
+ valid = false;
664
+ return valid;
665
+ }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
- /* eslint-disable @typescript-eslint/no-empty-object-type,@typescript-eslint/no-explicit-any */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  /*
4
4
  Code shared by various mixins
5
5
  */
@@ -0,0 +1,278 @@
1
+ import type * as fs from 'node:fs';
2
+ import type { V_Context } from '../context.js';
3
+ import type { Callback } from '../utils.js';
4
+ import type { FileContents } from '../vfs/shared.js';
5
+ import type { Dir, Dirent } from './dir.js';
6
+ import type { Stats } from './stats.js';
7
+ import { Buffer } from 'buffer';
8
+ import { type Exception } from 'kerium';
9
+ import { FSWatcher } from '../vfs/watchers.js';
10
+ import { BigIntStats } from './stats.js';
11
+ import { ReadStream, WriteStream, type ReadStreamOptions, type WriteStreamOptions } from './streams.js';
12
+ /**
13
+ * Asynchronous rename. No arguments other than a possible exception are given to the completion callback.
14
+ */
15
+ export declare function rename(this: V_Context, oldPath: fs.PathLike, newPath: fs.PathLike, cb?: Callback): void;
16
+ /**
17
+ * Test whether or not `path` exists by checking with the file system.
18
+ * Then call the callback argument with either true or false.
19
+ * According to Node.js: deprecated Use {@link stat} or {@link access} instead.
20
+ */
21
+ export declare function exists(this: V_Context, path: fs.PathLike, cb?: (exists: boolean) => unknown): void;
22
+ export declare function stat(this: V_Context, path: fs.PathLike, callback: Callback<[Stats]>): void;
23
+ export declare function stat(this: V_Context, path: fs.PathLike, options: {
24
+ bigint?: false;
25
+ }, callback: Callback<[Stats]>): void;
26
+ export declare function stat(this: V_Context, path: fs.PathLike, options: {
27
+ bigint: true;
28
+ }, callback: Callback<[BigIntStats]>): void;
29
+ export declare function stat(this: V_Context, path: fs.PathLike, options: fs.StatOptions, callback: Callback<[Stats] | [BigIntStats]>): void;
30
+ /**
31
+ * Asynchronous `lstat`.
32
+ * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
33
+ * then the link itself is stat-ed, not the file that it refers to.
34
+ */
35
+ export declare function lstat(this: V_Context, path: fs.PathLike, callback: Callback<[Stats]>): void;
36
+ export declare function lstat(this: V_Context, path: fs.PathLike, options: fs.StatOptions & {
37
+ bigint?: false;
38
+ }, callback: Callback<[Stats]>): void;
39
+ export declare function lstat(this: V_Context, path: fs.PathLike, options: fs.StatOptions & {
40
+ bigint: true;
41
+ }, callback: Callback<[BigIntStats]>): void;
42
+ export declare function lstat(this: V_Context, path: fs.PathLike, options: fs.StatOptions, callback: Callback<[Stats | BigIntStats]>): void;
43
+ export declare function truncate(this: V_Context, path: fs.PathLike, cb?: Callback): void;
44
+ export declare function truncate(this: V_Context, path: fs.PathLike, len: number, cb?: Callback): void;
45
+ export declare function unlink(this: V_Context, path: fs.PathLike, cb?: Callback): void;
46
+ /**
47
+ * Asynchronous file open.
48
+ * Exclusive mode ensures that path is newly created.
49
+ * Mode defaults to `0644`
50
+ *
51
+ * @see https://nodejs.org/api/fs.html#fsopenpath-flags-mode-callback
52
+ * @param flags {@link https://nodejs.org/api/fs.html#file-system-flags}
53
+ */
54
+ export declare function open(this: V_Context, path: fs.PathLike, flag: fs.OpenMode, cb?: Callback<[number]>): void;
55
+ export declare function open(this: V_Context, path: fs.PathLike, flag: fs.OpenMode, mode: number | string, cb?: Callback<[number]>): void;
56
+ /**
57
+ * Asynchronously reads the entire contents of a file.
58
+ * @option encoding The string encoding for the file contents. Defaults to `null`.
59
+ * @option flag Defaults to `'r'`.
60
+ * @param cb If no encoding is specified, then the raw buffer is returned.
61
+ */
62
+ export declare function readFile(this: V_Context, filename: fs.PathLike, cb: Callback<[Uint8Array]>): void;
63
+ export declare function readFile(this: V_Context, filename: fs.PathLike, options: {
64
+ flag?: string;
65
+ }, callback?: Callback<[Uint8Array]>): void;
66
+ export declare function readFile(this: V_Context, filename: fs.PathLike, options: {
67
+ encoding: BufferEncoding;
68
+ flag?: string;
69
+ } | BufferEncoding, cb: Callback<[string]>): void;
70
+ /**
71
+ * Asynchronously writes data to a file, replacing the file if it already
72
+ * exists.
73
+ *
74
+ * The encoding option is ignored if data is a buffer.
75
+ *
76
+ * @option encoding Defaults to `'utf8'`.
77
+ * @option mode Defaults to `0644`.
78
+ * @option flag Defaults to `'w'`.
79
+ */
80
+ export declare function writeFile(this: V_Context, filename: fs.PathLike, data: FileContents, cb?: Callback): void;
81
+ export declare function writeFile(this: V_Context, filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
82
+ export declare function writeFile(this: V_Context, filename: fs.PathLike, data: FileContents, options?: fs.WriteFileOptions, cb?: Callback): void;
83
+ /**
84
+ * Asynchronously append data to a file, creating the file if it not yet
85
+ * exists.
86
+ *
87
+ * @option encoding Defaults to `'utf8'`.
88
+ * @option mode Defaults to `0644`.
89
+ * @option flag Defaults to `'a'`.
90
+ */
91
+ export declare function appendFile(this: V_Context, filename: fs.PathLike, data: FileContents, cb?: Callback): void;
92
+ export declare function appendFile(this: V_Context, filename: fs.PathLike, data: FileContents, options?: fs.EncodingOption & {
93
+ mode?: fs.Mode;
94
+ flag?: fs.OpenMode;
95
+ }, cb?: Callback): void;
96
+ export declare function appendFile(this: V_Context, filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
97
+ /**
98
+ * Asynchronous `fstat`.
99
+ * `fstat()` is identical to `stat()`, except that the file to be stat-ed is specified by the file descriptor `fd`.
100
+ */
101
+ export declare function fstat(this: V_Context, fd: number, cb: Callback<[Stats]>): void;
102
+ export declare function fstat(this: V_Context, fd: number, options: fs.StatOptions & {
103
+ bigint?: false;
104
+ }, cb: Callback<[Stats]>): void;
105
+ export declare function fstat(this: V_Context, fd: number, options: fs.StatOptions & {
106
+ bigint: true;
107
+ }, cb: Callback<[BigIntStats]>): void;
108
+ export declare function close(this: V_Context, fd: number, cb?: Callback): void;
109
+ export declare function ftruncate(this: V_Context, fd: number, cb?: Callback): void;
110
+ export declare function ftruncate(this: V_Context, fd: number, len?: number, cb?: Callback): void;
111
+ export declare function fsync(this: V_Context, fd: number, cb?: Callback): void;
112
+ export declare function fdatasync(this: V_Context, fd: number, cb?: Callback): void;
113
+ /**
114
+ * Write buffer to the file specified by `fd`.
115
+ * Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback.
116
+ * @param buffer Uint8Array containing the data to write to the file.
117
+ * @param offset Offset in the buffer to start reading data from.
118
+ * @param length The amount of bytes to write to the file.
119
+ * @param position Offset from the beginning of the file where this data should be written.
120
+ * If position is null, the data will be written at the current position.
121
+ * @param cb The number specifies the number of bytes written into the file.
122
+ */
123
+ export declare function write(this: V_Context, fd: number, buffer: Uint8Array, offset: number, length: number, cb?: Callback<[number, Uint8Array]>): void;
124
+ export declare function write(this: V_Context, fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
125
+ export declare function write(this: V_Context, fd: number, data: FileContents, cb?: Callback<[number, string]>): void;
126
+ export declare function write(this: V_Context, fd: number, data: FileContents, position?: number, cb?: Callback<[number, string]>): void;
127
+ export declare function write(this: V_Context, fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?: Callback<[number, string]>): void;
128
+ /**
129
+ * Read data from the file specified by `fd`.
130
+ * @param buffer The buffer that the data will be written to.
131
+ * @param offset The offset within the buffer where writing will start.
132
+ * @param length An integer specifying the number of bytes to read.
133
+ * @param position An integer specifying where to begin reading from in the file.
134
+ * If position is null, data will be read from the current file position.
135
+ * @param cb The number is the number of bytes read
136
+ */
137
+ export declare function read(this: V_Context, fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
138
+ export declare function fchown(this: V_Context, fd: number, uid: number, gid: number, cb?: Callback): void;
139
+ export declare function fchmod(this: V_Context, fd: number, mode: string | number, cb: Callback): void;
140
+ /**
141
+ * Change the file timestamps of a file referenced by the supplied file descriptor.
142
+ */
143
+ export declare function futimes(this: V_Context, fd: number, atime: number | Date, mtime: number | Date, cb?: Callback): void;
144
+ export declare function rmdir(this: V_Context, path: fs.PathLike, cb?: Callback): void;
145
+ /**
146
+ * Asynchronous `mkdir`.
147
+ * @param mode defaults to `0777`
148
+ */
149
+ export declare function mkdir(this: V_Context, path: fs.PathLike, mode?: fs.Mode, cb?: Callback): void;
150
+ /**
151
+ * Asynchronous `readdir`. Reads the contents of a directory.
152
+ * The callback gets two arguments `(err, files)` where `files` is an array of
153
+ * the names of the files in the directory excluding `'.'` and `'..'`.
154
+ */
155
+ export declare function readdir(this: V_Context, path: fs.PathLike, cb: Callback<[string[]]>): void;
156
+ export declare function readdir(this: V_Context, path: fs.PathLike, options: {
157
+ withFileTypes?: false;
158
+ }, cb: Callback<[string[]]>): void;
159
+ export declare function readdir(this: V_Context, path: fs.PathLike, options: {
160
+ withFileTypes: true;
161
+ }, cb: Callback<[Dirent[]]>): void;
162
+ export declare function link(this: V_Context, existing: fs.PathLike, newpath: fs.PathLike, cb?: Callback): void;
163
+ /**
164
+ * Asynchronous `symlink`.
165
+ * @param target target path
166
+ * @param path link path
167
+ * Type defaults to file
168
+ */
169
+ export declare function symlink(this: V_Context, target: fs.PathLike, path: fs.PathLike, cb?: Callback): void;
170
+ export declare function symlink(this: V_Context, target: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type, cb?: Callback): void;
171
+ export declare function readlink(this: V_Context, path: fs.PathLike, callback: Callback<[string]>): void;
172
+ export declare function readlink(this: V_Context, path: fs.PathLike, options: fs.BufferEncodingOption, callback: Callback<[Uint8Array]>): void;
173
+ export declare function readlink(this: V_Context, path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string | Uint8Array]>): void;
174
+ export declare function readlink(this: V_Context, path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string]>): void;
175
+ export declare function chown(this: V_Context, path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
176
+ export declare function lchown(this: V_Context, path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
177
+ export declare function chmod(this: V_Context, path: fs.PathLike, mode: number | string, cb?: Callback): void;
178
+ export declare function lchmod(this: V_Context, path: fs.PathLike, mode: number | string, cb?: Callback): void;
179
+ /**
180
+ * Change file timestamps of the file referenced by the supplied path.
181
+ */
182
+ export declare function utimes(this: V_Context, path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
183
+ /**
184
+ * Change file timestamps of the file referenced by the supplied path.
185
+ */
186
+ export declare function lutimes(this: V_Context, path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
187
+ /**
188
+ * Asynchronous `realpath`. The callback gets two arguments
189
+ * `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.
190
+ */
191
+ export declare function realpath(this: V_Context, path: fs.PathLike, cb?: Callback<[string]>): void;
192
+ export declare function realpath(this: V_Context, path: fs.PathLike, options: fs.EncodingOption, cb: Callback<[string]>): void;
193
+ export declare function access(this: V_Context, path: fs.PathLike, cb: Callback): void;
194
+ export declare function access(this: V_Context, path: fs.PathLike, mode: number, cb: Callback): void;
195
+ /**
196
+ * Watch for changes on a file. The callback listener will be called each time the file is accessed.
197
+ *
198
+ * The `options` argument may be omitted. If provided, it should be an object with a `persistent` boolean and an `interval` number specifying the polling interval in milliseconds.
199
+ *
200
+ * When a change is detected, the `listener` callback is called with the current and previous `Stats` objects.
201
+ *
202
+ * @param path The path to the file to watch.
203
+ * @param options Optional options object specifying `persistent` and `interval`.
204
+ * @param listener The callback listener to be called when the file changes.
205
+ */
206
+ export declare function watchFile(this: V_Context, path: fs.PathLike, listener: (curr: Stats, prev: Stats) => void): void;
207
+ export declare function watchFile(this: V_Context, path: fs.PathLike, options: {
208
+ persistent?: boolean;
209
+ interval?: number;
210
+ }, listener: (curr: Stats, prev: Stats) => void): void;
211
+ /**
212
+ * Stop watching for changes on a file.
213
+ *
214
+ * If the `listener` is specified, only that particular listener is removed.
215
+ * If no `listener` is specified, all listeners are removed, and the file is no longer watched.
216
+ *
217
+ * @param path The path to the file to stop watching.
218
+ * @param listener Optional listener to remove.
219
+ */
220
+ export declare function unwatchFile(this: V_Context, path: fs.PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
221
+ export declare function watch(this: V_Context, path: fs.PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
222
+ export declare function watch(this: V_Context, path: fs.PathLike, options: {
223
+ persistent?: boolean;
224
+ }, listener?: (event: string, filename: string) => any): FSWatcher;
225
+ /**
226
+ * Opens a file in read mode and creates a Node.js-like ReadStream.
227
+ *
228
+ * @param path The path to the file to be opened.
229
+ * @param options Options for the ReadStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
230
+ * @returns A ReadStream object for interacting with the file's contents.
231
+ */
232
+ export declare function createReadStream(this: V_Context, path: fs.PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream;
233
+ /**
234
+ * Opens a file in write mode and creates a Node.js-like WriteStream.
235
+ *
236
+ * @param path The path to the file to be opened.
237
+ * @param options Options for the WriteStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
238
+ * @returns A WriteStream object for writing to the file.
239
+ */
240
+ export declare function createWriteStream(this: V_Context, path: fs.PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
241
+ export declare function rm(this: V_Context, path: fs.PathLike, callback: Callback): void;
242
+ export declare function rm(this: V_Context, path: fs.PathLike, options: fs.RmOptions, callback: Callback): void;
243
+ /**
244
+ * Asynchronously creates a unique temporary directory.
245
+ * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
246
+ */
247
+ export declare function mkdtemp(this: V_Context, prefix: string, callback: Callback<[string]>): void;
248
+ export declare function mkdtemp(this: V_Context, prefix: string, options: fs.EncodingOption, callback: Callback<[string]>): void;
249
+ export declare function mkdtemp(this: V_Context, prefix: string, options: fs.BufferEncodingOption, callback: Callback<[Buffer]>): void;
250
+ export declare function copyFile(this: V_Context, src: fs.PathLike, dest: fs.PathLike, callback: Callback): void;
251
+ export declare function copyFile(this: V_Context, src: fs.PathLike, dest: fs.PathLike, flags: number, callback: Callback): void;
252
+ type readvCb = Callback<[number, NodeJS.ArrayBufferView[]]>;
253
+ export declare function readv(this: V_Context, fd: number, buffers: NodeJS.ArrayBufferView[], cb: readvCb): void;
254
+ export declare function readv(this: V_Context, fd: number, buffers: NodeJS.ArrayBufferView[], position: number, cb: readvCb): void;
255
+ type writevCb = Callback<[number, NodeJS.ArrayBufferView[]]>;
256
+ export declare function writev(this: V_Context, fd: number, buffers: Uint8Array[], cb: writevCb): void;
257
+ export declare function writev(this: V_Context, fd: number, buffers: Uint8Array[], position: number, cb: writevCb): void;
258
+ export declare function opendir(this: V_Context, path: fs.PathLike, cb: Callback<[Dir]>): void;
259
+ export declare function opendir(this: V_Context, path: fs.PathLike, options: fs.OpenDirOptions, cb: Callback<[Dir]>): void;
260
+ export declare function cp(this: V_Context, source: fs.PathLike, destination: fs.PathLike, callback: Callback): void;
261
+ export declare function cp(this: V_Context, source: fs.PathLike, destination: fs.PathLike, opts: fs.CopyOptions, callback: Callback): void;
262
+ export declare function statfs(this: V_Context, path: fs.PathLike, callback: Callback<[fs.StatsFs]>): void;
263
+ export declare function statfs(this: V_Context, path: fs.PathLike, options: fs.StatFsOptions & {
264
+ bigint?: false;
265
+ }, callback: Callback<[fs.StatsFs]>): void;
266
+ export declare function statfs(this: V_Context, path: fs.PathLike, options: fs.StatFsOptions & {
267
+ bigint: true;
268
+ }, callback: Callback<[fs.BigIntStatsFs]>): void;
269
+ export declare function openAsBlob(this: V_Context, path: fs.PathLike, options?: fs.OpenAsBlobOptions): Promise<Blob>;
270
+ type GlobCallback<Args extends unknown[]> = (e: Exception | null, ...args: Args) => unknown;
271
+ /**
272
+ * Retrieves the files matching the specified pattern.
273
+ */
274
+ export declare function glob(this: V_Context, pattern: string | readonly string[], callback: GlobCallback<[string[]]>): void;
275
+ export declare function glob(this: V_Context, pattern: string | readonly string[], options: fs.GlobOptionsWithFileTypes, callback: GlobCallback<[Dirent[]]>): void;
276
+ export declare function glob(this: V_Context, pattern: string | readonly string[], options: fs.GlobOptionsWithoutFileTypes, callback: GlobCallback<[string[]]>): void;
277
+ export declare function glob(this: V_Context, pattern: string | readonly string[], options: fs.GlobOptions, callback: GlobCallback<[Dirent[] | string[]]>): void;
278
+ export {};