1
|
declare module "fs" {
|
2
|
import * as stream from "stream";
|
3
|
import * as events from "events";
|
4
|
import { URL } from "url";
|
5
|
|
6
|
/**
|
7
|
* Valid types for path values in "fs".
|
8
|
*/
|
9
|
type PathLike = string | Buffer | URL;
|
10
|
|
11
|
type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
|
12
|
|
13
|
interface StatsBase<T> {
|
14
|
isFile(): boolean;
|
15
|
isDirectory(): boolean;
|
16
|
isBlockDevice(): boolean;
|
17
|
isCharacterDevice(): boolean;
|
18
|
isSymbolicLink(): boolean;
|
19
|
isFIFO(): boolean;
|
20
|
isSocket(): boolean;
|
21
|
|
22
|
dev: T;
|
23
|
ino: T;
|
24
|
mode: T;
|
25
|
nlink: T;
|
26
|
uid: T;
|
27
|
gid: T;
|
28
|
rdev: T;
|
29
|
size: T;
|
30
|
blksize: T;
|
31
|
blocks: T;
|
32
|
atimeMs: T;
|
33
|
mtimeMs: T;
|
34
|
ctimeMs: T;
|
35
|
birthtimeMs: T;
|
36
|
atime: Date;
|
37
|
mtime: Date;
|
38
|
ctime: Date;
|
39
|
birthtime: Date;
|
40
|
}
|
41
|
|
42
|
interface Stats extends StatsBase<number> {
|
43
|
}
|
44
|
|
45
|
class Stats {
|
46
|
}
|
47
|
|
48
|
class Dirent {
|
49
|
isFile(): boolean;
|
50
|
isDirectory(): boolean;
|
51
|
isBlockDevice(): boolean;
|
52
|
isCharacterDevice(): boolean;
|
53
|
isSymbolicLink(): boolean;
|
54
|
isFIFO(): boolean;
|
55
|
isSocket(): boolean;
|
56
|
name: string;
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* A class representing a directory stream.
|
61
|
*/
|
62
|
class Dir {
|
63
|
readonly path: string;
|
64
|
|
65
|
/**
|
66
|
* Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
|
67
|
*/
|
68
|
[Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
|
69
|
|
70
|
/**
|
71
|
* Asynchronously close the directory's underlying resource handle.
|
72
|
* Subsequent reads will result in errors.
|
73
|
*/
|
74
|
close(): Promise<void>;
|
75
|
close(cb: NoParamCallback): void;
|
76
|
|
77
|
/**
|
78
|
* Synchronously close the directory's underlying resource handle.
|
79
|
* Subsequent reads will result in errors.
|
80
|
*/
|
81
|
closeSync(): void;
|
82
|
|
83
|
/**
|
84
|
* Asynchronously read the next directory entry via `readdir(3)` as an `Dirent`.
|
85
|
* After the read is completed, a value is returned that will be resolved with an `Dirent`, or `null` if there are no more directory entries to read.
|
86
|
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
|
87
|
*/
|
88
|
read(): Promise<Dirent | null>;
|
89
|
read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void;
|
90
|
|
91
|
/**
|
92
|
* Synchronously read the next directory entry via `readdir(3)` as a `Dirent`.
|
93
|
* If there are no more directory entries to read, null will be returned.
|
94
|
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
|
95
|
*/
|
96
|
readSync(): Dirent;
|
97
|
}
|
98
|
|
99
|
interface FSWatcher extends events.EventEmitter {
|
100
|
close(): void;
|
101
|
|
102
|
/**
|
103
|
* events.EventEmitter
|
104
|
* 1. change
|
105
|
* 2. error
|
106
|
*/
|
107
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
108
|
addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
109
|
addListener(event: "error", listener: (error: Error) => void): this;
|
110
|
addListener(event: "close", listener: () => void): this;
|
111
|
|
112
|
on(event: string, listener: (...args: any[]) => void): this;
|
113
|
on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
114
|
on(event: "error", listener: (error: Error) => void): this;
|
115
|
on(event: "close", listener: () => void): this;
|
116
|
|
117
|
once(event: string, listener: (...args: any[]) => void): this;
|
118
|
once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
119
|
once(event: "error", listener: (error: Error) => void): this;
|
120
|
once(event: "close", listener: () => void): this;
|
121
|
|
122
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
123
|
prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
124
|
prependListener(event: "error", listener: (error: Error) => void): this;
|
125
|
prependListener(event: "close", listener: () => void): this;
|
126
|
|
127
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
128
|
prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
|
129
|
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
130
|
prependOnceListener(event: "close", listener: () => void): this;
|
131
|
}
|
132
|
|
133
|
class ReadStream extends stream.Readable {
|
134
|
close(): void;
|
135
|
bytesRead: number;
|
136
|
path: string | Buffer;
|
137
|
pending: boolean;
|
138
|
|
139
|
/**
|
140
|
* events.EventEmitter
|
141
|
* 1. open
|
142
|
* 2. close
|
143
|
* 3. ready
|
144
|
*/
|
145
|
addListener(event: "close", listener: () => void): this;
|
146
|
addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
147
|
addListener(event: "end", listener: () => void): this;
|
148
|
addListener(event: "error", listener: (err: Error) => void): this;
|
149
|
addListener(event: "open", listener: (fd: number) => void): this;
|
150
|
addListener(event: "pause", listener: () => void): this;
|
151
|
addListener(event: "readable", listener: () => void): this;
|
152
|
addListener(event: "ready", listener: () => void): this;
|
153
|
addListener(event: "resume", listener: () => void): this;
|
154
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
155
|
|
156
|
on(event: "close", listener: () => void): this;
|
157
|
on(event: "data", listener: (chunk: Buffer | string) => void): this;
|
158
|
on(event: "end", listener: () => void): this;
|
159
|
on(event: "error", listener: (err: Error) => void): this;
|
160
|
on(event: "open", listener: (fd: number) => void): this;
|
161
|
on(event: "pause", listener: () => void): this;
|
162
|
on(event: "readable", listener: () => void): this;
|
163
|
on(event: "ready", listener: () => void): this;
|
164
|
on(event: "resume", listener: () => void): this;
|
165
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
166
|
|
167
|
once(event: "close", listener: () => void): this;
|
168
|
once(event: "data", listener: (chunk: Buffer | string) => void): this;
|
169
|
once(event: "end", listener: () => void): this;
|
170
|
once(event: "error", listener: (err: Error) => void): this;
|
171
|
once(event: "open", listener: (fd: number) => void): this;
|
172
|
once(event: "pause", listener: () => void): this;
|
173
|
once(event: "readable", listener: () => void): this;
|
174
|
once(event: "ready", listener: () => void): this;
|
175
|
once(event: "resume", listener: () => void): this;
|
176
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
177
|
|
178
|
prependListener(event: "close", listener: () => void): this;
|
179
|
prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
180
|
prependListener(event: "end", listener: () => void): this;
|
181
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
182
|
prependListener(event: "open", listener: (fd: number) => void): this;
|
183
|
prependListener(event: "pause", listener: () => void): this;
|
184
|
prependListener(event: "readable", listener: () => void): this;
|
185
|
prependListener(event: "ready", listener: () => void): this;
|
186
|
prependListener(event: "resume", listener: () => void): this;
|
187
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
188
|
|
189
|
prependOnceListener(event: "close", listener: () => void): this;
|
190
|
prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
|
191
|
prependOnceListener(event: "end", listener: () => void): this;
|
192
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
193
|
prependOnceListener(event: "open", listener: (fd: number) => void): this;
|
194
|
prependOnceListener(event: "pause", listener: () => void): this;
|
195
|
prependOnceListener(event: "readable", listener: () => void): this;
|
196
|
prependOnceListener(event: "ready", listener: () => void): this;
|
197
|
prependOnceListener(event: "resume", listener: () => void): this;
|
198
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
199
|
}
|
200
|
|
201
|
class WriteStream extends stream.Writable {
|
202
|
close(): void;
|
203
|
bytesWritten: number;
|
204
|
path: string | Buffer;
|
205
|
pending: boolean;
|
206
|
|
207
|
/**
|
208
|
* events.EventEmitter
|
209
|
* 1. open
|
210
|
* 2. close
|
211
|
* 3. ready
|
212
|
*/
|
213
|
addListener(event: "close", listener: () => void): this;
|
214
|
addListener(event: "drain", listener: () => void): this;
|
215
|
addListener(event: "error", listener: (err: Error) => void): this;
|
216
|
addListener(event: "finish", listener: () => void): this;
|
217
|
addListener(event: "open", listener: (fd: number) => void): this;
|
218
|
addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
219
|
addListener(event: "ready", listener: () => void): this;
|
220
|
addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
221
|
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
222
|
|
223
|
on(event: "close", listener: () => void): this;
|
224
|
on(event: "drain", listener: () => void): this;
|
225
|
on(event: "error", listener: (err: Error) => void): this;
|
226
|
on(event: "finish", listener: () => void): this;
|
227
|
on(event: "open", listener: (fd: number) => void): this;
|
228
|
on(event: "pipe", listener: (src: stream.Readable) => void): this;
|
229
|
on(event: "ready", listener: () => void): this;
|
230
|
on(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
231
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
232
|
|
233
|
once(event: "close", listener: () => void): this;
|
234
|
once(event: "drain", listener: () => void): this;
|
235
|
once(event: "error", listener: (err: Error) => void): this;
|
236
|
once(event: "finish", listener: () => void): this;
|
237
|
once(event: "open", listener: (fd: number) => void): this;
|
238
|
once(event: "pipe", listener: (src: stream.Readable) => void): this;
|
239
|
once(event: "ready", listener: () => void): this;
|
240
|
once(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
241
|
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
242
|
|
243
|
prependListener(event: "close", listener: () => void): this;
|
244
|
prependListener(event: "drain", listener: () => void): this;
|
245
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
246
|
prependListener(event: "finish", listener: () => void): this;
|
247
|
prependListener(event: "open", listener: (fd: number) => void): this;
|
248
|
prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
249
|
prependListener(event: "ready", listener: () => void): this;
|
250
|
prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
251
|
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
252
|
|
253
|
prependOnceListener(event: "close", listener: () => void): this;
|
254
|
prependOnceListener(event: "drain", listener: () => void): this;
|
255
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
256
|
prependOnceListener(event: "finish", listener: () => void): this;
|
257
|
prependOnceListener(event: "open", listener: (fd: number) => void): this;
|
258
|
prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
|
259
|
prependOnceListener(event: "ready", listener: () => void): this;
|
260
|
prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
|
261
|
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
262
|
}
|
263
|
|
264
|
/**
|
265
|
* Asynchronous rename(2) - Change the name or location of a file or directory.
|
266
|
* @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
267
|
* URL support is _experimental_.
|
268
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
269
|
* URL support is _experimental_.
|
270
|
*/
|
271
|
function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
|
272
|
|
273
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
274
|
namespace rename {
|
275
|
/**
|
276
|
* Asynchronous rename(2) - Change the name or location of a file or directory.
|
277
|
* @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
278
|
* URL support is _experimental_.
|
279
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
280
|
* URL support is _experimental_.
|
281
|
*/
|
282
|
function __promisify__(oldPath: PathLike, newPath: PathLike): Promise<void>;
|
283
|
}
|
284
|
|
285
|
/**
|
286
|
* Synchronous rename(2) - Change the name or location of a file or directory.
|
287
|
* @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
288
|
* URL support is _experimental_.
|
289
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
290
|
* URL support is _experimental_.
|
291
|
*/
|
292
|
function renameSync(oldPath: PathLike, newPath: PathLike): void;
|
293
|
|
294
|
/**
|
295
|
* Asynchronous truncate(2) - Truncate a file to a specified length.
|
296
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
297
|
* @param len If not specified, defaults to `0`.
|
298
|
*/
|
299
|
function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void;
|
300
|
|
301
|
/**
|
302
|
* Asynchronous truncate(2) - Truncate a file to a specified length.
|
303
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
304
|
* URL support is _experimental_.
|
305
|
*/
|
306
|
function truncate(path: PathLike, callback: NoParamCallback): void;
|
307
|
|
308
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
309
|
namespace truncate {
|
310
|
/**
|
311
|
* Asynchronous truncate(2) - Truncate a file to a specified length.
|
312
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
313
|
* @param len If not specified, defaults to `0`.
|
314
|
*/
|
315
|
function __promisify__(path: PathLike, len?: number | null): Promise<void>;
|
316
|
}
|
317
|
|
318
|
/**
|
319
|
* Synchronous truncate(2) - Truncate a file to a specified length.
|
320
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
321
|
* @param len If not specified, defaults to `0`.
|
322
|
*/
|
323
|
function truncateSync(path: PathLike, len?: number | null): void;
|
324
|
|
325
|
/**
|
326
|
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
327
|
* @param fd A file descriptor.
|
328
|
* @param len If not specified, defaults to `0`.
|
329
|
*/
|
330
|
function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void;
|
331
|
|
332
|
/**
|
333
|
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
334
|
* @param fd A file descriptor.
|
335
|
*/
|
336
|
function ftruncate(fd: number, callback: NoParamCallback): void;
|
337
|
|
338
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
339
|
namespace ftruncate {
|
340
|
/**
|
341
|
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
342
|
* @param fd A file descriptor.
|
343
|
* @param len If not specified, defaults to `0`.
|
344
|
*/
|
345
|
function __promisify__(fd: number, len?: number | null): Promise<void>;
|
346
|
}
|
347
|
|
348
|
/**
|
349
|
* Synchronous ftruncate(2) - Truncate a file to a specified length.
|
350
|
* @param fd A file descriptor.
|
351
|
* @param len If not specified, defaults to `0`.
|
352
|
*/
|
353
|
function ftruncateSync(fd: number, len?: number | null): void;
|
354
|
|
355
|
/**
|
356
|
* Asynchronous chown(2) - Change ownership of a file.
|
357
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
358
|
*/
|
359
|
function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
|
360
|
|
361
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
362
|
namespace chown {
|
363
|
/**
|
364
|
* Asynchronous chown(2) - Change ownership of a file.
|
365
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
366
|
*/
|
367
|
function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
|
368
|
}
|
369
|
|
370
|
/**
|
371
|
* Synchronous chown(2) - Change ownership of a file.
|
372
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
373
|
*/
|
374
|
function chownSync(path: PathLike, uid: number, gid: number): void;
|
375
|
|
376
|
/**
|
377
|
* Asynchronous fchown(2) - Change ownership of a file.
|
378
|
* @param fd A file descriptor.
|
379
|
*/
|
380
|
function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
|
381
|
|
382
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
383
|
namespace fchown {
|
384
|
/**
|
385
|
* Asynchronous fchown(2) - Change ownership of a file.
|
386
|
* @param fd A file descriptor.
|
387
|
*/
|
388
|
function __promisify__(fd: number, uid: number, gid: number): Promise<void>;
|
389
|
}
|
390
|
|
391
|
/**
|
392
|
* Synchronous fchown(2) - Change ownership of a file.
|
393
|
* @param fd A file descriptor.
|
394
|
*/
|
395
|
function fchownSync(fd: number, uid: number, gid: number): void;
|
396
|
|
397
|
/**
|
398
|
* Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
|
399
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
400
|
*/
|
401
|
function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
|
402
|
|
403
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
404
|
namespace lchown {
|
405
|
/**
|
406
|
* Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
|
407
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
408
|
*/
|
409
|
function __promisify__(path: PathLike, uid: number, gid: number): Promise<void>;
|
410
|
}
|
411
|
|
412
|
/**
|
413
|
* Synchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
|
414
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
415
|
*/
|
416
|
function lchownSync(path: PathLike, uid: number, gid: number): void;
|
417
|
|
418
|
/**
|
419
|
* Asynchronous chmod(2) - Change permissions of a file.
|
420
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
421
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
422
|
*/
|
423
|
function chmod(path: PathLike, mode: string | number, callback: NoParamCallback): void;
|
424
|
|
425
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
426
|
namespace chmod {
|
427
|
/**
|
428
|
* Asynchronous chmod(2) - Change permissions of a file.
|
429
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
430
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
431
|
*/
|
432
|
function __promisify__(path: PathLike, mode: string | number): Promise<void>;
|
433
|
}
|
434
|
|
435
|
/**
|
436
|
* Synchronous chmod(2) - Change permissions of a file.
|
437
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
438
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
439
|
*/
|
440
|
function chmodSync(path: PathLike, mode: string | number): void;
|
441
|
|
442
|
/**
|
443
|
* Asynchronous fchmod(2) - Change permissions of a file.
|
444
|
* @param fd A file descriptor.
|
445
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
446
|
*/
|
447
|
function fchmod(fd: number, mode: string | number, callback: NoParamCallback): void;
|
448
|
|
449
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
450
|
namespace fchmod {
|
451
|
/**
|
452
|
* Asynchronous fchmod(2) - Change permissions of a file.
|
453
|
* @param fd A file descriptor.
|
454
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
455
|
*/
|
456
|
function __promisify__(fd: number, mode: string | number): Promise<void>;
|
457
|
}
|
458
|
|
459
|
/**
|
460
|
* Synchronous fchmod(2) - Change permissions of a file.
|
461
|
* @param fd A file descriptor.
|
462
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
463
|
*/
|
464
|
function fchmodSync(fd: number, mode: string | number): void;
|
465
|
|
466
|
/**
|
467
|
* Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
|
468
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
469
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
470
|
*/
|
471
|
function lchmod(path: PathLike, mode: string | number, callback: NoParamCallback): void;
|
472
|
|
473
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
474
|
namespace lchmod {
|
475
|
/**
|
476
|
* Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
|
477
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
478
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
479
|
*/
|
480
|
function __promisify__(path: PathLike, mode: string | number): Promise<void>;
|
481
|
}
|
482
|
|
483
|
/**
|
484
|
* Synchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
|
485
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
486
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
487
|
*/
|
488
|
function lchmodSync(path: PathLike, mode: string | number): void;
|
489
|
|
490
|
/**
|
491
|
* Asynchronous stat(2) - Get file status.
|
492
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
493
|
*/
|
494
|
function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
495
|
|
496
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
497
|
namespace stat {
|
498
|
/**
|
499
|
* Asynchronous stat(2) - Get file status.
|
500
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
501
|
*/
|
502
|
function __promisify__(path: PathLike): Promise<Stats>;
|
503
|
}
|
504
|
|
505
|
/**
|
506
|
* Synchronous stat(2) - Get file status.
|
507
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
508
|
*/
|
509
|
function statSync(path: PathLike): Stats;
|
510
|
|
511
|
/**
|
512
|
* Asynchronous fstat(2) - Get file status.
|
513
|
* @param fd A file descriptor.
|
514
|
*/
|
515
|
function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
516
|
|
517
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
518
|
namespace fstat {
|
519
|
/**
|
520
|
* Asynchronous fstat(2) - Get file status.
|
521
|
* @param fd A file descriptor.
|
522
|
*/
|
523
|
function __promisify__(fd: number): Promise<Stats>;
|
524
|
}
|
525
|
|
526
|
/**
|
527
|
* Synchronous fstat(2) - Get file status.
|
528
|
* @param fd A file descriptor.
|
529
|
*/
|
530
|
function fstatSync(fd: number): Stats;
|
531
|
|
532
|
/**
|
533
|
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
534
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
535
|
*/
|
536
|
function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
537
|
|
538
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
539
|
namespace lstat {
|
540
|
/**
|
541
|
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
542
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
543
|
*/
|
544
|
function __promisify__(path: PathLike): Promise<Stats>;
|
545
|
}
|
546
|
|
547
|
/**
|
548
|
* Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
549
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
550
|
*/
|
551
|
function lstatSync(path: PathLike): Stats;
|
552
|
|
553
|
/**
|
554
|
* Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
|
555
|
* @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
556
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
557
|
*/
|
558
|
function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
|
559
|
|
560
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
561
|
namespace link {
|
562
|
/**
|
563
|
* Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
|
564
|
* @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
565
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
566
|
*/
|
567
|
function __promisify__(existingPath: PathLike, newPath: PathLike): Promise<void>;
|
568
|
}
|
569
|
|
570
|
/**
|
571
|
* Synchronous link(2) - Create a new link (also known as a hard link) to an existing file.
|
572
|
* @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
573
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
574
|
*/
|
575
|
function linkSync(existingPath: PathLike, newPath: PathLike): void;
|
576
|
|
577
|
/**
|
578
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
|
579
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
|
580
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
|
581
|
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
|
582
|
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
|
583
|
*/
|
584
|
function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void;
|
585
|
|
586
|
/**
|
587
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
|
588
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
|
589
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
|
590
|
*/
|
591
|
function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void;
|
592
|
|
593
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
594
|
namespace symlink {
|
595
|
/**
|
596
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
|
597
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
|
598
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
|
599
|
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
|
600
|
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
|
601
|
*/
|
602
|
function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
|
603
|
|
604
|
type Type = "dir" | "file" | "junction";
|
605
|
}
|
606
|
|
607
|
/**
|
608
|
* Synchronous symlink(2) - Create a new symbolic link to an existing file.
|
609
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
|
610
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
|
611
|
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
|
612
|
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
|
613
|
*/
|
614
|
function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
|
615
|
|
616
|
/**
|
617
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
618
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
619
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
620
|
*/
|
621
|
function readlink(
|
622
|
path: PathLike,
|
623
|
options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null,
|
624
|
callback: (err: NodeJS.ErrnoException | null, linkString: string) => void
|
625
|
): void;
|
626
|
|
627
|
/**
|
628
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
629
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
630
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
631
|
*/
|
632
|
function readlink(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void;
|
633
|
|
634
|
/**
|
635
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
636
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
637
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
638
|
*/
|
639
|
function readlink(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void;
|
640
|
|
641
|
/**
|
642
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
643
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
644
|
*/
|
645
|
function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
|
646
|
|
647
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
648
|
namespace readlink {
|
649
|
/**
|
650
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
651
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
652
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
653
|
*/
|
654
|
function __promisify__(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
|
655
|
|
656
|
/**
|
657
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
658
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
659
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
660
|
*/
|
661
|
function __promisify__(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
|
662
|
|
663
|
/**
|
664
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
665
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
666
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
667
|
*/
|
668
|
function __promisify__(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
|
669
|
}
|
670
|
|
671
|
/**
|
672
|
* Synchronous readlink(2) - read value of a symbolic link.
|
673
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
674
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
675
|
*/
|
676
|
function readlinkSync(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
|
677
|
|
678
|
/**
|
679
|
* Synchronous readlink(2) - read value of a symbolic link.
|
680
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
681
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
682
|
*/
|
683
|
function readlinkSync(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
|
684
|
|
685
|
/**
|
686
|
* Synchronous readlink(2) - read value of a symbolic link.
|
687
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
688
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
689
|
*/
|
690
|
function readlinkSync(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
|
691
|
|
692
|
/**
|
693
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
694
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
695
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
696
|
*/
|
697
|
function realpath(
|
698
|
path: PathLike,
|
699
|
options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null,
|
700
|
callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
|
701
|
): void;
|
702
|
|
703
|
/**
|
704
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
705
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
706
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
707
|
*/
|
708
|
function realpath(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
|
709
|
|
710
|
/**
|
711
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
712
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
713
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
714
|
*/
|
715
|
function realpath(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
|
716
|
|
717
|
/**
|
718
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
719
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
720
|
*/
|
721
|
function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
|
722
|
|
723
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
724
|
namespace realpath {
|
725
|
/**
|
726
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
727
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
728
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
729
|
*/
|
730
|
function __promisify__(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
|
731
|
|
732
|
/**
|
733
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
734
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
735
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
736
|
*/
|
737
|
function __promisify__(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
|
738
|
|
739
|
/**
|
740
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
741
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
742
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
743
|
*/
|
744
|
function __promisify__(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
|
745
|
|
746
|
function native(
|
747
|
path: PathLike,
|
748
|
options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null,
|
749
|
callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void
|
750
|
): void;
|
751
|
function native(path: PathLike, options: { encoding: "buffer" } | "buffer", callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void;
|
752
|
function native(path: PathLike, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void;
|
753
|
function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void;
|
754
|
}
|
755
|
|
756
|
/**
|
757
|
* Synchronous realpath(3) - return the canonicalized absolute pathname.
|
758
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
759
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
760
|
*/
|
761
|
function realpathSync(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
|
762
|
|
763
|
/**
|
764
|
* Synchronous realpath(3) - return the canonicalized absolute pathname.
|
765
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
766
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
767
|
*/
|
768
|
function realpathSync(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
|
769
|
|
770
|
/**
|
771
|
* Synchronous realpath(3) - return the canonicalized absolute pathname.
|
772
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
773
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
774
|
*/
|
775
|
function realpathSync(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
|
776
|
|
777
|
namespace realpathSync {
|
778
|
function native(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
|
779
|
function native(path: PathLike, options: { encoding: "buffer" } | "buffer"): Buffer;
|
780
|
function native(path: PathLike, options?: { encoding?: string | null } | string | null): string | Buffer;
|
781
|
}
|
782
|
|
783
|
/**
|
784
|
* Asynchronous unlink(2) - delete a name and possibly the file it refers to.
|
785
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
786
|
*/
|
787
|
function unlink(path: PathLike, callback: NoParamCallback): void;
|
788
|
|
789
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
790
|
namespace unlink {
|
791
|
/**
|
792
|
* Asynchronous unlink(2) - delete a name and possibly the file it refers to.
|
793
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
794
|
*/
|
795
|
function __promisify__(path: PathLike): Promise<void>;
|
796
|
}
|
797
|
|
798
|
/**
|
799
|
* Synchronous unlink(2) - delete a name and possibly the file it refers to.
|
800
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
801
|
*/
|
802
|
function unlinkSync(path: PathLike): void;
|
803
|
|
804
|
interface RmDirOptions {
|
805
|
/**
|
806
|
* If `true`, perform a recursive directory removal. In
|
807
|
* recursive mode, errors are not reported if `path` does not exist, and
|
808
|
* operations are retried on failure.
|
809
|
* @experimental
|
810
|
* @default false
|
811
|
*/
|
812
|
recursive?: boolean;
|
813
|
}
|
814
|
|
815
|
interface RmDirAsyncOptions extends RmDirOptions {
|
816
|
/**
|
817
|
* The amount of time in milliseconds to wait between retries.
|
818
|
* This option is ignored if the `recursive` option is not `true`.
|
819
|
* @default 100
|
820
|
*/
|
821
|
retryDelay?: number;
|
822
|
/**
|
823
|
* If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
|
824
|
* `EPERM` error is encountered, Node.js will retry the operation with a linear
|
825
|
* backoff wait of `retryDelay` ms longer on each try. This option represents the
|
826
|
* number of retries. This option is ignored if the `recursive` option is not
|
827
|
* `true`.
|
828
|
* @default 0
|
829
|
*/
|
830
|
maxRetries?: number;
|
831
|
}
|
832
|
|
833
|
/**
|
834
|
* Asynchronous rmdir(2) - delete a directory.
|
835
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
836
|
*/
|
837
|
function rmdir(path: PathLike, callback: NoParamCallback): void;
|
838
|
function rmdir(path: PathLike, options: RmDirAsyncOptions, callback: NoParamCallback): void;
|
839
|
|
840
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
841
|
namespace rmdir {
|
842
|
/**
|
843
|
* Asynchronous rmdir(2) - delete a directory.
|
844
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
845
|
*/
|
846
|
function __promisify__(path: PathLike, options?: RmDirAsyncOptions): Promise<void>;
|
847
|
}
|
848
|
|
849
|
/**
|
850
|
* Synchronous rmdir(2) - delete a directory.
|
851
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
852
|
*/
|
853
|
function rmdirSync(path: PathLike, options?: RmDirOptions): void;
|
854
|
|
855
|
interface MakeDirectoryOptions {
|
856
|
/**
|
857
|
* Indicates whether parent folders should be created.
|
858
|
* If a folder was created, the path to the first created folder will be returned.
|
859
|
* @default false
|
860
|
*/
|
861
|
recursive?: boolean;
|
862
|
/**
|
863
|
* A file mode. If a string is passed, it is parsed as an octal integer. If not specified
|
864
|
* @default 0o777
|
865
|
*/
|
866
|
mode?: number | string;
|
867
|
}
|
868
|
|
869
|
/**
|
870
|
* Asynchronous mkdir(2) - create a directory.
|
871
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
872
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
873
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
874
|
*/
|
875
|
function mkdir(path: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: (err: NodeJS.ErrnoException | null, path: string) => void): void;
|
876
|
|
877
|
/**
|
878
|
* Asynchronous mkdir(2) - create a directory.
|
879
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
880
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
881
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
882
|
*/
|
883
|
function mkdir(path: PathLike, options: number | string | (MakeDirectoryOptions & { recursive?: false; }) | null | undefined, callback: NoParamCallback): void;
|
884
|
|
885
|
/**
|
886
|
* Asynchronous mkdir(2) - create a directory.
|
887
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
888
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
889
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
890
|
*/
|
891
|
function mkdir(path: PathLike, options: number | string | MakeDirectoryOptions | null | undefined, callback: (err: NodeJS.ErrnoException | null, path: string | undefined) => void): void;
|
892
|
|
893
|
/**
|
894
|
* Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
|
895
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
896
|
*/
|
897
|
function mkdir(path: PathLike, callback: NoParamCallback): void;
|
898
|
|
899
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
900
|
namespace mkdir {
|
901
|
/**
|
902
|
* Asynchronous mkdir(2) - create a directory.
|
903
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
904
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
905
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
906
|
*/
|
907
|
function __promisify__(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): Promise<string>;
|
908
|
|
909
|
/**
|
910
|
* Asynchronous mkdir(2) - create a directory.
|
911
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
912
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
913
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
914
|
*/
|
915
|
function __promisify__(path: PathLike, options?: number | string | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise<void>;
|
916
|
|
917
|
/**
|
918
|
* Asynchronous mkdir(2) - create a directory.
|
919
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
920
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
921
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
922
|
*/
|
923
|
function __promisify__(path: PathLike, options?: number | string | MakeDirectoryOptions | null): Promise<string | undefined>;
|
924
|
}
|
925
|
|
926
|
/**
|
927
|
* Synchronous mkdir(2) - create a directory.
|
928
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
929
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
930
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
931
|
*/
|
932
|
function mkdirSync(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): string;
|
933
|
|
934
|
/**
|
935
|
* Synchronous mkdir(2) - create a directory.
|
936
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
937
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
938
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
939
|
*/
|
940
|
function mkdirSync(path: PathLike, options?: number | string | (MakeDirectoryOptions & { recursive?: false; }) | null): void;
|
941
|
|
942
|
/**
|
943
|
* Synchronous mkdir(2) - create a directory.
|
944
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
945
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
946
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
947
|
*/
|
948
|
function mkdirSync(path: PathLike, options?: number | string | MakeDirectoryOptions | null): string | undefined;
|
949
|
|
950
|
/**
|
951
|
* Asynchronously creates a unique temporary directory.
|
952
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
953
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
954
|
*/
|
955
|
function mkdtemp(prefix: string, options: { encoding?: BufferEncoding | null } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
|
956
|
|
957
|
/**
|
958
|
* Asynchronously creates a unique temporary directory.
|
959
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
960
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
961
|
*/
|
962
|
function mkdtemp(prefix: string, options: "buffer" | { encoding: "buffer" }, callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void): void;
|
963
|
|
964
|
/**
|
965
|
* Asynchronously creates a unique temporary directory.
|
966
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
967
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
968
|
*/
|
969
|
function mkdtemp(prefix: string, options: { encoding?: string | null } | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void;
|
970
|
|
971
|
/**
|
972
|
* Asynchronously creates a unique temporary directory.
|
973
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
974
|
*/
|
975
|
function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void;
|
976
|
|
977
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
978
|
namespace mkdtemp {
|
979
|
/**
|
980
|
* Asynchronously creates a unique temporary directory.
|
981
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
982
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
983
|
*/
|
984
|
function __promisify__(prefix: string, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
|
985
|
|
986
|
/**
|
987
|
* Asynchronously creates a unique temporary directory.
|
988
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
989
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
990
|
*/
|
991
|
function __promisify__(prefix: string, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
|
992
|
|
993
|
/**
|
994
|
* Asynchronously creates a unique temporary directory.
|
995
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
996
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
997
|
*/
|
998
|
function __promisify__(prefix: string, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
|
999
|
}
|
1000
|
|
1001
|
/**
|
1002
|
* Synchronously creates a unique temporary directory.
|
1003
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
1004
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1005
|
*/
|
1006
|
function mkdtempSync(prefix: string, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): string;
|
1007
|
|
1008
|
/**
|
1009
|
* Synchronously creates a unique temporary directory.
|
1010
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
1011
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1012
|
*/
|
1013
|
function mkdtempSync(prefix: string, options: { encoding: "buffer" } | "buffer"): Buffer;
|
1014
|
|
1015
|
/**
|
1016
|
* Synchronously creates a unique temporary directory.
|
1017
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
1018
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1019
|
*/
|
1020
|
function mkdtempSync(prefix: string, options?: { encoding?: string | null } | string | null): string | Buffer;
|
1021
|
|
1022
|
/**
|
1023
|
* Asynchronous readdir(3) - read a directory.
|
1024
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1025
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1026
|
*/
|
1027
|
function readdir(
|
1028
|
path: PathLike,
|
1029
|
options: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | undefined | null,
|
1030
|
callback: (err: NodeJS.ErrnoException | null, files: string[]) => void,
|
1031
|
): void;
|
1032
|
|
1033
|
/**
|
1034
|
* Asynchronous readdir(3) - read a directory.
|
1035
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1036
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1037
|
*/
|
1038
|
function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer", callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void;
|
1039
|
|
1040
|
/**
|
1041
|
* Asynchronous readdir(3) - read a directory.
|
1042
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1043
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1044
|
*/
|
1045
|
function readdir(
|
1046
|
path: PathLike,
|
1047
|
options: { encoding?: string | null; withFileTypes?: false } | string | undefined | null,
|
1048
|
callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void,
|
1049
|
): void;
|
1050
|
|
1051
|
/**
|
1052
|
* Asynchronous readdir(3) - read a directory.
|
1053
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1054
|
*/
|
1055
|
function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
|
1056
|
|
1057
|
/**
|
1058
|
* Asynchronous readdir(3) - read a directory.
|
1059
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1060
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
1061
|
*/
|
1062
|
function readdir(path: PathLike, options: { encoding?: string | null; withFileTypes: true }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void): void;
|
1063
|
|
1064
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1065
|
namespace readdir {
|
1066
|
/**
|
1067
|
* Asynchronous readdir(3) - read a directory.
|
1068
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1069
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1070
|
*/
|
1071
|
function __promisify__(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): Promise<string[]>;
|
1072
|
|
1073
|
/**
|
1074
|
* Asynchronous readdir(3) - read a directory.
|
1075
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1076
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1077
|
*/
|
1078
|
function __promisify__(path: PathLike, options: "buffer" | { encoding: "buffer"; withFileTypes?: false }): Promise<Buffer[]>;
|
1079
|
|
1080
|
/**
|
1081
|
* Asynchronous readdir(3) - read a directory.
|
1082
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1083
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1084
|
*/
|
1085
|
function __promisify__(path: PathLike, options?: { encoding?: string | null; withFileTypes?: false } | string | null): Promise<string[] | Buffer[]>;
|
1086
|
|
1087
|
/**
|
1088
|
* Asynchronous readdir(3) - read a directory.
|
1089
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1090
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent
|
1091
|
*/
|
1092
|
function __promisify__(path: PathLike, options: { encoding?: string | null; withFileTypes: true }): Promise<Dirent[]>;
|
1093
|
}
|
1094
|
|
1095
|
/**
|
1096
|
* Synchronous readdir(3) - read a directory.
|
1097
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1098
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1099
|
*/
|
1100
|
function readdirSync(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): string[];
|
1101
|
|
1102
|
/**
|
1103
|
* Synchronous readdir(3) - read a directory.
|
1104
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1105
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1106
|
*/
|
1107
|
function readdirSync(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Buffer[];
|
1108
|
|
1109
|
/**
|
1110
|
* Synchronous readdir(3) - read a directory.
|
1111
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1112
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
1113
|
*/
|
1114
|
function readdirSync(path: PathLike, options?: { encoding?: string | null; withFileTypes?: false } | string | null): string[] | Buffer[];
|
1115
|
|
1116
|
/**
|
1117
|
* Synchronous readdir(3) - read a directory.
|
1118
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1119
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
1120
|
*/
|
1121
|
function readdirSync(path: PathLike, options: { encoding?: string | null; withFileTypes: true }): Dirent[];
|
1122
|
|
1123
|
/**
|
1124
|
* Asynchronous close(2) - close a file descriptor.
|
1125
|
* @param fd A file descriptor.
|
1126
|
*/
|
1127
|
function close(fd: number, callback: NoParamCallback): void;
|
1128
|
|
1129
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1130
|
namespace close {
|
1131
|
/**
|
1132
|
* Asynchronous close(2) - close a file descriptor.
|
1133
|
* @param fd A file descriptor.
|
1134
|
*/
|
1135
|
function __promisify__(fd: number): Promise<void>;
|
1136
|
}
|
1137
|
|
1138
|
/**
|
1139
|
* Synchronous close(2) - close a file descriptor.
|
1140
|
* @param fd A file descriptor.
|
1141
|
*/
|
1142
|
function closeSync(fd: number): void;
|
1143
|
|
1144
|
/**
|
1145
|
* Asynchronous open(2) - open and possibly create a file.
|
1146
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1147
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
|
1148
|
*/
|
1149
|
function open(path: PathLike, flags: string | number, mode: string | number | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
1150
|
|
1151
|
/**
|
1152
|
* Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
|
1153
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1154
|
*/
|
1155
|
function open(path: PathLike, flags: string | number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
1156
|
|
1157
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1158
|
namespace open {
|
1159
|
/**
|
1160
|
* Asynchronous open(2) - open and possibly create a file.
|
1161
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1162
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
|
1163
|
*/
|
1164
|
function __promisify__(path: PathLike, flags: string | number, mode?: string | number | null): Promise<number>;
|
1165
|
}
|
1166
|
|
1167
|
/**
|
1168
|
* Synchronous open(2) - open and possibly create a file, returning a file descriptor..
|
1169
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1170
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`.
|
1171
|
*/
|
1172
|
function openSync(path: PathLike, flags: string | number, mode?: string | number | null): number;
|
1173
|
|
1174
|
/**
|
1175
|
* Asynchronously change file timestamps of the file referenced by the supplied path.
|
1176
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1177
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
1178
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
1179
|
*/
|
1180
|
function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
|
1181
|
|
1182
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1183
|
namespace utimes {
|
1184
|
/**
|
1185
|
* Asynchronously change file timestamps of the file referenced by the supplied path.
|
1186
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1187
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
1188
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
1189
|
*/
|
1190
|
function __promisify__(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
1191
|
}
|
1192
|
|
1193
|
/**
|
1194
|
* Synchronously change file timestamps of the file referenced by the supplied path.
|
1195
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1196
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
1197
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
1198
|
*/
|
1199
|
function utimesSync(path: PathLike, atime: string | number | Date, mtime: string | number | Date): void;
|
1200
|
|
1201
|
/**
|
1202
|
* Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
|
1203
|
* @param fd A file descriptor.
|
1204
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
1205
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
1206
|
*/
|
1207
|
function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
|
1208
|
|
1209
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1210
|
namespace futimes {
|
1211
|
/**
|
1212
|
* Asynchronously change file timestamps of the file referenced by the supplied file descriptor.
|
1213
|
* @param fd A file descriptor.
|
1214
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
1215
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
1216
|
*/
|
1217
|
function __promisify__(fd: number, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
1218
|
}
|
1219
|
|
1220
|
/**
|
1221
|
* Synchronously change file timestamps of the file referenced by the supplied file descriptor.
|
1222
|
* @param fd A file descriptor.
|
1223
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
1224
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
1225
|
*/
|
1226
|
function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void;
|
1227
|
|
1228
|
/**
|
1229
|
* Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
|
1230
|
* @param fd A file descriptor.
|
1231
|
*/
|
1232
|
function fsync(fd: number, callback: NoParamCallback): void;
|
1233
|
|
1234
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1235
|
namespace fsync {
|
1236
|
/**
|
1237
|
* Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
|
1238
|
* @param fd A file descriptor.
|
1239
|
*/
|
1240
|
function __promisify__(fd: number): Promise<void>;
|
1241
|
}
|
1242
|
|
1243
|
/**
|
1244
|
* Synchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
|
1245
|
* @param fd A file descriptor.
|
1246
|
*/
|
1247
|
function fsyncSync(fd: number): void;
|
1248
|
|
1249
|
/**
|
1250
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
1251
|
* @param fd A file descriptor.
|
1252
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
|
1253
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
1254
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
1255
|
*/
|
1256
|
function write<TBuffer extends NodeJS.ArrayBufferView>(
|
1257
|
fd: number,
|
1258
|
buffer: TBuffer,
|
1259
|
offset: number | undefined | null,
|
1260
|
length: number | undefined | null,
|
1261
|
position: number | undefined | null,
|
1262
|
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
|
1263
|
): void;
|
1264
|
|
1265
|
/**
|
1266
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
1267
|
* @param fd A file descriptor.
|
1268
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
|
1269
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
1270
|
*/
|
1271
|
function write<TBuffer extends NodeJS.ArrayBufferView>(
|
1272
|
fd: number,
|
1273
|
buffer: TBuffer,
|
1274
|
offset: number | undefined | null,
|
1275
|
length: number | undefined | null,
|
1276
|
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void,
|
1277
|
): void;
|
1278
|
|
1279
|
/**
|
1280
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
1281
|
* @param fd A file descriptor.
|
1282
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
|
1283
|
*/
|
1284
|
function write<TBuffer extends NodeJS.ArrayBufferView>(
|
1285
|
fd: number,
|
1286
|
buffer: TBuffer,
|
1287
|
offset: number | undefined | null,
|
1288
|
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void
|
1289
|
): void;
|
1290
|
|
1291
|
/**
|
1292
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
1293
|
* @param fd A file descriptor.
|
1294
|
*/
|
1295
|
function write<TBuffer extends NodeJS.ArrayBufferView>(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void;
|
1296
|
|
1297
|
/**
|
1298
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
1299
|
* @param fd A file descriptor.
|
1300
|
* @param string A string to write. If something other than a string is supplied it will be coerced to a string.
|
1301
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
1302
|
* @param encoding The expected string encoding.
|
1303
|
*/
|
1304
|
function write(
|
1305
|
fd: number,
|
1306
|
string: any,
|
1307
|
position: number | undefined | null,
|
1308
|
encoding: string | undefined | null,
|
1309
|
callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void,
|
1310
|
): void;
|
1311
|
|
1312
|
/**
|
1313
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
1314
|
* @param fd A file descriptor.
|
1315
|
* @param string A string to write. If something other than a string is supplied it will be coerced to a string.
|
1316
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
1317
|
*/
|
1318
|
function write(fd: number, string: any, position: number | undefined | null, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
|
1319
|
|
1320
|
/**
|
1321
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
1322
|
* @param fd A file descriptor.
|
1323
|
* @param string A string to write. If something other than a string is supplied it will be coerced to a string.
|
1324
|
*/
|
1325
|
function write(fd: number, string: any, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void;
|
1326
|
|
1327
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1328
|
namespace write {
|
1329
|
/**
|
1330
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
|
1331
|
* @param fd A file descriptor.
|
1332
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
|
1333
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
1334
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
1335
|
*/
|
1336
|
function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
|
1337
|
fd: number,
|
1338
|
buffer?: TBuffer,
|
1339
|
offset?: number,
|
1340
|
length?: number,
|
1341
|
position?: number | null,
|
1342
|
): Promise<{ bytesWritten: number, buffer: TBuffer }>;
|
1343
|
|
1344
|
/**
|
1345
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor.
|
1346
|
* @param fd A file descriptor.
|
1347
|
* @param string A string to write. If something other than a string is supplied it will be coerced to a string.
|
1348
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
1349
|
* @param encoding The expected string encoding.
|
1350
|
*/
|
1351
|
function __promisify__(fd: number, string: any, position?: number | null, encoding?: string | null): Promise<{ bytesWritten: number, buffer: string }>;
|
1352
|
}
|
1353
|
|
1354
|
/**
|
1355
|
* Synchronously writes `buffer` to the file referenced by the supplied file descriptor, returning the number of bytes written.
|
1356
|
* @param fd A file descriptor.
|
1357
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
|
1358
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
1359
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
1360
|
*/
|
1361
|
function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
|
1362
|
|
1363
|
/**
|
1364
|
* Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written.
|
1365
|
* @param fd A file descriptor.
|
1366
|
* @param string A string to write. If something other than a string is supplied it will be coerced to a string.
|
1367
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
1368
|
* @param encoding The expected string encoding.
|
1369
|
*/
|
1370
|
function writeSync(fd: number, string: any, position?: number | null, encoding?: string | null): number;
|
1371
|
|
1372
|
/**
|
1373
|
* Asynchronously reads data from the file referenced by the supplied file descriptor.
|
1374
|
* @param fd A file descriptor.
|
1375
|
* @param buffer The buffer that the data will be written to.
|
1376
|
* @param offset The offset in the buffer at which to start writing.
|
1377
|
* @param length The number of bytes to read.
|
1378
|
* @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.
|
1379
|
*/
|
1380
|
function read<TBuffer extends NodeJS.ArrayBufferView>(
|
1381
|
fd: number,
|
1382
|
buffer: TBuffer,
|
1383
|
offset: number,
|
1384
|
length: number,
|
1385
|
position: number | null,
|
1386
|
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
|
1387
|
): void;
|
1388
|
|
1389
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1390
|
namespace read {
|
1391
|
/**
|
1392
|
* @param fd A file descriptor.
|
1393
|
* @param buffer The buffer that the data will be written to.
|
1394
|
* @param offset The offset in the buffer at which to start writing.
|
1395
|
* @param length The number of bytes to read.
|
1396
|
* @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.
|
1397
|
*/
|
1398
|
function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
|
1399
|
fd: number,
|
1400
|
buffer: TBuffer,
|
1401
|
offset: number,
|
1402
|
length: number,
|
1403
|
position: number | null
|
1404
|
): Promise<{ bytesRead: number, buffer: TBuffer }>;
|
1405
|
}
|
1406
|
|
1407
|
/**
|
1408
|
* Synchronously reads data from the file referenced by the supplied file descriptor, returning the number of bytes read.
|
1409
|
* @param fd A file descriptor.
|
1410
|
* @param buffer The buffer that the data will be written to.
|
1411
|
* @param offset The offset in the buffer at which to start writing.
|
1412
|
* @param length The number of bytes to read.
|
1413
|
* @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.
|
1414
|
*/
|
1415
|
function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
|
1416
|
|
1417
|
/**
|
1418
|
* Asynchronously reads the entire contents of a file.
|
1419
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1420
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1421
|
* @param options An object that may contain an optional flag.
|
1422
|
* If a flag is not provided, it defaults to `'r'`.
|
1423
|
*/
|
1424
|
function readFile(path: PathLike | number, options: { encoding?: null; flag?: string; } | undefined | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
|
1425
|
|
1426
|
/**
|
1427
|
* Asynchronously reads the entire contents of a file.
|
1428
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1429
|
* URL support is _experimental_.
|
1430
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1431
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
1432
|
* If a flag is not provided, it defaults to `'r'`.
|
1433
|
*/
|
1434
|
function readFile(path: PathLike | number, options: { encoding: string; flag?: string; } | string, callback: (err: NodeJS.ErrnoException | null, data: string) => void): void;
|
1435
|
|
1436
|
/**
|
1437
|
* Asynchronously reads the entire contents of a file.
|
1438
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1439
|
* URL support is _experimental_.
|
1440
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1441
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
1442
|
* If a flag is not provided, it defaults to `'r'`.
|
1443
|
*/
|
1444
|
function readFile(
|
1445
|
path: PathLike | number,
|
1446
|
options: { encoding?: string | null; flag?: string; } | string | undefined | null,
|
1447
|
callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void,
|
1448
|
): void;
|
1449
|
|
1450
|
/**
|
1451
|
* Asynchronously reads the entire contents of a file.
|
1452
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1453
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1454
|
*/
|
1455
|
function readFile(path: PathLike | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void;
|
1456
|
|
1457
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1458
|
namespace readFile {
|
1459
|
/**
|
1460
|
* Asynchronously reads the entire contents of a file.
|
1461
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1462
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1463
|
* @param options An object that may contain an optional flag.
|
1464
|
* If a flag is not provided, it defaults to `'r'`.
|
1465
|
*/
|
1466
|
function __promisify__(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Promise<Buffer>;
|
1467
|
|
1468
|
/**
|
1469
|
* Asynchronously reads the entire contents of a file.
|
1470
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1471
|
* URL support is _experimental_.
|
1472
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1473
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
1474
|
* If a flag is not provided, it defaults to `'r'`.
|
1475
|
*/
|
1476
|
function __promisify__(path: PathLike | number, options: { encoding: string; flag?: string; } | string): Promise<string>;
|
1477
|
|
1478
|
/**
|
1479
|
* Asynchronously reads the entire contents of a file.
|
1480
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1481
|
* URL support is _experimental_.
|
1482
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1483
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
1484
|
* If a flag is not provided, it defaults to `'r'`.
|
1485
|
*/
|
1486
|
function __promisify__(path: PathLike | number, options?: { encoding?: string | null; flag?: string; } | string | null): Promise<string | Buffer>;
|
1487
|
}
|
1488
|
|
1489
|
/**
|
1490
|
* Synchronously reads the entire contents of a file.
|
1491
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1492
|
* URL support is _experimental_.
|
1493
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1494
|
* @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.
|
1495
|
*/
|
1496
|
function readFileSync(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Buffer;
|
1497
|
|
1498
|
/**
|
1499
|
* Synchronously reads the entire contents of a file.
|
1500
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1501
|
* URL support is _experimental_.
|
1502
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1503
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
1504
|
* If a flag is not provided, it defaults to `'r'`.
|
1505
|
*/
|
1506
|
function readFileSync(path: PathLike | number, options: { encoding: string; flag?: string; } | string): string;
|
1507
|
|
1508
|
/**
|
1509
|
* Synchronously reads the entire contents of a file.
|
1510
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1511
|
* URL support is _experimental_.
|
1512
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1513
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
1514
|
* If a flag is not provided, it defaults to `'r'`.
|
1515
|
*/
|
1516
|
function readFileSync(path: PathLike | number, options?: { encoding?: string | null; flag?: string; } | string | null): string | Buffer;
|
1517
|
|
1518
|
type WriteFileOptions = { encoding?: string | null; mode?: number | string; flag?: string; } | string | null;
|
1519
|
|
1520
|
/**
|
1521
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
1522
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1523
|
* URL support is _experimental_.
|
1524
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1525
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
1526
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
1527
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1528
|
* If `mode` is not supplied, the default of `0o666` is used.
|
1529
|
* If `mode` is a string, it is parsed as an octal integer.
|
1530
|
* If `flag` is not supplied, the default of `'w'` is used.
|
1531
|
*/
|
1532
|
function writeFile(path: PathLike | number, data: any, options: WriteFileOptions, callback: NoParamCallback): void;
|
1533
|
|
1534
|
/**
|
1535
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
1536
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1537
|
* URL support is _experimental_.
|
1538
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1539
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
1540
|
*/
|
1541
|
function writeFile(path: PathLike | number, data: any, callback: NoParamCallback): void;
|
1542
|
|
1543
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1544
|
namespace writeFile {
|
1545
|
/**
|
1546
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
1547
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1548
|
* URL support is _experimental_.
|
1549
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1550
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
1551
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
1552
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1553
|
* If `mode` is not supplied, the default of `0o666` is used.
|
1554
|
* If `mode` is a string, it is parsed as an octal integer.
|
1555
|
* If `flag` is not supplied, the default of `'w'` is used.
|
1556
|
*/
|
1557
|
function __promisify__(path: PathLike | number, data: any, options?: WriteFileOptions): Promise<void>;
|
1558
|
}
|
1559
|
|
1560
|
/**
|
1561
|
* Synchronously writes data to a file, replacing the file if it already exists.
|
1562
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1563
|
* URL support is _experimental_.
|
1564
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1565
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
1566
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
1567
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1568
|
* If `mode` is not supplied, the default of `0o666` is used.
|
1569
|
* If `mode` is a string, it is parsed as an octal integer.
|
1570
|
* If `flag` is not supplied, the default of `'w'` is used.
|
1571
|
*/
|
1572
|
function writeFileSync(path: PathLike | number, data: any, options?: WriteFileOptions): void;
|
1573
|
|
1574
|
/**
|
1575
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
1576
|
* @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1577
|
* URL support is _experimental_.
|
1578
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1579
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
1580
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
1581
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1582
|
* If `mode` is not supplied, the default of `0o666` is used.
|
1583
|
* If `mode` is a string, it is parsed as an octal integer.
|
1584
|
* If `flag` is not supplied, the default of `'a'` is used.
|
1585
|
*/
|
1586
|
function appendFile(file: PathLike | number, data: any, options: WriteFileOptions, callback: NoParamCallback): void;
|
1587
|
|
1588
|
/**
|
1589
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
1590
|
* @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1591
|
* URL support is _experimental_.
|
1592
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1593
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
1594
|
*/
|
1595
|
function appendFile(file: PathLike | number, data: any, callback: NoParamCallback): void;
|
1596
|
|
1597
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1598
|
namespace appendFile {
|
1599
|
/**
|
1600
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
1601
|
* @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1602
|
* URL support is _experimental_.
|
1603
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1604
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
1605
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
1606
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1607
|
* If `mode` is not supplied, the default of `0o666` is used.
|
1608
|
* If `mode` is a string, it is parsed as an octal integer.
|
1609
|
* If `flag` is not supplied, the default of `'a'` is used.
|
1610
|
*/
|
1611
|
function __promisify__(file: PathLike | number, data: any, options?: WriteFileOptions): Promise<void>;
|
1612
|
}
|
1613
|
|
1614
|
/**
|
1615
|
* Synchronously append data to a file, creating the file if it does not exist.
|
1616
|
* @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1617
|
* URL support is _experimental_.
|
1618
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
1619
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
|
1620
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
1621
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1622
|
* If `mode` is not supplied, the default of `0o666` is used.
|
1623
|
* If `mode` is a string, it is parsed as an octal integer.
|
1624
|
* If `flag` is not supplied, the default of `'a'` is used.
|
1625
|
*/
|
1626
|
function appendFileSync(file: PathLike | number, data: any, options?: WriteFileOptions): void;
|
1627
|
|
1628
|
/**
|
1629
|
* Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
|
1630
|
*/
|
1631
|
function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number; } | undefined, listener: (curr: Stats, prev: Stats) => void): void;
|
1632
|
|
1633
|
/**
|
1634
|
* Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
|
1635
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1636
|
* URL support is _experimental_.
|
1637
|
*/
|
1638
|
function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;
|
1639
|
|
1640
|
/**
|
1641
|
* Stop watching for changes on `filename`.
|
1642
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1643
|
* URL support is _experimental_.
|
1644
|
*/
|
1645
|
function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
|
1646
|
|
1647
|
/**
|
1648
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
1649
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1650
|
* URL support is _experimental_.
|
1651
|
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
1652
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1653
|
* If `persistent` is not supplied, the default of `true` is used.
|
1654
|
* If `recursive` is not supplied, the default of `false` is used.
|
1655
|
*/
|
1656
|
function watch(
|
1657
|
filename: PathLike,
|
1658
|
options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | BufferEncoding | undefined | null,
|
1659
|
listener?: (event: string, filename: string) => void,
|
1660
|
): FSWatcher;
|
1661
|
|
1662
|
/**
|
1663
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
1664
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1665
|
* URL support is _experimental_.
|
1666
|
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
1667
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1668
|
* If `persistent` is not supplied, the default of `true` is used.
|
1669
|
* If `recursive` is not supplied, the default of `false` is used.
|
1670
|
*/
|
1671
|
function watch(filename: PathLike, options: { encoding: "buffer", persistent?: boolean, recursive?: boolean } | "buffer", listener?: (event: string, filename: Buffer) => void): FSWatcher;
|
1672
|
|
1673
|
/**
|
1674
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
1675
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1676
|
* URL support is _experimental_.
|
1677
|
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
1678
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1679
|
* If `persistent` is not supplied, the default of `true` is used.
|
1680
|
* If `recursive` is not supplied, the default of `false` is used.
|
1681
|
*/
|
1682
|
function watch(
|
1683
|
filename: PathLike,
|
1684
|
options: { encoding?: string | null, persistent?: boolean, recursive?: boolean } | string | null,
|
1685
|
listener?: (event: string, filename: string | Buffer) => void,
|
1686
|
): FSWatcher;
|
1687
|
|
1688
|
/**
|
1689
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
1690
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1691
|
* URL support is _experimental_.
|
1692
|
*/
|
1693
|
function watch(filename: PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
|
1694
|
|
1695
|
/**
|
1696
|
* Asynchronously tests whether or not the given path exists by checking with the file system.
|
1697
|
* @deprecated
|
1698
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1699
|
* URL support is _experimental_.
|
1700
|
*/
|
1701
|
function exists(path: PathLike, callback: (exists: boolean) => void): void;
|
1702
|
|
1703
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1704
|
namespace exists {
|
1705
|
/**
|
1706
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1707
|
* URL support is _experimental_.
|
1708
|
*/
|
1709
|
function __promisify__(path: PathLike): Promise<boolean>;
|
1710
|
}
|
1711
|
|
1712
|
/**
|
1713
|
* Synchronously tests whether or not the given path exists by checking with the file system.
|
1714
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1715
|
* URL support is _experimental_.
|
1716
|
*/
|
1717
|
function existsSync(path: PathLike): boolean;
|
1718
|
|
1719
|
namespace constants {
|
1720
|
// File Access Constants
|
1721
|
|
1722
|
/** Constant for fs.access(). File is visible to the calling process. */
|
1723
|
const F_OK: number;
|
1724
|
|
1725
|
/** Constant for fs.access(). File can be read by the calling process. */
|
1726
|
const R_OK: number;
|
1727
|
|
1728
|
/** Constant for fs.access(). File can be written by the calling process. */
|
1729
|
const W_OK: number;
|
1730
|
|
1731
|
/** Constant for fs.access(). File can be executed by the calling process. */
|
1732
|
const X_OK: number;
|
1733
|
|
1734
|
// File Copy Constants
|
1735
|
|
1736
|
/** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */
|
1737
|
const COPYFILE_EXCL: number;
|
1738
|
|
1739
|
/**
|
1740
|
* Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink.
|
1741
|
* If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
|
1742
|
*/
|
1743
|
const COPYFILE_FICLONE: number;
|
1744
|
|
1745
|
/**
|
1746
|
* Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
|
1747
|
* If the underlying platform does not support copy-on-write, then the operation will fail with an error.
|
1748
|
*/
|
1749
|
const COPYFILE_FICLONE_FORCE: number;
|
1750
|
|
1751
|
// File Open Constants
|
1752
|
|
1753
|
/** Constant for fs.open(). Flag indicating to open a file for read-only access. */
|
1754
|
const O_RDONLY: number;
|
1755
|
|
1756
|
/** Constant for fs.open(). Flag indicating to open a file for write-only access. */
|
1757
|
const O_WRONLY: number;
|
1758
|
|
1759
|
/** Constant for fs.open(). Flag indicating to open a file for read-write access. */
|
1760
|
const O_RDWR: number;
|
1761
|
|
1762
|
/** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */
|
1763
|
const O_CREAT: number;
|
1764
|
|
1765
|
/** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */
|
1766
|
const O_EXCL: number;
|
1767
|
|
1768
|
/**
|
1769
|
* Constant for fs.open(). Flag indicating that if path identifies a terminal device,
|
1770
|
* opening the path shall not cause that terminal to become the controlling terminal for the process
|
1771
|
* (if the process does not already have one).
|
1772
|
*/
|
1773
|
const O_NOCTTY: number;
|
1774
|
|
1775
|
/** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */
|
1776
|
const O_TRUNC: number;
|
1777
|
|
1778
|
/** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */
|
1779
|
const O_APPEND: number;
|
1780
|
|
1781
|
/** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */
|
1782
|
const O_DIRECTORY: number;
|
1783
|
|
1784
|
/**
|
1785
|
* constant for fs.open().
|
1786
|
* Flag indicating reading accesses to the file system will no longer result in
|
1787
|
* an update to the atime information associated with the file.
|
1788
|
* This flag is available on Linux operating systems only.
|
1789
|
*/
|
1790
|
const O_NOATIME: number;
|
1791
|
|
1792
|
/** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */
|
1793
|
const O_NOFOLLOW: number;
|
1794
|
|
1795
|
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */
|
1796
|
const O_SYNC: number;
|
1797
|
|
1798
|
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */
|
1799
|
const O_DSYNC: number;
|
1800
|
|
1801
|
/** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */
|
1802
|
const O_SYMLINK: number;
|
1803
|
|
1804
|
/** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */
|
1805
|
const O_DIRECT: number;
|
1806
|
|
1807
|
/** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */
|
1808
|
const O_NONBLOCK: number;
|
1809
|
|
1810
|
// File Type Constants
|
1811
|
|
1812
|
/** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
|
1813
|
const S_IFMT: number;
|
1814
|
|
1815
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
|
1816
|
const S_IFREG: number;
|
1817
|
|
1818
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */
|
1819
|
const S_IFDIR: number;
|
1820
|
|
1821
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */
|
1822
|
const S_IFCHR: number;
|
1823
|
|
1824
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */
|
1825
|
const S_IFBLK: number;
|
1826
|
|
1827
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */
|
1828
|
const S_IFIFO: number;
|
1829
|
|
1830
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */
|
1831
|
const S_IFLNK: number;
|
1832
|
|
1833
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */
|
1834
|
const S_IFSOCK: number;
|
1835
|
|
1836
|
// File Mode Constants
|
1837
|
|
1838
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */
|
1839
|
const S_IRWXU: number;
|
1840
|
|
1841
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */
|
1842
|
const S_IRUSR: number;
|
1843
|
|
1844
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */
|
1845
|
const S_IWUSR: number;
|
1846
|
|
1847
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */
|
1848
|
const S_IXUSR: number;
|
1849
|
|
1850
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */
|
1851
|
const S_IRWXG: number;
|
1852
|
|
1853
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */
|
1854
|
const S_IRGRP: number;
|
1855
|
|
1856
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */
|
1857
|
const S_IWGRP: number;
|
1858
|
|
1859
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */
|
1860
|
const S_IXGRP: number;
|
1861
|
|
1862
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */
|
1863
|
const S_IRWXO: number;
|
1864
|
|
1865
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */
|
1866
|
const S_IROTH: number;
|
1867
|
|
1868
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */
|
1869
|
const S_IWOTH: number;
|
1870
|
|
1871
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
|
1872
|
const S_IXOTH: number;
|
1873
|
|
1874
|
/**
|
1875
|
* When set, a memory file mapping is used to access the file. This flag
|
1876
|
* is available on Windows operating systems only. On other operating systems,
|
1877
|
* this flag is ignored.
|
1878
|
*/
|
1879
|
const UV_FS_O_FILEMAP: number;
|
1880
|
}
|
1881
|
|
1882
|
/**
|
1883
|
* Asynchronously tests a user's permissions for the file specified by path.
|
1884
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1885
|
* URL support is _experimental_.
|
1886
|
*/
|
1887
|
function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
|
1888
|
|
1889
|
/**
|
1890
|
* Asynchronously tests a user's permissions for the file specified by path.
|
1891
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1892
|
* URL support is _experimental_.
|
1893
|
*/
|
1894
|
function access(path: PathLike, callback: NoParamCallback): void;
|
1895
|
|
1896
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1897
|
namespace access {
|
1898
|
/**
|
1899
|
* Asynchronously tests a user's permissions for the file specified by path.
|
1900
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1901
|
* URL support is _experimental_.
|
1902
|
*/
|
1903
|
function __promisify__(path: PathLike, mode?: number): Promise<void>;
|
1904
|
}
|
1905
|
|
1906
|
/**
|
1907
|
* Synchronously tests a user's permissions for the file specified by path.
|
1908
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1909
|
* URL support is _experimental_.
|
1910
|
*/
|
1911
|
function accessSync(path: PathLike, mode?: number): void;
|
1912
|
|
1913
|
/**
|
1914
|
* Returns a new `ReadStream` object.
|
1915
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1916
|
* URL support is _experimental_.
|
1917
|
*/
|
1918
|
function createReadStream(path: PathLike, options?: string | {
|
1919
|
flags?: string;
|
1920
|
encoding?: string;
|
1921
|
fd?: number;
|
1922
|
mode?: number;
|
1923
|
autoClose?: boolean;
|
1924
|
/**
|
1925
|
* @default false
|
1926
|
*/
|
1927
|
emitClose?: boolean;
|
1928
|
start?: number;
|
1929
|
end?: number;
|
1930
|
highWaterMark?: number;
|
1931
|
}): ReadStream;
|
1932
|
|
1933
|
/**
|
1934
|
* Returns a new `WriteStream` object.
|
1935
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1936
|
* URL support is _experimental_.
|
1937
|
*/
|
1938
|
function createWriteStream(path: PathLike, options?: string | {
|
1939
|
flags?: string;
|
1940
|
encoding?: string;
|
1941
|
fd?: number;
|
1942
|
mode?: number;
|
1943
|
autoClose?: boolean;
|
1944
|
emitClose?: boolean;
|
1945
|
start?: number;
|
1946
|
highWaterMark?: number;
|
1947
|
}): WriteStream;
|
1948
|
|
1949
|
/**
|
1950
|
* Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
|
1951
|
* @param fd A file descriptor.
|
1952
|
*/
|
1953
|
function fdatasync(fd: number, callback: NoParamCallback): void;
|
1954
|
|
1955
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1956
|
namespace fdatasync {
|
1957
|
/**
|
1958
|
* Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
|
1959
|
* @param fd A file descriptor.
|
1960
|
*/
|
1961
|
function __promisify__(fd: number): Promise<void>;
|
1962
|
}
|
1963
|
|
1964
|
/**
|
1965
|
* Synchronous fdatasync(2) - synchronize a file's in-core state with storage device.
|
1966
|
* @param fd A file descriptor.
|
1967
|
*/
|
1968
|
function fdatasyncSync(fd: number): void;
|
1969
|
|
1970
|
/**
|
1971
|
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
|
1972
|
* No arguments other than a possible exception are given to the callback function.
|
1973
|
* Node.js makes no guarantees about the atomicity of the copy operation.
|
1974
|
* If an error occurs after the destination file has been opened for writing, Node.js will attempt
|
1975
|
* to remove the destination.
|
1976
|
* @param src A path to the source file.
|
1977
|
* @param dest A path to the destination file.
|
1978
|
*/
|
1979
|
function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
|
1980
|
/**
|
1981
|
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
|
1982
|
* No arguments other than a possible exception are given to the callback function.
|
1983
|
* Node.js makes no guarantees about the atomicity of the copy operation.
|
1984
|
* If an error occurs after the destination file has been opened for writing, Node.js will attempt
|
1985
|
* to remove the destination.
|
1986
|
* @param src A path to the source file.
|
1987
|
* @param dest A path to the destination file.
|
1988
|
* @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
|
1989
|
*/
|
1990
|
function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoParamCallback): void;
|
1991
|
|
1992
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
|
1993
|
namespace copyFile {
|
1994
|
/**
|
1995
|
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
|
1996
|
* No arguments other than a possible exception are given to the callback function.
|
1997
|
* Node.js makes no guarantees about the atomicity of the copy operation.
|
1998
|
* If an error occurs after the destination file has been opened for writing, Node.js will attempt
|
1999
|
* to remove the destination.
|
2000
|
* @param src A path to the source file.
|
2001
|
* @param dest A path to the destination file.
|
2002
|
* @param flags An optional integer that specifies the behavior of the copy operation.
|
2003
|
* The only supported flag is fs.constants.COPYFILE_EXCL,
|
2004
|
* which causes the copy operation to fail if dest already exists.
|
2005
|
*/
|
2006
|
function __promisify__(src: PathLike, dst: PathLike, flags?: number): Promise<void>;
|
2007
|
}
|
2008
|
|
2009
|
/**
|
2010
|
* Synchronously copies src to dest. By default, dest is overwritten if it already exists.
|
2011
|
* Node.js makes no guarantees about the atomicity of the copy operation.
|
2012
|
* If an error occurs after the destination file has been opened for writing, Node.js will attempt
|
2013
|
* to remove the destination.
|
2014
|
* @param src A path to the source file.
|
2015
|
* @param dest A path to the destination file.
|
2016
|
* @param flags An optional integer that specifies the behavior of the copy operation.
|
2017
|
* The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
|
2018
|
*/
|
2019
|
function copyFileSync(src: PathLike, dest: PathLike, flags?: number): void;
|
2020
|
|
2021
|
/**
|
2022
|
* Write an array of ArrayBufferViews to the file specified by fd using writev().
|
2023
|
* position is the offset from the beginning of the file where this data should be written.
|
2024
|
* It is unsafe to use fs.writev() multiple times on the same file without waiting for the callback. For this scenario, use fs.createWriteStream().
|
2025
|
* On Linux, positional writes don't work when the file is opened in append mode.
|
2026
|
* The kernel ignores the position argument and always appends the data to the end of the file.
|
2027
|
*/
|
2028
|
function writev(
|
2029
|
fd: number,
|
2030
|
buffers: NodeJS.ArrayBufferView[],
|
2031
|
cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
|
2032
|
): void;
|
2033
|
function writev(
|
2034
|
fd: number,
|
2035
|
buffers: NodeJS.ArrayBufferView[],
|
2036
|
position: number,
|
2037
|
cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
|
2038
|
): void;
|
2039
|
|
2040
|
interface WriteVResult {
|
2041
|
bytesWritten: number;
|
2042
|
buffers: NodeJS.ArrayBufferView[];
|
2043
|
}
|
2044
|
|
2045
|
namespace writev {
|
2046
|
function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
|
2047
|
}
|
2048
|
|
2049
|
/**
|
2050
|
* See `writev`.
|
2051
|
*/
|
2052
|
function writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
|
2053
|
|
2054
|
interface OpenDirOptions {
|
2055
|
encoding?: BufferEncoding;
|
2056
|
/**
|
2057
|
* Number of directory entries that are buffered
|
2058
|
* internally when reading from the directory. Higher values lead to better
|
2059
|
* performance but higher memory usage.
|
2060
|
* @default 32
|
2061
|
*/
|
2062
|
bufferSize?: number;
|
2063
|
}
|
2064
|
|
2065
|
function opendirSync(path: string, options?: OpenDirOptions): Dir;
|
2066
|
|
2067
|
function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
|
2068
|
function opendir(path: string, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
|
2069
|
|
2070
|
namespace opendir {
|
2071
|
function __promisify__(path: string, options?: OpenDirOptions): Promise<Dir>;
|
2072
|
}
|
2073
|
|
2074
|
namespace promises {
|
2075
|
interface FileHandle {
|
2076
|
/**
|
2077
|
* Gets the file descriptor for this file handle.
|
2078
|
*/
|
2079
|
readonly fd: number;
|
2080
|
|
2081
|
/**
|
2082
|
* Asynchronously append data to a file, creating the file if it does not exist. The underlying file will _not_ be closed automatically.
|
2083
|
* The `FileHandle` must have been opened for appending.
|
2084
|
* @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
|
2085
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
2086
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
2087
|
* If `mode` is not supplied, the default of `0o666` is used.
|
2088
|
* If `mode` is a string, it is parsed as an octal integer.
|
2089
|
* If `flag` is not supplied, the default of `'a'` is used.
|
2090
|
*/
|
2091
|
appendFile(data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
|
2092
|
|
2093
|
/**
|
2094
|
* Asynchronous fchown(2) - Change ownership of a file.
|
2095
|
*/
|
2096
|
chown(uid: number, gid: number): Promise<void>;
|
2097
|
|
2098
|
/**
|
2099
|
* Asynchronous fchmod(2) - Change permissions of a file.
|
2100
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
2101
|
*/
|
2102
|
chmod(mode: string | number): Promise<void>;
|
2103
|
|
2104
|
/**
|
2105
|
* Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
|
2106
|
*/
|
2107
|
datasync(): Promise<void>;
|
2108
|
|
2109
|
/**
|
2110
|
* Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
|
2111
|
*/
|
2112
|
sync(): Promise<void>;
|
2113
|
|
2114
|
/**
|
2115
|
* Asynchronously reads data from the file.
|
2116
|
* The `FileHandle` must have been opened for reading.
|
2117
|
* @param buffer The buffer that the data will be written to.
|
2118
|
* @param offset The offset in the buffer at which to start writing.
|
2119
|
* @param length The number of bytes to read.
|
2120
|
* @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.
|
2121
|
*/
|
2122
|
read<TBuffer extends Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesRead: number, buffer: TBuffer }>;
|
2123
|
|
2124
|
/**
|
2125
|
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
2126
|
* The `FileHandle` must have been opened for reading.
|
2127
|
* @param options An object that may contain an optional flag.
|
2128
|
* If a flag is not provided, it defaults to `'r'`.
|
2129
|
*/
|
2130
|
readFile(options?: { encoding?: null, flag?: string | number } | null): Promise<Buffer>;
|
2131
|
|
2132
|
/**
|
2133
|
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
2134
|
* The `FileHandle` must have been opened for reading.
|
2135
|
* @param options An object that may contain an optional flag.
|
2136
|
* If a flag is not provided, it defaults to `'r'`.
|
2137
|
*/
|
2138
|
readFile(options: { encoding: BufferEncoding, flag?: string | number } | BufferEncoding): Promise<string>;
|
2139
|
|
2140
|
/**
|
2141
|
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
2142
|
* The `FileHandle` must have been opened for reading.
|
2143
|
* @param options An object that may contain an optional flag.
|
2144
|
* If a flag is not provided, it defaults to `'r'`.
|
2145
|
*/
|
2146
|
readFile(options?: { encoding?: string | null, flag?: string | number } | string | null): Promise<string | Buffer>;
|
2147
|
|
2148
|
/**
|
2149
|
* Asynchronous fstat(2) - Get file status.
|
2150
|
*/
|
2151
|
stat(): Promise<Stats>;
|
2152
|
|
2153
|
/**
|
2154
|
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
2155
|
* @param len If not specified, defaults to `0`.
|
2156
|
*/
|
2157
|
truncate(len?: number): Promise<void>;
|
2158
|
|
2159
|
/**
|
2160
|
* Asynchronously change file timestamps of the file.
|
2161
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
2162
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
2163
|
*/
|
2164
|
utimes(atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
2165
|
|
2166
|
/**
|
2167
|
* Asynchronously writes `buffer` to the file.
|
2168
|
* The `FileHandle` must have been opened for writing.
|
2169
|
* @param buffer The buffer that the data will be written to.
|
2170
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
|
2171
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
2172
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
2173
|
*/
|
2174
|
write<TBuffer extends Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
|
2175
|
|
2176
|
/**
|
2177
|
* Asynchronously writes `string` to the file.
|
2178
|
* The `FileHandle` must have been opened for writing.
|
2179
|
* It is unsafe to call `write()` multiple times on the same file without waiting for the `Promise`
|
2180
|
* to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
|
2181
|
* @param string A string to write. If something other than a string is supplied it will be coerced to a string.
|
2182
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
2183
|
* @param encoding The expected string encoding.
|
2184
|
*/
|
2185
|
write(data: any, position?: number | null, encoding?: string | null): Promise<{ bytesWritten: number, buffer: string }>;
|
2186
|
|
2187
|
/**
|
2188
|
* Asynchronously writes data to a file, replacing the file if it already exists. The underlying file will _not_ be closed automatically.
|
2189
|
* The `FileHandle` must have been opened for writing.
|
2190
|
* It is unsafe to call `writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
|
2191
|
* @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
|
2192
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
2193
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
2194
|
* If `mode` is not supplied, the default of `0o666` is used.
|
2195
|
* If `mode` is a string, it is parsed as an octal integer.
|
2196
|
* If `flag` is not supplied, the default of `'w'` is used.
|
2197
|
*/
|
2198
|
writeFile(data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
|
2199
|
|
2200
|
/**
|
2201
|
* See `fs.writev` promisified version.
|
2202
|
*/
|
2203
|
writev(buffers: NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
|
2204
|
|
2205
|
/**
|
2206
|
* Asynchronous close(2) - close a `FileHandle`.
|
2207
|
*/
|
2208
|
close(): Promise<void>;
|
2209
|
}
|
2210
|
|
2211
|
/**
|
2212
|
* Asynchronously tests a user's permissions for the file specified by path.
|
2213
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
2214
|
* URL support is _experimental_.
|
2215
|
*/
|
2216
|
function access(path: PathLike, mode?: number): Promise<void>;
|
2217
|
|
2218
|
/**
|
2219
|
* Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it already exists.
|
2220
|
* Node.js makes no guarantees about the atomicity of the copy operation.
|
2221
|
* If an error occurs after the destination file has been opened for writing, Node.js will attempt
|
2222
|
* to remove the destination.
|
2223
|
* @param src A path to the source file.
|
2224
|
* @param dest A path to the destination file.
|
2225
|
* @param flags An optional integer that specifies the behavior of the copy operation. The only
|
2226
|
* supported flag is `fs.constants.COPYFILE_EXCL`, which causes the copy operation to fail if
|
2227
|
* `dest` already exists.
|
2228
|
*/
|
2229
|
function copyFile(src: PathLike, dest: PathLike, flags?: number): Promise<void>;
|
2230
|
|
2231
|
/**
|
2232
|
* Asynchronous open(2) - open and possibly create a file.
|
2233
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2234
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not
|
2235
|
* supplied, defaults to `0o666`.
|
2236
|
*/
|
2237
|
function open(path: PathLike, flags: string | number, mode?: string | number): Promise<FileHandle>;
|
2238
|
|
2239
|
/**
|
2240
|
* Asynchronously reads data from the file referenced by the supplied `FileHandle`.
|
2241
|
* @param handle A `FileHandle`.
|
2242
|
* @param buffer The buffer that the data will be written to.
|
2243
|
* @param offset The offset in the buffer at which to start writing.
|
2244
|
* @param length The number of bytes to read.
|
2245
|
* @param position The offset from the beginning of the file from which data should be read. If
|
2246
|
* `null`, data will be read from the current position.
|
2247
|
*/
|
2248
|
function read<TBuffer extends Uint8Array>(
|
2249
|
handle: FileHandle,
|
2250
|
buffer: TBuffer,
|
2251
|
offset?: number | null,
|
2252
|
length?: number | null,
|
2253
|
position?: number | null,
|
2254
|
): Promise<{ bytesRead: number, buffer: TBuffer }>;
|
2255
|
|
2256
|
/**
|
2257
|
* Asynchronously writes `buffer` to the file referenced by the supplied `FileHandle`.
|
2258
|
* It is unsafe to call `fsPromises.write()` multiple times on the same file without waiting for the `Promise`
|
2259
|
* to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
|
2260
|
* @param handle A `FileHandle`.
|
2261
|
* @param buffer The buffer that the data will be written to.
|
2262
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
|
2263
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
2264
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
2265
|
*/
|
2266
|
function write<TBuffer extends Uint8Array>(
|
2267
|
handle: FileHandle,
|
2268
|
buffer: TBuffer,
|
2269
|
offset?: number | null,
|
2270
|
length?: number | null, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
|
2271
|
|
2272
|
/**
|
2273
|
* Asynchronously writes `string` to the file referenced by the supplied `FileHandle`.
|
2274
|
* It is unsafe to call `fsPromises.write()` multiple times on the same file without waiting for the `Promise`
|
2275
|
* to be resolved (or rejected). For this scenario, `fs.createWriteStream` is strongly recommended.
|
2276
|
* @param handle A `FileHandle`.
|
2277
|
* @param string A string to write. If something other than a string is supplied it will be coerced to a string.
|
2278
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
2279
|
* @param encoding The expected string encoding.
|
2280
|
*/
|
2281
|
function write(handle: FileHandle, string: any, position?: number | null, encoding?: string | null): Promise<{ bytesWritten: number, buffer: string }>;
|
2282
|
|
2283
|
/**
|
2284
|
* Asynchronous rename(2) - Change the name or location of a file or directory.
|
2285
|
* @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2286
|
* URL support is _experimental_.
|
2287
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2288
|
* URL support is _experimental_.
|
2289
|
*/
|
2290
|
function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
|
2291
|
|
2292
|
/**
|
2293
|
* Asynchronous truncate(2) - Truncate a file to a specified length.
|
2294
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2295
|
* @param len If not specified, defaults to `0`.
|
2296
|
*/
|
2297
|
function truncate(path: PathLike, len?: number): Promise<void>;
|
2298
|
|
2299
|
/**
|
2300
|
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
2301
|
* @param handle A `FileHandle`.
|
2302
|
* @param len If not specified, defaults to `0`.
|
2303
|
*/
|
2304
|
function ftruncate(handle: FileHandle, len?: number): Promise<void>;
|
2305
|
|
2306
|
/**
|
2307
|
* Asynchronous rmdir(2) - delete a directory.
|
2308
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2309
|
*/
|
2310
|
function rmdir(path: PathLike, options?: RmDirAsyncOptions): Promise<void>;
|
2311
|
|
2312
|
/**
|
2313
|
* Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
|
2314
|
* @param handle A `FileHandle`.
|
2315
|
*/
|
2316
|
function fdatasync(handle: FileHandle): Promise<void>;
|
2317
|
|
2318
|
/**
|
2319
|
* Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
|
2320
|
* @param handle A `FileHandle`.
|
2321
|
*/
|
2322
|
function fsync(handle: FileHandle): Promise<void>;
|
2323
|
|
2324
|
/**
|
2325
|
* Asynchronous mkdir(2) - create a directory.
|
2326
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2327
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
2328
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
2329
|
*/
|
2330
|
function mkdir(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): Promise<string>;
|
2331
|
|
2332
|
/**
|
2333
|
* Asynchronous mkdir(2) - create a directory.
|
2334
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2335
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
2336
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
2337
|
*/
|
2338
|
function mkdir(path: PathLike, options?: number | string | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise<void>;
|
2339
|
|
2340
|
/**
|
2341
|
* Asynchronous mkdir(2) - create a directory.
|
2342
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2343
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
2344
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
2345
|
*/
|
2346
|
function mkdir(path: PathLike, options?: number | string | MakeDirectoryOptions | null): Promise<string | undefined>;
|
2347
|
|
2348
|
/**
|
2349
|
* Asynchronous readdir(3) - read a directory.
|
2350
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2351
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2352
|
*/
|
2353
|
function readdir(path: PathLike, options?: { encoding?: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): Promise<string[]>;
|
2354
|
|
2355
|
/**
|
2356
|
* Asynchronous readdir(3) - read a directory.
|
2357
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2358
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2359
|
*/
|
2360
|
function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Promise<Buffer[]>;
|
2361
|
|
2362
|
/**
|
2363
|
* Asynchronous readdir(3) - read a directory.
|
2364
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2365
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2366
|
*/
|
2367
|
function readdir(path: PathLike, options?: { encoding?: string | null; withFileTypes?: false } | string | null): Promise<string[] | Buffer[]>;
|
2368
|
|
2369
|
/**
|
2370
|
* Asynchronous readdir(3) - read a directory.
|
2371
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2372
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
2373
|
*/
|
2374
|
function readdir(path: PathLike, options: { encoding?: string | null; withFileTypes: true }): Promise<Dirent[]>;
|
2375
|
|
2376
|
/**
|
2377
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
2378
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2379
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2380
|
*/
|
2381
|
function readlink(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
|
2382
|
|
2383
|
/**
|
2384
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
2385
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2386
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2387
|
*/
|
2388
|
function readlink(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
|
2389
|
|
2390
|
/**
|
2391
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
2392
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2393
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2394
|
*/
|
2395
|
function readlink(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
|
2396
|
|
2397
|
/**
|
2398
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
|
2399
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
|
2400
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
|
2401
|
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
|
2402
|
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
|
2403
|
*/
|
2404
|
function symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
|
2405
|
|
2406
|
/**
|
2407
|
* Asynchronous fstat(2) - Get file status.
|
2408
|
* @param handle A `FileHandle`.
|
2409
|
*/
|
2410
|
function fstat(handle: FileHandle): Promise<Stats>;
|
2411
|
|
2412
|
/**
|
2413
|
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
2414
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2415
|
*/
|
2416
|
function lstat(path: PathLike): Promise<Stats>;
|
2417
|
|
2418
|
/**
|
2419
|
* Asynchronous stat(2) - Get file status.
|
2420
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2421
|
*/
|
2422
|
function stat(path: PathLike): Promise<Stats>;
|
2423
|
|
2424
|
/**
|
2425
|
* Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
|
2426
|
* @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2427
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2428
|
*/
|
2429
|
function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
|
2430
|
|
2431
|
/**
|
2432
|
* Asynchronous unlink(2) - delete a name and possibly the file it refers to.
|
2433
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2434
|
*/
|
2435
|
function unlink(path: PathLike): Promise<void>;
|
2436
|
|
2437
|
/**
|
2438
|
* Asynchronous fchmod(2) - Change permissions of a file.
|
2439
|
* @param handle A `FileHandle`.
|
2440
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
2441
|
*/
|
2442
|
function fchmod(handle: FileHandle, mode: string | number): Promise<void>;
|
2443
|
|
2444
|
/**
|
2445
|
* Asynchronous chmod(2) - Change permissions of a file.
|
2446
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2447
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
2448
|
*/
|
2449
|
function chmod(path: PathLike, mode: string | number): Promise<void>;
|
2450
|
|
2451
|
/**
|
2452
|
* Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.
|
2453
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2454
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer.
|
2455
|
*/
|
2456
|
function lchmod(path: PathLike, mode: string | number): Promise<void>;
|
2457
|
|
2458
|
/**
|
2459
|
* Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
|
2460
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2461
|
*/
|
2462
|
function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
|
2463
|
|
2464
|
/**
|
2465
|
* Asynchronous fchown(2) - Change ownership of a file.
|
2466
|
* @param handle A `FileHandle`.
|
2467
|
*/
|
2468
|
function fchown(handle: FileHandle, uid: number, gid: number): Promise<void>;
|
2469
|
|
2470
|
/**
|
2471
|
* Asynchronous chown(2) - Change ownership of a file.
|
2472
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2473
|
*/
|
2474
|
function chown(path: PathLike, uid: number, gid: number): Promise<void>;
|
2475
|
|
2476
|
/**
|
2477
|
* Asynchronously change file timestamps of the file referenced by the supplied path.
|
2478
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2479
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
2480
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
2481
|
*/
|
2482
|
function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
2483
|
|
2484
|
/**
|
2485
|
* Asynchronously change file timestamps of the file referenced by the supplied `FileHandle`.
|
2486
|
* @param handle A `FileHandle`.
|
2487
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
2488
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number.
|
2489
|
*/
|
2490
|
function futimes(handle: FileHandle, atime: string | number | Date, mtime: string | number | Date): Promise<void>;
|
2491
|
|
2492
|
/**
|
2493
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
2494
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2495
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2496
|
*/
|
2497
|
function realpath(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
|
2498
|
|
2499
|
/**
|
2500
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
2501
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2502
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2503
|
*/
|
2504
|
function realpath(path: PathLike, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
|
2505
|
|
2506
|
/**
|
2507
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
2508
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2509
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2510
|
*/
|
2511
|
function realpath(path: PathLike, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
|
2512
|
|
2513
|
/**
|
2514
|
* Asynchronously creates a unique temporary directory.
|
2515
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
2516
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2517
|
*/
|
2518
|
function mkdtemp(prefix: string, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise<string>;
|
2519
|
|
2520
|
/**
|
2521
|
* Asynchronously creates a unique temporary directory.
|
2522
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
2523
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2524
|
*/
|
2525
|
function mkdtemp(prefix: string, options: { encoding: "buffer" } | "buffer"): Promise<Buffer>;
|
2526
|
|
2527
|
/**
|
2528
|
* Asynchronously creates a unique temporary directory.
|
2529
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
2530
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
2531
|
*/
|
2532
|
function mkdtemp(prefix: string, options?: { encoding?: string | null } | string | null): Promise<string | Buffer>;
|
2533
|
|
2534
|
/**
|
2535
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
2536
|
* It is unsafe to call `fsPromises.writeFile()` multiple times on the same file without waiting for the `Promise` to be resolved (or rejected).
|
2537
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2538
|
* URL support is _experimental_.
|
2539
|
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
2540
|
* @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
|
2541
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
2542
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
2543
|
* If `mode` is not supplied, the default of `0o666` is used.
|
2544
|
* If `mode` is a string, it is parsed as an octal integer.
|
2545
|
* If `flag` is not supplied, the default of `'w'` is used.
|
2546
|
*/
|
2547
|
function writeFile(path: PathLike | FileHandle, data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
|
2548
|
|
2549
|
/**
|
2550
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
2551
|
* @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2552
|
* URL support is _experimental_.
|
2553
|
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
2554
|
* @param data The data to write. If something other than a `Buffer` or `Uint8Array` is provided, the value is coerced to a string.
|
2555
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
|
2556
|
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
2557
|
* If `mode` is not supplied, the default of `0o666` is used.
|
2558
|
* If `mode` is a string, it is parsed as an octal integer.
|
2559
|
* If `flag` is not supplied, the default of `'a'` is used.
|
2560
|
*/
|
2561
|
function appendFile(path: PathLike | FileHandle, data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
|
2562
|
|
2563
|
/**
|
2564
|
* Asynchronously reads the entire contents of a file.
|
2565
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2566
|
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
2567
|
* @param options An object that may contain an optional flag.
|
2568
|
* If a flag is not provided, it defaults to `'r'`.
|
2569
|
*/
|
2570
|
function readFile(path: PathLike | FileHandle, options?: { encoding?: null, flag?: string | number } | null): Promise<Buffer>;
|
2571
|
|
2572
|
/**
|
2573
|
* Asynchronously reads the entire contents of a file.
|
2574
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2575
|
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
2576
|
* @param options An object that may contain an optional flag.
|
2577
|
* If a flag is not provided, it defaults to `'r'`.
|
2578
|
*/
|
2579
|
function readFile(path: PathLike | FileHandle, options: { encoding: BufferEncoding, flag?: string | number } | BufferEncoding): Promise<string>;
|
2580
|
|
2581
|
/**
|
2582
|
* Asynchronously reads the entire contents of a file.
|
2583
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
2584
|
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
2585
|
* @param options An object that may contain an optional flag.
|
2586
|
* If a flag is not provided, it defaults to `'r'`.
|
2587
|
*/
|
2588
|
function readFile(path: PathLike | FileHandle, options?: { encoding?: string | null, flag?: string | number } | string | null): Promise<string | Buffer>;
|
2589
|
|
2590
|
function opendir(path: string, options?: OpenDirOptions): Promise<Dir>;
|
2591
|
}
|
2592
|
}
|