@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
@@ -1,18 +1,28 @@
1
1
  // Utilities and shared data
2
2
  import { InMemory } from '../backends/memory.js';
3
+ import { bindContext } from '../context.js';
3
4
  import { Errno, ErrnoError } from '../error.js';
4
5
  import { normalizePath } from '../utils.js';
5
- import { resolve } from './path.js';
6
- import { size_max } from './constants.js';
7
6
  import { paths as pathCache } from './cache.js';
7
+ import { size_max } from './constants.js';
8
+ import { join, resolve } from './path.js';
8
9
  // descriptors
10
+ /**
11
+ * @internal @hidden
12
+ */
9
13
  export const fdMap = new Map();
10
14
  let nextFd = 100;
15
+ /**
16
+ * @internal @hidden
17
+ */
11
18
  export function file2fd(file) {
12
19
  const fd = nextFd++;
13
20
  fdMap.set(fd, file);
14
21
  return fd;
15
22
  }
23
+ /**
24
+ * @internal @hidden
25
+ */
16
26
  export function fd2file(fd) {
17
27
  if (!fdMap.has(fd)) {
18
28
  throw new ErrnoError(Errno.EBADF);
@@ -28,6 +38,7 @@ export const mounts = new Map();
28
38
  mount('/', InMemory.create({ name: 'root' }));
29
39
  /**
30
40
  * Mounts the file system at `mountPoint`.
41
+ * @internal
31
42
  */
32
43
  export function mount(mountPoint, fs) {
33
44
  if (mountPoint[0] !== '/') {
@@ -56,21 +67,23 @@ export function umount(mountPoint) {
56
67
  }
57
68
  /**
58
69
  * Gets the internal `FileSystem` for the path, then returns it along with the path relative to the FS' root
70
+ * @internal @hidden
59
71
  */
60
- export function resolveMount(path) {
61
- path = normalizePath(path);
72
+ export function resolveMount(path, ctx) {
73
+ const root = ctx?.root || '/';
74
+ path = normalizePath(join(root, path));
62
75
  const sortedMounts = [...mounts].sort((a, b) => (a[0].length > b[0].length ? -1 : 1)); // descending order of the string length
63
76
  for (const [mountPoint, fs] of sortedMounts) {
64
77
  // We know path is normalized, so it would be a substring of the mount point.
65
78
  if (mountPoint.length <= path.length && path.startsWith(mountPoint)) {
66
79
  path = path.slice(mountPoint.length > 1 ? mountPoint.length : 0); // Resolve the path relative to the mount point
67
80
  if (path === '') {
68
- path = '/';
81
+ path = root;
69
82
  }
70
- return { fs, path, mountPoint };
83
+ return { fs, path, mountPoint, root };
71
84
  }
72
85
  }
73
- throw new ErrnoError(Errno.EIO, 'ZenFS not initialized with a file system');
86
+ throw new ErrnoError(Errno.EIO, 'No file system');
74
87
  }
75
88
  /**
76
89
  * Wait for all file systems to be ready and synced.
@@ -83,7 +96,7 @@ export async function _synced() {
83
96
  }
84
97
  /**
85
98
  * Reverse maps the paths in text from the mounted FileSystem to the global path
86
- * @hidden
99
+ * @internal @hidden
87
100
  */
88
101
  export function fixPaths(text, paths) {
89
102
  for (const [from, to] of Object.entries(paths)) {
@@ -93,7 +106,7 @@ export function fixPaths(text, paths) {
93
106
  }
94
107
  /**
95
108
  * Fix paths in error stacks
96
- * @hidden
109
+ * @internal @hidden
97
110
  */
98
111
  export function fixError(e, paths) {
99
112
  if (typeof e.stack == 'string') {
@@ -105,10 +118,12 @@ export function fixError(e, paths) {
105
118
  catch {
106
119
  // `message` is read only
107
120
  }
121
+ if (e.path)
122
+ e.path = fixPaths(e.path, paths);
108
123
  return e;
109
124
  }
110
125
  /**
111
- * @deprecated
126
+ * @internal @deprecated
112
127
  */
113
128
  export function mountObject(mounts) {
114
129
  if ('/' in mounts) {
@@ -119,7 +134,7 @@ export function mountObject(mounts) {
119
134
  }
120
135
  }
121
136
  /**
122
- * @hidden
137
+ * @internal @hidden
123
138
  */
124
139
  export function _statfs(fs, bigint) {
125
140
  const md = fs.metadata();
@@ -134,3 +149,14 @@ export function _statfs(fs, bigint) {
134
149
  blocks: (bigint ? BigInt : Number)(md.totalSpace / bs),
135
150
  };
136
151
  }
152
+ export function chroot(path, inPlace) {
153
+ const creds = this?.credentials;
154
+ if (creds?.uid && creds?.gid && creds?.euid && creds?.egid) {
155
+ throw new ErrnoError(Errno.EPERM, 'Can not chroot() as non-root user');
156
+ }
157
+ if (inPlace && this) {
158
+ this.root += path;
159
+ return this;
160
+ }
161
+ return bindContext(join(this?.root || '/', path), creds);
162
+ }
@@ -4,15 +4,16 @@ import type { FileContents } from '../filesystem.js';
4
4
  import { BigIntStats, type Stats } from '../stats.js';
5
5
  import { Dir, Dirent } from './dir.js';
6
6
  import { type InternalOptions, type ReaddirOptions } from './shared.js';
7
- export declare function renameSync(oldPath: fs.PathLike, newPath: fs.PathLike): void;
7
+ import type { V_Context } from '../context.js';
8
+ export declare function renameSync(this: V_Context, oldPath: fs.PathLike, newPath: fs.PathLike): void;
8
9
  /**
9
10
  * Test whether or not `path` exists by checking with the file system.
10
11
  */
11
- export declare function existsSync(path: fs.PathLike): boolean;
12
- export declare function statSync(path: fs.PathLike, options?: {
12
+ export declare function existsSync(this: V_Context, path: fs.PathLike): boolean;
13
+ export declare function statSync(this: V_Context, path: fs.PathLike, options?: {
13
14
  bigint?: boolean;
14
15
  }): Stats;
15
- export declare function statSync(path: fs.PathLike, options: {
16
+ export declare function statSync(this: V_Context, path: fs.PathLike, options: {
16
17
  bigint: true;
17
18
  }): BigIntStats;
18
19
  /**
@@ -20,34 +21,34 @@ export declare function statSync(path: fs.PathLike, options: {
20
21
  * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
21
22
  * then the link itself is stat-ed, not the file that it refers to.
22
23
  */
23
- export declare function lstatSync(path: fs.PathLike, options?: {
24
+ export declare function lstatSync(this: V_Context, path: fs.PathLike, options?: {
24
25
  bigint?: boolean;
25
26
  }): Stats;
26
- export declare function lstatSync(path: fs.PathLike, options: {
27
+ export declare function lstatSync(this: V_Context, path: fs.PathLike, options: {
27
28
  bigint: true;
28
29
  }): BigIntStats;
29
- export declare function truncateSync(path: fs.PathLike, len?: number | null): void;
30
- export declare function unlinkSync(path: fs.PathLike): void;
30
+ export declare function truncateSync(this: V_Context, path: fs.PathLike, len?: number | null): void;
31
+ export declare function unlinkSync(this: V_Context, path: fs.PathLike): void;
31
32
  /**
32
33
  * Synchronous file open.
33
34
  * @see http://www.manpagez.com/man/2/open/
34
35
  */
35
- export declare function openSync(path: fs.PathLike, flag: fs.OpenMode, mode?: fs.Mode | null): number;
36
+ export declare function openSync(this: V_Context, path: fs.PathLike, flag: fs.OpenMode, mode?: fs.Mode | null): number;
36
37
  /**
37
38
  * Opens a file or symlink
38
39
  * @internal
39
40
  */
40
- export declare function lopenSync(path: fs.PathLike, flag: string, mode?: fs.Mode | null): number;
41
+ export declare function lopenSync(this: V_Context, path: fs.PathLike, flag: string, mode?: fs.Mode | null): number;
41
42
  /**
42
43
  * Synchronously reads the entire contents of a file.
43
44
  * @option encoding The string encoding for the file contents. Defaults to `null`.
44
45
  * @option flag Defaults to `'r'`.
45
46
  * @returns file contents
46
47
  */
47
- export declare function readFileSync(path: fs.PathOrFileDescriptor, options?: {
48
+ export declare function readFileSync(this: V_Context, path: fs.PathOrFileDescriptor, options?: {
48
49
  flag?: string;
49
50
  } | null): Buffer;
50
- export declare function readFileSync(path: fs.PathOrFileDescriptor, options?: (fs.EncodingOption & {
51
+ export declare function readFileSync(this: V_Context, path: fs.PathOrFileDescriptor, options?: (fs.EncodingOption & {
51
52
  flag?: string;
52
53
  }) | BufferEncoding | null): string;
53
54
  /**
@@ -58,30 +59,30 @@ export declare function readFileSync(path: fs.PathOrFileDescriptor, options?: (f
58
59
  * @option mode Defaults to `0644`.
59
60
  * @option flag Defaults to `'w'`.
60
61
  */
61
- export declare function writeFileSync(path: fs.PathOrFileDescriptor, data: FileContents, options?: fs.WriteFileOptions): void;
62
- export declare function writeFileSync(path: fs.PathOrFileDescriptor, data: FileContents, encoding?: BufferEncoding): void;
62
+ export declare function writeFileSync(this: V_Context, path: fs.PathOrFileDescriptor, data: FileContents, options?: fs.WriteFileOptions): void;
63
+ export declare function writeFileSync(this: V_Context, path: fs.PathOrFileDescriptor, data: FileContents, encoding?: BufferEncoding): void;
63
64
  /**
64
65
  * Asynchronously append data to a file, creating the file if it not yet exists.
65
66
  * @option encoding Defaults to `'utf8'`.
66
67
  * @option mode Defaults to `0644`.
67
68
  * @option flag Defaults to `'a+'`.
68
69
  */
69
- export declare function appendFileSync(filename: fs.PathOrFileDescriptor, data: FileContents, _options?: fs.WriteFileOptions): void;
70
+ export declare function appendFileSync(this: V_Context, filename: fs.PathOrFileDescriptor, data: FileContents, _options?: fs.WriteFileOptions): void;
70
71
  /**
71
72
  * Synchronous `fstat`.
72
73
  * `fstat()` is identical to `stat()`, except that the file to be stat-ed is
73
74
  * specified by the file descriptor `fd`.
74
75
  */
75
- export declare function fstatSync(fd: number, options?: {
76
+ export declare function fstatSync(this: V_Context, fd: number, options?: {
76
77
  bigint?: boolean;
77
78
  }): Stats;
78
- export declare function fstatSync(fd: number, options: {
79
+ export declare function fstatSync(this: V_Context, fd: number, options: {
79
80
  bigint: true;
80
81
  }): BigIntStats;
81
- export declare function closeSync(fd: number): void;
82
- export declare function ftruncateSync(fd: number, len?: number | null): void;
83
- export declare function fsyncSync(fd: number): void;
84
- export declare function fdatasyncSync(fd: number): void;
82
+ export declare function closeSync(this: V_Context, fd: number): void;
83
+ export declare function ftruncateSync(this: V_Context, fd: number, len?: number | null): void;
84
+ export declare function fsyncSync(this: V_Context, fd: number): void;
85
+ export declare function fdatasyncSync(this: V_Context, fd: number): void;
85
86
  /**
86
87
  * Write buffer to the file specified by `fd`.
87
88
  * @param data Uint8Array containing the data to write to the file.
@@ -90,85 +91,85 @@ export declare function fdatasyncSync(fd: number): void;
90
91
  * @param position Offset from the beginning of the file where this data should be written.
91
92
  * If position is null, the data will be written at the current position.
92
93
  */
93
- export declare function writeSync(fd: number, data: ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
94
- export declare function writeSync(fd: number, data: string, position?: number | null, encoding?: BufferEncoding | null): number;
95
- export declare function readSync(fd: number, buffer: ArrayBufferView, options?: fs.ReadSyncOptions): number;
96
- export declare function readSync(fd: number, buffer: ArrayBufferView, offset: number, length: number, position?: fs.ReadPosition | null): number;
97
- export declare function fchownSync(fd: number, uid: number, gid: number): void;
98
- export declare function fchmodSync(fd: number, mode: number | string): void;
94
+ export declare function writeSync(this: V_Context, fd: number, data: ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
95
+ export declare function writeSync(this: V_Context, fd: number, data: string, position?: number | null, encoding?: BufferEncoding | null): number;
96
+ export declare function readSync(this: V_Context, fd: number, buffer: ArrayBufferView, options?: fs.ReadSyncOptions): number;
97
+ export declare function readSync(this: V_Context, fd: number, buffer: ArrayBufferView, offset: number, length: number, position?: fs.ReadPosition | null): number;
98
+ export declare function fchownSync(this: V_Context, fd: number, uid: number, gid: number): void;
99
+ export declare function fchmodSync(this: V_Context, fd: number, mode: number | string): void;
99
100
  /**
100
101
  * Change the file timestamps of a file referenced by the supplied file descriptor.
101
102
  */
102
- export declare function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
103
- export declare function rmdirSync(path: fs.PathLike): void;
103
+ export declare function futimesSync(this: V_Context, fd: number, atime: string | number | Date, mtime: string | number | Date): void;
104
+ export declare function rmdirSync(this: V_Context, path: fs.PathLike): void;
104
105
  /**
105
106
  * Synchronous `mkdir`. Mode defaults to `o777`.
106
107
  */
107
- export declare function mkdirSync(path: fs.PathLike, options: fs.MakeDirectoryOptions & {
108
+ export declare function mkdirSync(this: V_Context, path: fs.PathLike, options: fs.MakeDirectoryOptions & {
108
109
  recursive: true;
109
110
  }): string | undefined;
110
- export declare function mkdirSync(path: fs.PathLike, options?: fs.Mode | (fs.MakeDirectoryOptions & {
111
+ export declare function mkdirSync(this: V_Context, path: fs.PathLike, options?: fs.Mode | (fs.MakeDirectoryOptions & {
111
112
  recursive?: false;
112
113
  }) | null): void;
113
- export declare function mkdirSync(path: fs.PathLike, options?: fs.Mode | fs.MakeDirectoryOptions | null): string | undefined;
114
- export declare function readdirSync(path: fs.PathLike, options?: (fs.ObjectEncodingOptions & ReaddirOptions & {
114
+ export declare function mkdirSync(this: V_Context, path: fs.PathLike, options?: fs.Mode | fs.MakeDirectoryOptions | null): string | undefined;
115
+ export declare function readdirSync(this: V_Context, path: fs.PathLike, options?: (fs.ObjectEncodingOptions & ReaddirOptions & {
115
116
  withFileTypes?: false;
116
117
  }) | BufferEncoding | null): string[];
117
- export declare function readdirSync(path: fs.PathLike, options: fs.BufferEncodingOption & ReaddirOptions & {
118
+ export declare function readdirSync(this: V_Context, path: fs.PathLike, options: fs.BufferEncodingOption & ReaddirOptions & {
118
119
  withFileTypes?: false;
119
120
  }): Buffer[];
120
- export declare function readdirSync(path: fs.PathLike, options?: (fs.ObjectEncodingOptions & ReaddirOptions & {
121
+ export declare function readdirSync(this: V_Context, path: fs.PathLike, options?: (fs.ObjectEncodingOptions & ReaddirOptions & {
121
122
  withFileTypes?: false;
122
123
  }) | BufferEncoding | null): string[] | Buffer[];
123
- export declare function readdirSync(path: fs.PathLike, options: fs.ObjectEncodingOptions & ReaddirOptions & {
124
+ export declare function readdirSync(this: V_Context, path: fs.PathLike, options: fs.ObjectEncodingOptions & ReaddirOptions & {
124
125
  withFileTypes: true;
125
126
  }): Dirent[];
126
- export declare function readdirSync(path: fs.PathLike, options?: (ReaddirOptions & (fs.ObjectEncodingOptions | fs.BufferEncodingOption)) | BufferEncoding | null): string[] | Dirent[] | Buffer[];
127
- export declare function linkSync(targetPath: fs.PathLike, linkPath: fs.PathLike): void;
127
+ export declare function readdirSync(this: V_Context, path: fs.PathLike, options?: (ReaddirOptions & (fs.ObjectEncodingOptions | fs.BufferEncodingOption)) | BufferEncoding | null): string[] | Dirent[] | Buffer[];
128
+ export declare function linkSync(this: V_Context, targetPath: fs.PathLike, linkPath: fs.PathLike): void;
128
129
  /**
129
130
  * Synchronous `symlink`.
130
131
  * @param target target path
131
132
  * @param path link path
132
133
  * @param type can be either `'dir'` or `'file'` (default is `'file'`)
133
134
  */
134
- export declare function symlinkSync(target: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type | null): void;
135
- export declare function readlinkSync(path: fs.PathLike, options?: fs.BufferEncodingOption): Buffer;
136
- export declare function readlinkSync(path: fs.PathLike, options: fs.EncodingOption | BufferEncoding): string;
137
- export declare function readlinkSync(path: fs.PathLike, options?: fs.EncodingOption | BufferEncoding | fs.BufferEncodingOption): Buffer | string;
138
- export declare function chownSync(path: fs.PathLike, uid: number, gid: number): void;
139
- export declare function lchownSync(path: fs.PathLike, uid: number, gid: number): void;
140
- export declare function chmodSync(path: fs.PathLike, mode: fs.Mode): void;
141
- export declare function lchmodSync(path: fs.PathLike, mode: number | string): void;
135
+ export declare function symlinkSync(this: V_Context, target: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type | null): void;
136
+ export declare function readlinkSync(this: V_Context, path: fs.PathLike, options?: fs.BufferEncodingOption): Buffer;
137
+ export declare function readlinkSync(this: V_Context, path: fs.PathLike, options: fs.EncodingOption | BufferEncoding): string;
138
+ export declare function readlinkSync(this: V_Context, path: fs.PathLike, options?: fs.EncodingOption | BufferEncoding | fs.BufferEncodingOption): Buffer | string;
139
+ export declare function chownSync(this: V_Context, path: fs.PathLike, uid: number, gid: number): void;
140
+ export declare function lchownSync(this: V_Context, path: fs.PathLike, uid: number, gid: number): void;
141
+ export declare function chmodSync(this: V_Context, path: fs.PathLike, mode: fs.Mode): void;
142
+ export declare function lchmodSync(this: V_Context, path: fs.PathLike, mode: number | string): void;
142
143
  /**
143
144
  * Change file timestamps of the file referenced by the supplied path.
144
145
  */
145
- export declare function utimesSync(path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): void;
146
+ export declare function utimesSync(this: V_Context, path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): void;
146
147
  /**
147
148
  * Change file timestamps of the file referenced by the supplied path.
148
149
  */
149
- export declare function lutimesSync(path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): void;
150
- export declare function realpathSync(path: fs.PathLike, options: fs.BufferEncodingOption): Buffer;
151
- export declare function realpathSync(path: fs.PathLike, options?: fs.EncodingOption): string;
152
- export declare function accessSync(path: fs.PathLike, mode?: number): void;
150
+ export declare function lutimesSync(this: V_Context, path: fs.PathLike, atime: string | number | Date, mtime: string | number | Date): void;
151
+ export declare function realpathSync(this: V_Context, path: fs.PathLike, options: fs.BufferEncodingOption): Buffer;
152
+ export declare function realpathSync(this: V_Context, path: fs.PathLike, options?: fs.EncodingOption): string;
153
+ export declare function accessSync(this: V_Context, path: fs.PathLike, mode?: number): void;
153
154
  /**
154
155
  * Synchronous `rm`. Removes files or directories (recursively).
155
156
  * @param path The path to the file or directory to remove.
156
157
  */
157
- export declare function rmSync(path: fs.PathLike, options?: fs.RmOptions & InternalOptions): void;
158
+ export declare function rmSync(this: V_Context, path: fs.PathLike, options?: fs.RmOptions & InternalOptions): void;
158
159
  /**
159
160
  * Synchronous `mkdtemp`. Creates a unique temporary directory.
160
161
  * @param prefix The directory prefix.
161
162
  * @param options The encoding (or an object including `encoding`).
162
163
  * @returns The path to the created temporary directory, encoded as a string or buffer.
163
164
  */
164
- export declare function mkdtempSync(prefix: string, options: fs.BufferEncodingOption): Buffer;
165
- export declare function mkdtempSync(prefix: string, options?: fs.EncodingOption): string;
165
+ export declare function mkdtempSync(this: V_Context, prefix: string, options: fs.BufferEncodingOption): Buffer;
166
+ export declare function mkdtempSync(this: V_Context, prefix: string, options?: fs.EncodingOption): string;
166
167
  /**
167
168
  * Synchronous `copyFile`. Copies a file.
168
169
  * @param flags Optional flags for the copy operation. Currently supports these flags:
169
170
  * - `fs.constants.COPYFILE_EXCL`: If the destination file already exists, the operation fails.
170
171
  */
171
- export declare function copyFileSync(source: fs.PathLike, destination: fs.PathLike, flags?: number): void;
172
+ export declare function copyFileSync(this: V_Context, source: fs.PathLike, destination: fs.PathLike, flags?: number): void;
172
173
  /**
173
174
  * Synchronous `readv`. Reads from a file descriptor into multiple buffers.
174
175
  * @param fd The file descriptor.
@@ -176,7 +177,7 @@ export declare function copyFileSync(source: fs.PathLike, destination: fs.PathLi
176
177
  * @param position The position in the file where to begin reading.
177
178
  * @returns The number of bytes read.
178
179
  */
179
- export declare function readvSync(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number;
180
+ export declare function readvSync(this: V_Context, fd: number, buffers: readonly NodeJS.ArrayBufferView[], position?: number): number;
180
181
  /**
181
182
  * Synchronous `writev`. Writes from multiple buffers into a file descriptor.
182
183
  * @param fd The file descriptor.
@@ -184,7 +185,7 @@ export declare function readvSync(fd: number, buffers: readonly NodeJS.ArrayBuff
184
185
  * @param position The position in the file where to begin writing.
185
186
  * @returns The number of bytes written.
186
187
  */
187
- export declare function writevSync(fd: number, buffers: readonly ArrayBufferView[], position?: number): number;
188
+ export declare function writevSync(this: V_Context, fd: number, buffers: readonly ArrayBufferView[], position?: number): number;
188
189
  /**
189
190
  * Synchronous `opendir`. Opens a directory.
190
191
  * @param path The path to the directory.
@@ -192,7 +193,7 @@ export declare function writevSync(fd: number, buffers: readonly ArrayBufferView
192
193
  * @returns A `Dir` object representing the opened directory.
193
194
  * @todo Handle options
194
195
  */
195
- export declare function opendirSync(path: fs.PathLike, options?: fs.OpenDirOptions): Dir;
196
+ export declare function opendirSync(this: V_Context, path: fs.PathLike, options?: fs.OpenDirOptions): Dir;
196
197
  /**
197
198
  * Synchronous `cp`. Recursively copies a file or directory.
198
199
  * @param source The source file or directory.
@@ -205,16 +206,16 @@ export declare function opendirSync(path: fs.PathLike, options?: fs.OpenDirOptio
205
206
  * - `preserveTimestamps`: Preserve file timestamps.
206
207
  * - `recursive`: If `true`, copies directories recursively.
207
208
  */
208
- export declare function cpSync(source: fs.PathLike, destination: fs.PathLike, opts?: fs.CopySyncOptions): void;
209
+ export declare function cpSync(this: V_Context, source: fs.PathLike, destination: fs.PathLike, opts?: fs.CopySyncOptions): void;
209
210
  /**
210
211
  * Synchronous statfs(2). Returns information about the mounted file system which contains path.
211
212
  * In case of an error, the err.code will be one of Common System Errors.
212
213
  * @param path A path to an existing file or directory on the file system to be queried.
213
214
  */
214
- export declare function statfsSync(path: fs.PathLike, options?: fs.StatFsOptions & {
215
+ export declare function statfsSync(this: V_Context, path: fs.PathLike, options?: fs.StatFsOptions & {
215
216
  bigint?: false;
216
217
  }): fs.StatsFs;
217
- export declare function statfsSync(path: fs.PathLike, options: fs.StatFsOptions & {
218
+ export declare function statfsSync(this: V_Context, path: fs.PathLike, options: fs.StatFsOptions & {
218
219
  bigint: true;
219
220
  }): fs.BigIntStatsFs;
220
- export declare function statfsSync(path: fs.PathLike, options?: fs.StatFsOptions): fs.StatsFs | fs.BigIntStatsFs;
221
+ export declare function statfsSync(this: V_Context, path: fs.PathLike, options?: fs.StatFsOptions): fs.StatsFs | fs.BigIntStatsFs;