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