@zenfs/core 0.0.12 → 0.2.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 (54) hide show
  1. package/dist/ApiError.d.ts +52 -15
  2. package/dist/ApiError.js +77 -50
  3. package/dist/FileIndex.d.ts +32 -35
  4. package/dist/FileIndex.js +93 -109
  5. package/dist/backends/AsyncMirror.d.ts +42 -43
  6. package/dist/backends/AsyncMirror.js +154 -147
  7. package/dist/backends/AsyncStore.d.ts +29 -28
  8. package/dist/backends/AsyncStore.js +375 -482
  9. package/dist/backends/FolderAdapter.js +8 -19
  10. package/dist/backends/InMemory.d.ts +16 -13
  11. package/dist/backends/InMemory.js +29 -14
  12. package/dist/backends/Locked.d.ts +8 -28
  13. package/dist/backends/Locked.js +74 -224
  14. package/dist/backends/OverlayFS.d.ts +26 -34
  15. package/dist/backends/OverlayFS.js +303 -511
  16. package/dist/backends/SyncStore.d.ts +54 -72
  17. package/dist/backends/SyncStore.js +159 -161
  18. package/dist/backends/backend.d.ts +45 -29
  19. package/dist/backends/backend.js +83 -13
  20. package/dist/backends/index.d.ts +6 -7
  21. package/dist/backends/index.js +5 -6
  22. package/dist/browser.min.js +21 -6
  23. package/dist/browser.min.js.map +4 -4
  24. package/dist/emulation/callbacks.d.ts +119 -113
  25. package/dist/emulation/callbacks.js +129 -92
  26. package/dist/emulation/constants.js +1 -1
  27. package/dist/emulation/dir.d.ts +55 -0
  28. package/dist/emulation/dir.js +104 -0
  29. package/dist/emulation/fs.d.ts +1 -2
  30. package/dist/emulation/fs.js +0 -1
  31. package/dist/emulation/index.d.ts +3 -0
  32. package/dist/emulation/index.js +3 -0
  33. package/dist/emulation/promises.d.ts +265 -145
  34. package/dist/emulation/promises.js +526 -383
  35. package/dist/emulation/shared.d.ts +20 -6
  36. package/dist/emulation/shared.js +22 -23
  37. package/dist/emulation/streams.d.ts +102 -0
  38. package/dist/emulation/streams.js +55 -0
  39. package/dist/emulation/sync.d.ts +98 -69
  40. package/dist/emulation/sync.js +280 -133
  41. package/dist/file.d.ts +175 -173
  42. package/dist/file.js +257 -273
  43. package/dist/filesystem.d.ts +71 -244
  44. package/dist/filesystem.js +67 -472
  45. package/dist/index.d.ts +7 -44
  46. package/dist/index.js +22 -75
  47. package/dist/inode.d.ts +37 -28
  48. package/dist/inode.js +123 -65
  49. package/dist/stats.d.ts +91 -36
  50. package/dist/stats.js +138 -110
  51. package/dist/utils.d.ts +26 -13
  52. package/dist/utils.js +79 -107
  53. package/package.json +7 -4
  54. package/readme.md +2 -40
@@ -1,162 +1,269 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /// <reference types="node" resolution-mode="require"/>
3
- import type { ReadStream, WriteStream, FSWatcher, symlink as _symlink } from 'node:fs';
4
- import * as constants from './constants.js';
5
- export { constants };
3
+ /// <reference types="node" resolution-mode="require"/>
4
+ import type * as Node from 'node:fs';
5
+ export * as constants from './constants.js';
6
+ import type { PathLike, BufferToUint8Array } from './shared.js';
6
7
  import { FileContents } from '../filesystem.js';
