@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.
- package/dist/ApiError.d.ts +52 -15
- package/dist/ApiError.js +77 -50
- package/dist/FileIndex.d.ts +32 -35
- package/dist/FileIndex.js +93 -109
- package/dist/backends/AsyncMirror.d.ts +42 -43
- package/dist/backends/AsyncMirror.js +154 -147
- package/dist/backends/AsyncStore.d.ts +29 -28
- package/dist/backends/AsyncStore.js +375 -482
- package/dist/backends/FolderAdapter.js +8 -19
- package/dist/backends/InMemory.d.ts +16 -13
- package/dist/backends/InMemory.js +29 -14
- package/dist/backends/Locked.d.ts +8 -28
- package/dist/backends/Locked.js +74 -224
- package/dist/backends/OverlayFS.d.ts +26 -34
- package/dist/backends/OverlayFS.js +303 -511
- package/dist/backends/SyncStore.d.ts +54 -72
- package/dist/backends/SyncStore.js +159 -161
- package/dist/backends/backend.d.ts +45 -29
- package/dist/backends/backend.js +83 -13
- package/dist/backends/index.d.ts +6 -7
- package/dist/backends/index.js +5 -6
- package/dist/browser.min.js +21 -6
- package/dist/browser.min.js.map +4 -4
- package/dist/emulation/callbacks.d.ts +119 -113
- package/dist/emulation/callbacks.js +129 -92
- package/dist/emulation/constants.js +1 -1
- package/dist/emulation/dir.d.ts +55 -0
- package/dist/emulation/dir.js +104 -0
- package/dist/emulation/fs.d.ts +1 -2
- package/dist/emulation/fs.js +0 -1
- package/dist/emulation/index.d.ts +3 -0
- package/dist/emulation/index.js +3 -0
- package/dist/emulation/promises.d.ts +265 -145
- package/dist/emulation/promises.js +526 -383
- package/dist/emulation/shared.d.ts +20 -6
- package/dist/emulation/shared.js +22 -23
- package/dist/emulation/streams.d.ts +102 -0
- package/dist/emulation/streams.js +55 -0
- package/dist/emulation/sync.d.ts +98 -69
- package/dist/emulation/sync.js +280 -133
- package/dist/file.d.ts +175 -173
- package/dist/file.js +257 -273
- package/dist/filesystem.d.ts +71 -244
- package/dist/filesystem.js +67 -472
- package/dist/index.d.ts +7 -44
- package/dist/index.js +22 -75
- package/dist/inode.d.ts +37 -28
- package/dist/inode.js +123 -65
- package/dist/stats.d.ts +91 -36
- package/dist/stats.js +138 -110
- package/dist/utils.d.ts +26 -13
- package/dist/utils.js +79 -107
- package/package.json +7 -4
- 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
|
-
|
|
4
|
-
import * as
|
|
5
|
-
export
|
|
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:
|
|
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
|
|
157
|
+
* @param _path
|
|
17
158
|
*/
|
|
18
|
-
export declare function exists(
|
|
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:
|
|
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
|
|
175
|
+
* @return
|
|
31
176
|
*/
|
|
32
|
-
export declare function lstat(path:
|
|
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:
|
|
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:
|
|
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
|
|
48
|
-
* @param
|
|
49
|
-
|
|
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
|
|
205
|
+
export declare function lopen(path: PathLike, flag: string, mode?: Node.Mode): Promise<FileHandle>;
|
|
52
206
|
/**
|
|
53
|
-
*
|
|
207
|
+
* Asynchronously reads the entire contents of a file.
|
|
54
208
|
* @param filename
|
|
55
209
|
* @param options
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @
|
|
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:
|
|
61
|
-
flag?:
|
|
214
|
+
export declare function readFile(filename: PathLike, options?: {
|
|
215
|
+
flag?: Node.OpenMode;
|
|
62
216
|
}): Promise<Uint8Array>;
|
|
63
|
-
export declare function readFile(filename:
|
|
64
|
-
encoding
|
|
65
|
-
flag?:
|
|
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
|
|
76
|
-
* @option options
|
|
77
|
-
* @option options
|
|
78
|
-
* @option options
|
|
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:
|
|
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
|
|
104
|
-
* @option options
|
|
105
|
-
* @option options
|
|
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
|
|
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
|
-
*
|
|
146
|
-
* @param
|
|
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(
|
|
156
|
-
|
|
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
|
|
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(
|
|
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
|
|
282
|
+
* @param handle
|
|
176
283
|
* @param uid
|
|
177
284
|
* @param gid
|
|
178
285
|
*/
|
|
179
|
-
export declare function fchown(
|
|
286
|
+
export declare function fchown(handle: FileHandle, uid: number, gid: number): Promise<void>;
|
|
180
287
|
/**
|
|
181
288
|
* `fchmod`.
|
|
182
|
-
* @param
|
|
289
|
+
* @param handle
|
|
183
290
|
* @param mode
|
|
184
291
|
*/
|
|
185
|
-
export declare function fchmod(
|
|
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
|
|
296
|
+
* @param handle
|
|
190
297
|
* @param atime
|
|
191
298
|
* @param mtime
|
|
192
299
|
*/
|
|
193
|
-
export declare function futimes(
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
214
|
-
* @param
|
|
332
|
+
* @param existing
|
|
333
|
+
* @param newpath
|
|
215
334
|
*/
|
|
216
|
-
export declare function link(
|
|
335
|
+
export declare function link(existing: PathLike, newpath: PathLike): Promise<void>;
|
|
217
336
|
/**
|
|
218
337
|
* `symlink`.
|
|
219
|
-
* @param
|
|
220
|
-
* @param
|
|
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(
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
388
|
+
export declare function lutimes(path: PathLike, atime: number | Date, mtime: number | Date): Promise<void>;
|
|
270
389
|
/**
|
|
271
|
-
*
|
|
272
|
-
* @param path
|
|
273
|
-
* @param
|
|
274
|
-
*
|
|
275
|
-
*
|
|
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:
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
export declare function watchFile(filename:
|
|
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:
|
|
287
|
-
export declare function watch(filename:
|
|
288
|
-
export declare function watch(filename:
|
|
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:
|
|
297
|
-
export declare function createReadStream(path:
|
|
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:
|
|
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>;
|