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