7
- import { Stats } from '../stats.js';
8
+ import { BigIntStats, Stats } from '../stats.js';
9
+ import { Dirent } from './dir.js';
10
+ export declare class FileHandle implements BufferToUint8Array<Node.promises.FileHandle> {
11
+ /**
12
+ * Gets the file descriptor for this file handle.
13
+ */
14
+ readonly fd: number;
15
+ constructor(
16
+ /**
17
+ * Gets the file descriptor for this file handle.
18
+ */
19
+ fd: number);
20
+ /**
21
+ * Asynchronous fchown(2) - Change ownership of a file.
22
+ */
23
+ chown(uid: number, gid: number): Promise<void>;
24
+ /**
25
+ * Asynchronous fchmod(2) - Change permissions of a file.
26
+ * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
27
+ */
28
+ chmod(mode: Node.Mode): Promise<void>;
29
+ /**
30
+ * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
31
+ */
32
+ datasync(): Promise<void>;
33
+ /**
34
+ * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
35
+ */
36
+ sync(): Promise<void>;
37
+ /**
38
+ * Asynchronous ftruncate(2) - Truncate a file to a specified length.
39
+ * @param len If not specified, defaults to `0`.
40
+ */
41
+ truncate(len?: number): Promise<void>;
42
+ /**
43
+ * Asynchronously change file timestamps of the file.
44
+ * @param atime The last access time. If a string is provided, it will be coerced to number.
45
+ * @param mtime The last modified time. If a string is provided, it will be coerced to number.
46
+ */
47
+ utimes(atime: string | number | Date, mtime: string | number | Date): Promise<void>;
48
+ /**
49
+ * Asynchronously append data to a file, creating the file if it does not exist. The underlying file will _not_ be closed automatically.
50
+ * The `FileHandle` must have been opened for appending.
51
+ * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
52
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
53
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
54
+ * If `mode` is not supplied, the default of `0o666` is used.
55
+ * If `mode` is a string, it is parsed as an octal integer.
56
+ * If `flag` is not supplied, the default of `'a'` is used.
57
+ */
58
+ appendFile(data: string | Uint8Array, options?: {
59
+ encoding?: BufferEncoding;
60
+ mode?: Node.Mode;
61
+ flag?: Node.OpenMode;
62
+ } | BufferEncoding): Promise<void>;
63
+ /**
64
+ * Asynchronously reads data from the file.
65
+ * The `FileHandle` must have been opened for reading.
66
+ * @param buffer The buffer that the data will be written to.
67
+ * @param offset The offset in the buffer at which to start writing.
68
+ * @param length The number of bytes to read.
69
+ * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
70
+ */
71
+ read<TBuffer extends Uint8Array>(buffer: TBuffer, offset?: number, length?: number, position?: number): Promise<{
72
+ bytesRead: number;
73
+ buffer: TBuffer;
74
+ }>;
75
+ /**
76
+ * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
77
+ * The `FileHandle` must have been opened for reading.
78
+ * @param options An object that may contain an optional flag.
79
+ * If a flag is not provided, it defaults to `'r'`.
80
+ */
81
+ readFile(options?: {
82
+ flag?: Node.OpenMode;
83
+ }): Promise<Uint8Array>;
84
+ readFile(options: {
85
+ encoding: BufferEncoding;
86
+ flag?: Node.OpenMode;
87
+ } | BufferEncoding): Promise<string>;
88
+ /**
89
+ * Asynchronous fstat(2) - Get file status.
90
+ */
91
+ stat(opts: Node.BigIntOptions): Promise<BigIntStats>;
92
+ stat(opts?: Node.StatOptions & {
93
+ bigint?: false;
94
+ }): Promise<Stats>;
95
+ write(data: FileContents, posOrOff?: number, lenOrEnc?: BufferEncoding | number, position?: number): Promise<{
96
+ bytesWritten: number;
97
+ buffer: FileContents;
98
+ }>;
99
+ /**
100
+ * Asynchronously writes `buffer` to the file.
101
+ * The `FileHandle` must have been opened for writing.
102
+ * @param buffer The buffer that the data will be written to.
103
+ * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
104
+ * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
105
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
106
+ */
107
+ write(buffer: Uint8Array, offset?: number, length?: number, position?: number): Promise<{
108
+ bytesWritten: number;
109
+ buffer: Uint8Array;
110
+ }>;
111
+ /**
112
+ * Asynchronously writes `string` to the file.
113
+ * The `FileHandle` must have been opened for writing.
114
+ * It is unsafe to call `write()` multiple times on the same file without waiting for the `Promise`
115
+ * to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
116
+ * @param string A string to write.
117
+ * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
118
+ * @param encoding The expected string encoding.
119
+ */
120
+ write(data: string, position?: number, encoding?: BufferEncoding): Promise<{
121
+ bytesWritten: number;
122
+ buffer: string;
123
+ }>;
124
+ /**
125
+ * Asynchronously writes data to a file, replacing the file if it already exists. The underlying file will _not_ be closed automatically.
126
+ * The `FileHandle` must have been opened for writing.
127
+ * It is unsafe to call `writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
128
+ * @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
129
+ * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
130
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
131
+ * If `mode` is not supplied, the default of `0o666` is used.
132
+ * If `mode` is a string, it is parsed as an octal integer.
133
+ * If `flag` is not supplied, the default of `'w'` is used.
134
+ */
135
+ writeFile(data: string | Uint8Array, options?: Node.WriteFileOptions): Promise<void>;
136
+ /**
137
+ * See `fs.writev` promisified version.
138
+ */
139
+ writev(buffers: ReadonlyArray<Uint8Array>, position?: number): Promise<Node.WriteVResult>;
140
+ /**
141
+ * See `fs.readv` promisified version.
142
+ */
143
+ readv(buffers: ReadonlyArray<Uint8Array>, position?: number): Promise<Node.ReadVResult>;
144
+ /**
145
+ * Asynchronous close(2) - close a `FileHandle`.
146
+ */
147
+ close(): Promise<void>;
148
+ }
8
149
  /**
9
150
  * Renames a file
10
151
  * @param oldPath
11
152
  * @param newPath
12
153
  */
