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