13
- export declare function rename(oldPath: string, newPath: string): Promise<void>;
154
+ export declare function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
14
155
  /**
15
156
  * Test whether or not the given path exists by checking with the file system.
16
- * @param path
157
+ * @param _path
17
158
  */
18
- export declare function exists(path: string): Promise<boolean>;
159
+ export declare function exists(_path: PathLike): Promise<boolean>;
19
160
  /**
20
161
  * `stat`.
21
162
  * @param path
22
163
  * @returns Stats
23
164
  */
24
- export declare function stat(path: string): Promise<Stats>;
165
+ export declare function stat(path: PathLike, options: Node.BigIntOptions): Promise<BigIntStats>;
166
+ export declare function stat(path: PathLike, options?: {
167
+ bigint?: false;
168
+ }): Promise<Stats>;
169
+ export declare function stat(path: PathLike, options?: Node.StatOptions): Promise<Stats | BigIntStats>;
25
170
  /**
26
171
  * `lstat`.
27
172
  * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
28
173
  * then the link itself is stat-ed, not the file that it refers to.
29
174
  * @param path
30
- * @return [ZenFS.node.fs.Stats]
175
+ * @return
31
176
  */
32
- export declare function lstat(path: string): Promise<Stats>;
177
+ export declare function lstat(path: PathLike, options?: {
178
+ bigint?: false;
179
+ }): Promise<Stats>;
180
+ export declare function lstat(path: PathLike, options: {
181
+ bigint: true;
182
+ }): Promise<BigIntStats>;
33
183
  /**
34
184
  * `truncate`.
35
185
  * @param path
36
186
  * @param len
37
187
  */
38
- export declare function truncate(path: string, len?: number): Promise<void>;
188
+ export declare function truncate(path: PathLike, len?: number): Promise<void>;
39
189
  /**
40
190
  * `unlink`.
41
191
  * @param path
42
192
  */
43
- export declare function unlink(path: string): Promise<void>;
193
+ export declare function unlink(path: PathLike): Promise<void>;
44
194
  /**
45
- * file open.
195
+ * Asynchronous file open.
46
196
  * @see http://www.manpagez.com/man/2/open/
47
- * @param path
48
- * @param flags
49
- * @param mode defaults to `0644`
197
+ * @param flags Handles the complexity of the various file modes. See its API for more details.
198
+ * @param mode Mode to use to open the file. Can be ignored if the filesystem doesn't support permissions.
199
+ */
200
+ export declare function open(path: PathLike, flag: string, mode?: Node.Mode): Promise<FileHandle>;
201
+ /**
202
+ * Opens a file without resolving symlinks
203
+ * @internal
50
204
  */
51
- export declare function open(path: string, flag: string, mode?: number | string): Promise<number>;
205
+ export declare function lopen(path: PathLike, flag: string, mode?: Node.Mode): Promise<FileHandle>;
52
206
  /**
53
- * Synchronously reads the entire contents of a file.
207
+ * Asynchronously reads the entire contents of a file.
54
208
  * @param filename
55
209
  * @param options
56
- * @option options [String] encoding The string encoding for the file contents. Defaults to `null`.
57
- * @option options [String] flag Defaults to `'r'`.
58
- * @return [String | ZenFS.node.Uint8Array]
210
+ * options.encoding The string encoding for the file contents. Defaults to `null`.
211
+ * options.flag Defaults to `'r'`.
212
+ * @returns file data
59
213
  */
60
- export declare function readFile(filename: string, options?: {
61
- flag?: string;
214
+ export declare function readFile(filename: PathLike, options?: {
215
+ flag?: Node.OpenMode;
62
216
  }): Promise<Uint8Array>;
63
- export declare function readFile(filename: string, options: {
64
- encoding: string;
65
- flag?: string;
66
- }): Promise<string>;
67
- export declare function readFile(filename: string, encoding: string): Promise<string>;
217
+ export declare function readFile(filename: PathLike, options: {
218
+ encoding?: BufferEncoding;
219
+ flag?: Node.OpenMode;
220
+ } | BufferEncoding): Promise<string>;
68
221
  /**
69
- * Synchronously writes data to a file, replacing the file if it already
70
- * exists.
222
+ * Synchronously writes data to a file, replacing the file if it already exists.
71
223
  *
72
224
  * The encoding option is ignored if data is a buffer.
73
225
  * @param filename
74
226
  * @param data
75
- * @param options
76
- * @option options [String] encoding Defaults to `'utf8'`.
77
- * @option options [Number] mode Defaults to `0644`.
78
- * @option options [String] flag Defaults to `'w'`.
227
+ * @param _options
228
+ * @option options encoding Defaults to `'utf8'`.
229
+ * @option options mode Defaults to `0644`.
230
+ * @option options flag Defaults to `'w'`.
79
231
  */
80
- export declare function writeFile(filename: string, data: FileContents, options?: {
81
- encoding?: string;
82
- mode?: number | string;
83
- flag?: string;
84
- }): Promise<void>;
85
- export declare function writeFile(filename: string, data: FileContents, encoding?: string): Promise<void>;
86
- export declare function writeFile(filename: string, data: FileContents, options?: {
87
- encoding?: string;
88
- mode?: number | string;
89
- flag?: string;
90
- } | string): Promise<void>;
232
+ export declare function writeFile(filename: PathLike, data: FileContents, _options?: Node.WriteFileOptions): Promise<void>;
91
233
  /**
92
234
  * Asynchronously append data to a file, creating the file if it not yet
93
235
  * exists.
94
- *
95
- * @example Usage example
96
- * fs.appendFile('message.txt', 'data to append', function (err) {
97
- * if (err) throw err;
98
- * console.log('The "data to append" was appended to file!');
99
- * });
100
236
  * @param filename
101
237
  * @param data
102
238
  * @param options
103
- * @option options [String] encoding Defaults to `'utf8'`.
104
- * @option options [Number] mode Defaults to `0644`.
105
- * @option options [String] flag Defaults to `'a'`.
106
- */
107
- export declare function appendFile(filename: string, data: FileContents, options?: {
108
- encoding?: string;
109
- mode?: number | string;
110
- flag?: string;
111
- }): Promise<void>;
112
- export declare function appendFile(filename: string, data: FileContents, encoding?: string): Promise<void>;
113
- /**
114
- * `fstat`.
115
- * `fstat()` is identical to `stat()`, except that the file to be stat-ed is
116
- * specified by the file descriptor `fd`.
117
- * @param fd
118
- * @return [ZenFS.node.fs.Stats]
119
- */
120
- export declare function fstat(fd: number): Promise<Stats>;
121
- /**
122
- * close.
123
- * @param fd
124
- */
125
- export declare function close(fd: number): Promise<void>;
126
- /**
127
- * ftruncate.
128
- * @param fd
129
- * @param len
130
- */
131
- export declare function ftruncate(fd: number, len?: number): Promise<void>;
132
- /**
133
- * fsync.
134
- * @param fd
135
- */
136
- export declare function fsync(fd: number): Promise<void>;
137
- /**
138
- * fdatasync.
139
- * @param fd
239
+ * @option options encoding Defaults to `'utf8'`.
240
+ * @option options mode Defaults to `0644`.
241
+ * @option options flag Defaults to `'a'`.
140
242
  */
141
- export declare function fdatasync(fd: number): Promise<void>;
243
+ export declare function appendFile(filename: PathLike, data: FileContents, _options?: BufferEncoding | (Node.BaseEncodingOptions & {
244
+ mode?: Node.Mode;
245
+ flag?: Node.OpenMode;
246
+ })): Promise<void>;
142
247
  /**
143
248
  * Write buffer to the file specified by `fd`.
144
- * Note that it is unsafe to use fs.write multiple times on the same file
145
- * without waiting for it to return.
146
- * @param fd
147
- * @param buffer Uint8Array containing the data to write to
148
- * the file.
249
+ * Note that it is unsafe to use fs.write multiple times on the same file without waiting for it to return.
250
+ * @param handle
251
+ * @param data Uint8Array containing the data to write to the file.
149
252
  * @param offset Offset in the buffer to start reading data from.
150
253
  * @param length The amount of bytes to write to the file.
151
- * @param position Offset from the beginning of the file where this
152
- * data should be written. If position is null, the data will be written at
153
- * the current position.
254
+ * @param position Offset from the beginning of the file where this data should be written. If position is null, the data will be written at the current position.
154
255
  */
155
- export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number): Promise<number>;
156
- export declare function write(fd: number, data: string, position?: number | null, encoding?: BufferEncoding): Promise<number>;
256
+ export declare function write(handle: FileHandle, data: Uint8Array, offset: number, length: number, position?: number): Promise<{
257
+ bytesWritten: number;
258
+ buffer: Uint8Array;
259
+ }>;
260
+ export declare function write(handle: FileHandle, data: string, position?: number, encoding?: BufferEncoding): Promise<{
261
+ bytesWritten: number;
262
+ buffer: string;
263
+ }>;
157
264
  /**
158
265
  * Read data from the file specified by `fd`.
159
- * @param fd
266
+ * @param handle
160
267
  * @param buffer The buffer that the data will be
161
268
  * written to.
162
269
  * @param offset The offset within the buffer where writing will
@@ -166,144 +273,157 @@ export declare function write(fd: number, data: string, position?: number | null
166
273
  * in the file. If position is null, data will be read from the current file
167
274
  * position.
168
275
  */
169
- export declare function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number): Promise<{
276
+ export declare function read(handle: FileHandle, buffer: Uint8Array, offset: number, length: number, position?: number): Promise<{
170
277
  bytesRead: number;
171
278
  buffer: Uint8Array;
172
279
  }>;
173
280
  /**
174
281
  * `fchown`.
175
- * @param fd
282
+ * @param handle
176
283
  * @param uid
177
284
  * @param gid
178
285
  */
179
- export declare function fchown(fd: number, uid: number, gid: number): Promise<void>;
286
+ export declare function fchown(handle: FileHandle, uid: number, gid: number): Promise<void>;
180
287
  /**
181
288
  * `fchmod`.
182
- * @param fd
289
+ * @param handle
183
290
  * @param mode
184
291
  */
185
- export declare function fchmod(fd: number, mode: number | string): Promise<void>;
292
+ export declare function fchmod(handle: FileHandle, mode: Node.Mode): Promise<void>;
186
293
  /**
187
294
  * Change the file timestamps of a file referenced by the supplied file
188
295
  * descriptor.
189
- * @param fd
296
+ * @param handle
190
297
  * @param atime
191
298
  * @param mtime
192
299
  */
193
- export declare function futimes(fd: number, atime: number | Date, mtime: number | Date): Promise<void>;
300
+ export declare function futimes(handle: FileHandle, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
194
301
  /**
195
302
  * `rmdir`.
196
303
  * @param path
197
304
  */
198
- export declare function rmdir(path: string): Promise<void>;
305
+ export declare function rmdir(path: PathLike): Promise<void>;
199
306
  /**
200
307
  * `mkdir`.
201
308
  * @param path
202
309
  * @param mode defaults to `0777`
203
310
  */
204
- export declare function mkdir(path: string, mode?: number | string): Promise<void>;
311
+ export declare function mkdir(path: PathLike, mode?: Node.Mode | (Node.MakeDirectoryOptions & {
312
+ recursive?: false;
313
+ })): Promise<void>;
314
+ export declare function mkdir(path: PathLike, mode: Node.MakeDirectoryOptions & {
315
+ recursive: true;
316
+ }): Promise<string>;
205
317
  /**
206
318
  * `readdir`. Reads the contents of a directory.
207
319
  * @param path
208
- * @return [String[]]
209
320
  */
210
- export declare function readdir(path: string): Promise<string[]>;
321
+ export declare function readdir(path: PathLike, options?: (Node.BaseEncodingOptions & {
322
+ withFileTypes?: false;
323
+ }) | BufferEncoding): Promise<string[]>;
324
+ export declare function readdir(path: PathLike, options: Node.BufferEncodingOption & {
325
+ withFileTypes?: false;
326
+ }): Promise<Uint8Array[]>;
327
+ export declare function readdir(path: PathLike, options: Node.BaseEncodingOptions & {
328
+ withFileTypes: true;
329
+ }): Promise<Dirent[]>;
211
330
  /**
212
331
  * `link`.
213
- * @param srcpath
214
- * @param dstpath
332
+ * @param existing
333
+ * @param newpath
215
334
  */
216
- export declare function link(srcpath: string, dstpath: string): Promise<void>;
335
+ export declare function link(existing: PathLike, newpath: PathLike): Promise<void>;
217
336
  /**
218
337
  * `symlink`.
219
- * @param srcpath
220
- * @param dstpath
338
+ * @param target target path
339
+ * @param path link path
221
340
  * @param type can be either `'dir'` or `'file'` (default is `'file'`)
222
341
  */
223
- export declare function symlink(srcpath: string, dstpath: string, type?: _symlink.Type): Promise<void>;
342
+ export declare function symlink(target: PathLike, path: PathLike, type?: Node.symlink.Type): Promise<void>;
224
343
  /**
225
344
  * readlink.
226
345
  * @param path
227
- * @return [String]
228
346
  */
229
- export declare function readlink(path: string): Promise<string>;
347
+ export declare function readlink(path: PathLike, options: Node.BufferEncodingOption): Promise<Uint8Array>;
348
+ export declare function readlink(path: PathLike, options?: Node.BaseEncodingOptions | BufferEncoding): Promise<string>;
230
349
  /**
231
350
  * `chown`.
232
351
  * @param path
233
352
  * @param uid
234
353
  * @param gid
235
354
  */
236
- export declare function chown(path: string, uid: number, gid: number): Promise<void>;
355
+ export declare function chown(path: PathLike, uid: number, gid: number): Promise<void>;
237
356
  /**
238
357
  * `lchown`.
239
358
  * @param path
240
359
  * @param uid
241
360
  * @param gid
242
361
  */
243
- export declare function lchown(path: string, uid: number, gid: number): Promise<void>;
362
+ export declare function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
244
363
  /**
245
364
  * `chmod`.
246
365
  * @param path
247
366
  * @param mode
248
367
  */
249
- export declare function chmod(path: string, mode: string | number): Promise<void>;
368
+ export declare function chmod(path: PathLike, mode: Node.Mode): Promise<void>;
250
369
  /**
251
370
  * `lchmod`.
252
371
  * @param path
253
372
  * @param mode
254
373
  */
255
- export declare function lchmod(path: string, mode: number | string): Promise<void>;
374
+ export declare function lchmod(path: PathLike, mode: Node.Mode): Promise<void>;
256
375
  /**
257
376
  * Change file timestamps of the file referenced by the supplied path.
258
377
  * @param path
259
378
  * @param atime
260
379
  * @param mtime
261
380
  */
262
- export declare function utimes(path: string, atime: number | Date, mtime: number | Date): Promise<void>;
381
+ export declare function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
263
382
  /**
264
383
  * Change file timestamps of the file referenced by the supplied path.
265
384
  * @param path
266
385
  * @param atime
267
386
  * @param mtime
268
387
  */
269
- export declare function lutimes(path: string, atime: number | Date, mtime: number | Date): Promise<void>;
388
+ export declare function lutimes(path: PathLike, atime: number | Date, mtime: number | Date): Promise<void>;
270
389
  /**
271
- * `realpath`.
272
- * @param path
273
- * @param cache An object literal of mapped paths that can be used to
274
- * force a specific path resolution or avoid additional `fs.stat` calls for
275
- * known real paths.
276
- * @return [String]
390
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
391
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
392
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
393
+ *
394
+ * Note: This *Can not* use doOp since doOp depends on it
277
395
  */
278
- export declare function realpath(path: string, cache?: {
279
- [path: string]: string;
280
- }): Promise<string>;
281
- export declare function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): Promise<void>;
282
- export declare function watchFile(filename: string, options: {
396
+ export declare function realpath(path: PathLike, options: Node.BufferEncodingOption): Promise<Uint8Array>;
397
+ export declare function realpath(path: PathLike, options?: Node.BaseEncodingOptions | BufferEncoding): Promise<string>;
398
+ export declare function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): Promise<void>;
399
+ export declare function watchFile(filename: PathLike, options: {
283
400
  persistent?: boolean;
284
401
  interval?: number;
285
402
  }, listener: (curr: Stats, prev: Stats) => void): Promise<void>;
286
- export declare function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): Promise<void>;
287
- export declare function watch(filename: string, listener?: (event: string, filename: string) => any): Promise<FSWatcher>;
288
- export declare function watch(filename: string, options: {
403
+ export declare function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): Promise<void>;
404
+ export declare function watch(filename: PathLike, listener?: (event: string, filename: PathLike) => any): Promise<Node.FSWatcher>;
405
+ export declare function watch(filename: PathLike, options: {
289
406
  persistent?: boolean;
290
- }, listener?: (event: string, filename: string) => any): Promise<FSWatcher>;
407
+ }, listener?: (event: string, filename: string) => any): Promise<Node.FSWatcher>;
291
408
  /**
292
409
  * `access`.
293
410
  * @param path
294
411
  * @param mode
295
412
  */
296
- export declare function access(path: string, mode?: number): Promise<void>;
297
- export declare function createReadStream(path: string, options?: {
413
+ export declare function access(path: PathLike, mode?: number): Promise<void>;
414
+ export declare function createReadStream(path: PathLike, options?: {
298
415
  flags?: string;
299
416
  encoding?: string;
300
417
  fd?: number;
301
418
  mode?: number;
302
419
  autoClose?: boolean;
303
- }): Promise<ReadStream>;
304
- export declare function createWriteStream(path: string, options?: {
420
+ }): Promise<Node.ReadStream>;
421
+ export declare function createWriteStream(path: PathLike, options?: {
305
422
  flags?: string;
306
423
  encoding?: string;
307
424
  fd?: number;
308
425
  mode?: number;
309
- }): Promise<WriteStream>;
426
+ }): Promise<Node.WriteStream>;
427
+ export declare function rm(path: PathLike): Promise<void>;
428
+ export declare function mkdtemp(path: PathLike): Promise<void>;
429
+ export declare function copyFile(path: PathLike): Promise<void>;