1
|
|
|
declare module "fs" { |
2
|
|
|
import * as stream from "stream"; |
3
|
|
|
import * as events from "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; |
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; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
export interface FSWatcher extends events.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
|
|
|
* Asynchronous chmod(2) - Change permissions of a file. |
432
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
433
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. |
434
|
|
|
*/ |
435
|
|
|
export function chmod(path: PathLike, mode: Mode, callback: NoParamCallback): void; |
436
|
|
|
|
437
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
438
|
|
|
export namespace chmod { |
439
|
|
|
/** |
440
|
|
|
* Asynchronous chmod(2) - Change permissions of a file. |
441
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
442
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. |
443
|
|
|
*/ |
444
|
|
|
function __promisify__(path: PathLike, mode: Mode): Promise<void>; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* Synchronous chmod(2) - Change permissions of a file. |
449
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
450
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. |
451
|
|
|
*/ |
452
|
|
|
export function chmodSync(path: PathLike, mode: Mode): void; |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* Asynchronous fchmod(2) - Change permissions of a file. |
456
|
|
|
* @param fd A file descriptor. |
457
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. |
458
|
|
|
*/ |
459
|
|
|
export function fchmod(fd: number, mode: Mode, callback: NoParamCallback): void; |
460
|
|
|
|
461
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
462
|
|
|
export namespace fchmod { |
463
|
|
|
/** |
464
|
|
|
* Asynchronous fchmod(2) - Change permissions of a file. |
465
|
|
|
* @param fd A file descriptor. |
466
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. |
467
|
|
|
*/ |
468
|
|
|
function __promisify__(fd: number, mode: Mode): Promise<void>; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* Synchronous fchmod(2) - Change permissions of a file. |
473
|
|
|
* @param fd A file descriptor. |
474
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. |
475
|
|
|
*/ |
476
|
|
|
export function fchmodSync(fd: number, mode: Mode): void; |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links. |
480
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
481
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. |
482
|
|
|
*/ |
483
|
|
|
export function lchmod(path: PathLike, mode: Mode, callback: NoParamCallback): void; |
484
|
|
|
|
485
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
486
|
|
|
export namespace lchmod { |
487
|
|
|
/** |
488
|
|
|
* Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links. |
489
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
490
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. |
491
|
|
|
*/ |
492
|
|
|
function __promisify__(path: PathLike, mode: Mode): Promise<void>; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
/** |
496
|
|
|
* Synchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links. |
497
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
498
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. |
499
|
|
|
*/ |
500
|
|
|
export function lchmodSync(path: PathLike, mode: Mode): void; |
501
|
|
|
|
502
|
|
|
/** |
503
|
|
|
* Asynchronous stat(2) - Get file status. |
504
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
505
|
|
|
*/ |
506
|
|
|
export function stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; |
507
|
|
|
|
508
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
509
|
|
|
export namespace stat { |
510
|
|
|
/** |
511
|
|
|
* Asynchronous stat(2) - Get file status. |
512
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
513
|
|
|
*/ |
514
|
|
|
function __promisify__(path: PathLike): Promise<Stats>; |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* Synchronous stat(2) - Get file status. |
519
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
520
|
|
|
*/ |
521
|
|
|
export function statSync(path: PathLike): Stats; |
522
|
|
|
|
523
|
|
|
/** |
524
|
|
|
* Asynchronous fstat(2) - Get file status. |
525
|
|
|
* @param fd A file descriptor. |
526
|
|
|
*/ |
527
|
|
|
export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; |
528
|
|
|
|
529
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
530
|
|
|
export namespace fstat { |
531
|
|
|
/** |
532
|
|
|
* Asynchronous fstat(2) - Get file status. |
533
|
|
|
* @param fd A file descriptor. |
534
|
|
|
*/ |
535
|
|
|
function __promisify__(fd: number): Promise<Stats>; |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* Synchronous fstat(2) - Get file status. |
540
|
|
|
* @param fd A file descriptor. |
541
|
|
|
*/ |
542
|
|
|
export function fstatSync(fd: number): Stats; |
543
|
|
|
|
544
|
|
|
/** |
545
|
|
|
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links. |
546
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
547
|
|
|
*/ |
548
|
|
|
export function lstat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; |
549
|
|
|
|
550
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
551
|
|
|
export namespace lstat { |
552
|
|
|
/** |
553
|
|
|
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links. |
554
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
555
|
|
|
*/ |
556
|
|
|
function __promisify__(path: PathLike): Promise<Stats>; |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
/** |
560
|
|
|
* Synchronous lstat(2) - Get file status. Does not dereference symbolic links. |
561
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
562
|
|
|
*/ |
563
|
|
|
export function lstatSync(path: PathLike): Stats; |
564
|
|
|
|
565
|
|
|
/** |
566
|
|
|
* Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file. |
567
|
|
|
* @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol. |
568
|
|
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol. |
569
|
|
|
*/ |
570
|
|
|
export function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void; |
571
|
|
|
|
572
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
573
|
|
|
export namespace link { |
574
|
|
|
/** |
575
|
|
|
* Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file. |
576
|
|
|
* @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol. |
577
|
|
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol. |
578
|
|
|
*/ |
579
|
|
|
function __promisify__(existingPath: PathLike, newPath: PathLike): Promise<void>; |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
/** |
583
|
|
|
* Synchronous link(2) - Create a new link (also known as a hard link) to an existing file. |
584
|
|
|
* @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol. |
585
|
|
|
* @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol. |
586
|
|
|
*/ |
587
|
|
|
export function linkSync(existingPath: PathLike, newPath: PathLike): void; |
588
|
|
|
|
589
|
|
|
/** |
590
|
|
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file. |
591
|
|
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol. |
592
|
|
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol. |
593
|
|
|
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). |
594
|
|
|
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. |
595
|
|
|
*/ |
596
|
|
|
export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void; |
597
|
|
|
|
598
|
|
|
/** |
599
|
|
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file. |
600
|
|
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol. |
601
|
|
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol. |
602
|
|
|
*/ |
603
|
|
|
export function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void; |
604
|
|
|
|
605
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
606
|
|
|
export namespace symlink { |
607
|
|
|
/** |
608
|
|
|
* Asynchronous symlink(2) - Create a new symbolic link to an existing file. |
609
|
|
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol. |
610
|
|
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol. |
611
|
|
|
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). |
612
|
|
|
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. |
613
|
|
|
*/ |
614
|
|
|
function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>; |
615
|
|
|
|
616
|
|
|
type Type = "dir" | "file" | "junction"; |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
/** |
620
|
|
|
* Synchronous symlink(2) - Create a new symbolic link to an existing file. |
621
|
|
|
* @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol. |
622
|
|
|
* @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol. |
623
|
|
|
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms). |
624
|
|
|
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path. |
625
|
|
|
*/ |
626
|
|
|
export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void; |
627
|
|
|
|
628
|
|
|
/** |
629
|
|
|
* Asynchronous readlink(2) - read value of a symbolic link. |
630
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
631
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
632
|
|
|
*/ |
633
|
|
|
export function readlink( |
634
|
|
|
path: PathLike, |
635
|
|
|
options: BaseEncodingOptions | BufferEncoding | undefined | null, |
636
|
|
|
callback: (err: NodeJS.ErrnoException | null, linkString: string) => void |
637
|
|
|
): void; |
638
|
|
|
|
639
|
|
|
/** |
640
|
|
|
* Asynchronous readlink(2) - read value of a symbolic link. |
641
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
642
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
643
|
|
|
*/ |
644
|
|
|
export function readlink(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void; |
645
|
|
|
|
646
|
|
|
/** |
647
|
|
|
* Asynchronous readlink(2) - read value of a symbolic link. |
648
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
649
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
650
|
|
|
*/ |
651
|
|
|
export function readlink(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void): void; |
652
|
|
|
|
653
|
|
|
/** |
654
|
|
|
* Asynchronous readlink(2) - read value of a symbolic link. |
655
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
656
|
|
|
*/ |
657
|
|
|
export function readlink(path: PathLike, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void; |
658
|
|
|
|
659
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
660
|
|
|
export namespace readlink { |
661
|
|
|
/** |
662
|
|
|
* Asynchronous readlink(2) - read value of a symbolic link. |
663
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
664
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
665
|
|
|
*/ |
666
|
|
|
function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>; |
667
|
|
|
|
668
|
|
|
/** |
669
|
|
|
* Asynchronous readlink(2) - read value of a symbolic link. |
670
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
671
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
672
|
|
|
*/ |
673
|
|
|
function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>; |
674
|
|
|
|
675
|
|
|
/** |
676
|
|
|
* Asynchronous readlink(2) - read value of a symbolic link. |
677
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
678
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
679
|
|
|
*/ |
680
|
|
|
function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>; |
681
|
|
|
} |
682
|
|
|
|
683
|
|
|
/** |
684
|
|
|
* Synchronous readlink(2) - read value of a symbolic link. |
685
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
686
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
687
|
|
|
*/ |
688
|
|
|
export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string; |
689
|
|
|
|
690
|
|
|
/** |
691
|
|
|
* Synchronous readlink(2) - read value of a symbolic link. |
692
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
693
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
694
|
|
|
*/ |
695
|
|
|
export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer; |
696
|
|
|
|
697
|
|
|
/** |
698
|
|
|
* Synchronous readlink(2) - read value of a symbolic link. |
699
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
700
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
701
|
|
|
*/ |
702
|
|
|
export function readlinkSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer; |
703
|
|
|
|
704
|
|
|
/** |
705
|
|
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname. |
706
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
707
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
708
|
|
|
*/ |
709
|
|
|
export function realpath( |
710
|
|
|
path: PathLike, |
711
|
|
|
options: BaseEncodingOptions | BufferEncoding | undefined | null, |
712
|
|
|
callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void |
713
|
|
|
): void; |
714
|
|
|
|
715
|
|
|
/** |
716
|
|
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname. |
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
|
|
|
export function realpath(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void; |
721
|
|
|
|
722
|
|
|
/** |
723
|
|
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname. |
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
|
|
|
export function realpath(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void; |
728
|
|
|
|
729
|
|
|
/** |
730
|
|
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname. |
731
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
732
|
|
|
*/ |
733
|
|
|
export function realpath(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void; |
734
|
|
|
|
735
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
736
|
|
|
export namespace realpath { |
737
|
|
|
/** |
738
|
|
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname. |
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
|
|
|
function __promisify__(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>; |
743
|
|
|
|
744
|
|
|
/** |
745
|
|
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname. |
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
|
|
|
function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>; |
750
|
|
|
|
751
|
|
|
/** |
752
|
|
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname. |
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
|
|
|
function __promisify__(path: PathLike, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>; |
757
|
|
|
|
758
|
|
|
function native( |
759
|
|
|
path: PathLike, |
760
|
|
|
options: BaseEncodingOptions | BufferEncoding | undefined | null, |
761
|
|
|
callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void |
762
|
|
|
): void; |
763
|
|
|
function native(path: PathLike, options: BufferEncodingOption, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void; |
764
|
|
|
function native(path: PathLike, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void): void; |
765
|
|
|
function native(path: PathLike, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void; |
766
|
|
|
} |
767
|
|
|
|
768
|
|
|
/** |
769
|
|
|
* Synchronous realpath(3) - return the canonicalized absolute pathname. |
770
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
771
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
772
|
|
|
*/ |
773
|
|
|
export function realpathSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string; |
774
|
|
|
|
775
|
|
|
/** |
776
|
|
|
* Synchronous realpath(3) - return the canonicalized absolute pathname. |
777
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
778
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
779
|
|
|
*/ |
780
|
|
|
export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer; |
781
|
|
|
|
782
|
|
|
/** |
783
|
|
|
* Synchronous realpath(3) - return the canonicalized absolute pathname. |
784
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
785
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
786
|
|
|
*/ |
787
|
|
|
export function realpathSync(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer; |
788
|
|
|
|
789
|
|
|
export namespace realpathSync { |
790
|
|
|
function native(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | null): string; |
791
|
|
|
function native(path: PathLike, options: BufferEncodingOption): Buffer; |
792
|
|
|
function native(path: PathLike, options?: BaseEncodingOptions | string | null): string | Buffer; |
793
|
|
|
} |
794
|
|
|
|
795
|
|
|
/** |
796
|
|
|
* Asynchronous unlink(2) - delete a name and possibly the file it refers to. |
797
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
798
|
|
|
*/ |
799
|
|
|
export function unlink(path: PathLike, callback: NoParamCallback): void; |
800
|
|
|
|
801
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
802
|
|
|
export namespace unlink { |
803
|
|
|
/** |
804
|
|
|
* Asynchronous unlink(2) - delete a name and possibly the file it refers to. |
805
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
806
|
|
|
*/ |
807
|
|
|
function __promisify__(path: PathLike): Promise<void>; |
808
|
|
|
} |
809
|
|
|
|
810
|
|
|
/** |
811
|
|
|
* Synchronous unlink(2) - delete a name and possibly the file it refers to. |
812
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
813
|
|
|
*/ |
814
|
|
|
export function unlinkSync(path: PathLike): void; |
815
|
|
|
|
816
|
|
|
export interface RmDirOptions { |
817
|
|
|
/** |
818
|
|
|
* If `true`, perform a recursive directory removal. In |
819
|
|
|
* recursive mode, errors are not reported if `path` does not exist, and |
820
|
|
|
* operations are retried on failure. |
821
|
|
|
* @experimental |
822
|
|
|
* @default false |
823
|
|
|
*/ |
824
|
|
|
recursive?: boolean; |
825
|
|
|
} |
826
|
|
|
|
827
|
|
|
export interface RmDirAsyncOptions extends RmDirOptions { |
828
|
|
|
/** |
829
|
|
|
* The amount of time in milliseconds to wait between retries. |
830
|
|
|
* This option is ignored if the `recursive` option is not `true`. |
831
|
|
|
* @default 100 |
832
|
|
|
*/ |
833
|
|
|
retryDelay?: number; |
834
|
|
|
/** |
835
|
|
|
* If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or |
836
|
|
|
* `EPERM` error is encountered, Node.js will retry the operation with a linear |
837
|
|
|
* backoff wait of `retryDelay` ms longer on each try. This option represents the |
838
|
|
|
* number of retries. This option is ignored if the `recursive` option is not |
839
|
|
|
* `true`. |
840
|
|
|
* @default 0 |
841
|
|
|
*/ |
842
|
|
|
maxRetries?: number; |
843
|
|
|
} |
844
|
|
|
|
845
|
|
|
/** |
846
|
|
|
* Asynchronous rmdir(2) - delete a directory. |
847
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
848
|
|
|
*/ |
849
|
|
|
export function rmdir(path: PathLike, callback: NoParamCallback): void; |
850
|
|
|
export function rmdir(path: PathLike, options: RmDirAsyncOptions, callback: NoParamCallback): void; |
851
|
|
|
|
852
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
853
|
|
|
export namespace rmdir { |
854
|
|
|
/** |
855
|
|
|
* Asynchronous rmdir(2) - delete a directory. |
856
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
857
|
|
|
*/ |
858
|
|
|
function __promisify__(path: PathLike, options?: RmDirAsyncOptions): Promise<void>; |
859
|
|
|
} |
860
|
|
|
|
861
|
|
|
/** |
862
|
|
|
* Synchronous rmdir(2) - delete a directory. |
863
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
864
|
|
|
*/ |
865
|
|
|
export function rmdirSync(path: PathLike, options?: RmDirOptions): void; |
866
|
|
|
|
867
|
|
|
export interface MakeDirectoryOptions { |
868
|
|
|
/** |
869
|
|
|
* Indicates whether parent folders should be created. |
870
|
|
|
* If a folder was created, the path to the first created folder will be returned. |
871
|
|
|
* @default false |
872
|
|
|
*/ |
873
|
|
|
recursive?: boolean; |
874
|
|
|
/** |
875
|
|
|
* A file mode. If a string is passed, it is parsed as an octal integer. If not specified |
876
|
|
|
* @default 0o777 |
877
|
|
|
*/ |
878
|
|
|
mode?: Mode; |
879
|
|
|
} |
880
|
|
|
|
881
|
|
|
/** |
882
|
|
|
* Asynchronous mkdir(2) - create a directory. |
883
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
884
|
|
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders |
885
|
|
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. |
886
|
|
|
*/ |
887
|
|
|
export function mkdir(path: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: (err: NodeJS.ErrnoException | null, path: string) => void): void; |
888
|
|
|
|
889
|
|
|
/** |
890
|
|
|
* Asynchronous mkdir(2) - create a directory. |
891
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
892
|
|
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders |
893
|
|
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. |
894
|
|
|
*/ |
895
|
|
|
export function mkdir(path: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null | undefined, callback: NoParamCallback): void; |
896
|
|
|
|
897
|
|
|
/** |
898
|
|
|
* Asynchronous mkdir(2) - create a directory. |
899
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
900
|
|
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders |
901
|
|
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. |
902
|
|
|
*/ |
903
|
|
|
export function mkdir(path: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: (err: NodeJS.ErrnoException | null, path: string | undefined) => void): void; |
904
|
|
|
|
905
|
|
|
/** |
906
|
|
|
* Asynchronous mkdir(2) - create a directory with a mode of `0o777`. |
907
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
908
|
|
|
*/ |
909
|
|
|
export function mkdir(path: PathLike, callback: NoParamCallback): void; |
910
|
|
|
|
911
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
912
|
|
|
export namespace mkdir { |
913
|
|
|
/** |
914
|
|
|
* Asynchronous mkdir(2) - create a directory. |
915
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
916
|
|
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders |
917
|
|
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. |
918
|
|
|
*/ |
919
|
|
|
function __promisify__(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): Promise<string>; |
920
|
|
|
|
921
|
|
|
/** |
922
|
|
|
* Asynchronous mkdir(2) - create a directory. |
923
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
924
|
|
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders |
925
|
|
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. |
926
|
|
|
*/ |
927
|
|
|
function __promisify__(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): Promise<void>; |
928
|
|
|
|
929
|
|
|
/** |
930
|
|
|
* Asynchronous mkdir(2) - create a directory. |
931
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
932
|
|
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders |
933
|
|
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. |
934
|
|
|
*/ |
935
|
|
|
function __promisify__(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>; |
936
|
|
|
} |
937
|
|
|
|
938
|
|
|
/** |
939
|
|
|
* Synchronous mkdir(2) - create a directory. |
940
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
941
|
|
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders |
942
|
|
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. |
943
|
|
|
*/ |
944
|
|
|
export function mkdirSync(path: PathLike, options: MakeDirectoryOptions & { recursive: true; }): string; |
945
|
|
|
|
946
|
|
|
/** |
947
|
|
|
* Synchronous mkdir(2) - create a directory. |
948
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
949
|
|
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders |
950
|
|
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. |
951
|
|
|
*/ |
952
|
|
|
export function mkdirSync(path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false; }) | null): void; |
953
|
|
|
|
954
|
|
|
/** |
955
|
|
|
* Synchronous mkdir(2) - create a directory. |
956
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
957
|
|
|
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders |
958
|
|
|
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`. |
959
|
|
|
*/ |
960
|
|
|
export function mkdirSync(path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined; |
961
|
|
|
|
962
|
|
|
/** |
963
|
|
|
* Asynchronously creates a unique temporary directory. |
964
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
965
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
966
|
|
|
*/ |
967
|
|
|
export function mkdtemp(prefix: string, options: BaseEncodingOptions | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void; |
968
|
|
|
|
969
|
|
|
/** |
970
|
|
|
* Asynchronously creates a unique temporary directory. |
971
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
972
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
973
|
|
|
*/ |
974
|
|
|
export function mkdtemp(prefix: string, options: "buffer" | { encoding: "buffer" }, callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void): void; |
975
|
|
|
|
976
|
|
|
/** |
977
|
|
|
* Asynchronously creates a unique temporary directory. |
978
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
979
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
980
|
|
|
*/ |
981
|
|
|
export function mkdtemp(prefix: string, options: BaseEncodingOptions | string | undefined | null, callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void): void; |
982
|
|
|
|
983
|
|
|
/** |
984
|
|
|
* Asynchronously creates a unique temporary directory. |
985
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
986
|
|
|
*/ |
987
|
|
|
export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void; |
988
|
|
|
|
989
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
990
|
|
|
export namespace mkdtemp { |
991
|
|
|
/** |
992
|
|
|
* Asynchronously creates a unique temporary directory. |
993
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
994
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
995
|
|
|
*/ |
996
|
|
|
function __promisify__(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): Promise<string>; |
997
|
|
|
|
998
|
|
|
/** |
999
|
|
|
* Asynchronously creates a unique temporary directory. |
1000
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
1001
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1002
|
|
|
*/ |
1003
|
|
|
function __promisify__(prefix: string, options: BufferEncodingOption): Promise<Buffer>; |
1004
|
|
|
|
1005
|
|
|
/** |
1006
|
|
|
* Asynchronously creates a unique temporary directory. |
1007
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
1008
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1009
|
|
|
*/ |
1010
|
|
|
function __promisify__(prefix: string, options?: BaseEncodingOptions | string | null): Promise<string | Buffer>; |
1011
|
|
|
} |
1012
|
|
|
|
1013
|
|
|
/** |
1014
|
|
|
* Synchronously creates a unique temporary directory. |
1015
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
1016
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1017
|
|
|
*/ |
1018
|
|
|
export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | BufferEncoding | null): string; |
1019
|
|
|
|
1020
|
|
|
/** |
1021
|
|
|
* Synchronously creates a unique temporary directory. |
1022
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
1023
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1024
|
|
|
*/ |
1025
|
|
|
export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer; |
1026
|
|
|
|
1027
|
|
|
/** |
1028
|
|
|
* Synchronously creates a unique temporary directory. |
1029
|
|
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory. |
1030
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1031
|
|
|
*/ |
1032
|
|
|
export function mkdtempSync(prefix: string, options?: BaseEncodingOptions | string | null): string | Buffer; |
1033
|
|
|
|
1034
|
|
|
/** |
1035
|
|
|
* Asynchronous readdir(3) - read a directory. |
1036
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1037
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1038
|
|
|
*/ |
1039
|
|
|
export function readdir( |
1040
|
|
|
path: PathLike, |
1041
|
|
|
options: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | undefined | null, |
1042
|
|
|
callback: (err: NodeJS.ErrnoException | null, files: string[]) => void, |
1043
|
|
|
): void; |
1044
|
|
|
|
1045
|
|
|
/** |
1046
|
|
|
* Asynchronous readdir(3) - read a directory. |
1047
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1048
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1049
|
|
|
*/ |
1050
|
|
|
export function readdir(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer", callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void; |
1051
|
|
|
|
1052
|
|
|
/** |
1053
|
|
|
* Asynchronous readdir(3) - read a directory. |
1054
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1055
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1056
|
|
|
*/ |
1057
|
|
|
export function readdir( |
1058
|
|
|
path: PathLike, |
1059
|
|
|
options: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | undefined | null, |
1060
|
|
|
callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void, |
1061
|
|
|
): void; |
1062
|
|
|
|
1063
|
|
|
/** |
1064
|
|
|
* Asynchronous readdir(3) - read a directory. |
1065
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1066
|
|
|
*/ |
1067
|
|
|
export function readdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void; |
1068
|
|
|
|
1069
|
|
|
/** |
1070
|
|
|
* Asynchronous readdir(3) - read a directory. |
1071
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1072
|
|
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent. |
1073
|
|
|
*/ |
1074
|
|
|
export function readdir(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }, callback: (err: NodeJS.ErrnoException | null, files: Dirent[]) => void): void; |
1075
|
|
|
|
1076
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1077
|
|
|
export namespace readdir { |
1078
|
|
|
/** |
1079
|
|
|
* Asynchronous readdir(3) - read a directory. |
1080
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1081
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1082
|
|
|
*/ |
1083
|
|
|
function __promisify__(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): Promise<string[]>; |
1084
|
|
|
|
1085
|
|
|
/** |
1086
|
|
|
* Asynchronous readdir(3) - read a directory. |
1087
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1088
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1089
|
|
|
*/ |
1090
|
|
|
function __promisify__(path: PathLike, options: "buffer" | { encoding: "buffer"; withFileTypes?: false }): Promise<Buffer[]>; |
1091
|
|
|
|
1092
|
|
|
/** |
1093
|
|
|
* Asynchronous readdir(3) - read a directory. |
1094
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1095
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1096
|
|
|
*/ |
1097
|
|
|
function __promisify__(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | null): Promise<string[] | Buffer[]>; |
1098
|
|
|
|
1099
|
|
|
/** |
1100
|
|
|
* Asynchronous readdir(3) - read a directory. |
1101
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1102
|
|
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent |
1103
|
|
|
*/ |
1104
|
|
|
function __promisify__(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Promise<Dirent[]>; |
1105
|
|
|
} |
1106
|
|
|
|
1107
|
|
|
/** |
1108
|
|
|
* Synchronous readdir(3) - read a directory. |
1109
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1110
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1111
|
|
|
*/ |
1112
|
|
|
export function readdirSync(path: PathLike, options?: { encoding: BufferEncoding | null; withFileTypes?: false } | BufferEncoding | null): string[]; |
1113
|
|
|
|
1114
|
|
|
/** |
1115
|
|
|
* Synchronous readdir(3) - read a directory. |
1116
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1117
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1118
|
|
|
*/ |
1119
|
|
|
export function readdirSync(path: PathLike, options: { encoding: "buffer"; withFileTypes?: false } | "buffer"): Buffer[]; |
1120
|
|
|
|
1121
|
|
|
/** |
1122
|
|
|
* Synchronous readdir(3) - read a directory. |
1123
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1124
|
|
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used. |
1125
|
|
|
*/ |
1126
|
|
|
export function readdirSync(path: PathLike, options?: BaseEncodingOptions & { withFileTypes?: false } | BufferEncoding | null): string[] | Buffer[]; |
1127
|
|
|
|
1128
|
|
|
/** |
1129
|
|
|
* Synchronous readdir(3) - read a directory. |
1130
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1131
|
|
|
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent. |
1132
|
|
|
*/ |
1133
|
|
|
export function readdirSync(path: PathLike, options: BaseEncodingOptions & { withFileTypes: true }): Dirent[]; |
1134
|
|
|
|
1135
|
|
|
/** |
1136
|
|
|
* Asynchronous close(2) - close a file descriptor. |
1137
|
|
|
* @param fd A file descriptor. |
1138
|
|
|
*/ |
1139
|
|
|
export function close(fd: number, callback: NoParamCallback): void; |
1140
|
|
|
|
1141
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1142
|
|
|
export namespace close { |
1143
|
|
|
/** |
1144
|
|
|
* Asynchronous close(2) - close a file descriptor. |
1145
|
|
|
* @param fd A file descriptor. |
1146
|
|
|
*/ |
1147
|
|
|
function __promisify__(fd: number): Promise<void>; |
1148
|
|
|
} |
1149
|
|
|
|
1150
|
|
|
/** |
1151
|
|
|
* Synchronous close(2) - close a file descriptor. |
1152
|
|
|
* @param fd A file descriptor. |
1153
|
|
|
*/ |
1154
|
|
|
export function closeSync(fd: number): void; |
1155
|
|
|
|
1156
|
|
|
/** |
1157
|
|
|
* Asynchronous open(2) - open and possibly create a file. |
1158
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1159
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`. |
1160
|
|
|
*/ |
1161
|
|
|
export function open(path: PathLike, flags: OpenMode, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; |
1162
|
|
|
|
1163
|
|
|
/** |
1164
|
|
|
* Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`. |
1165
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1166
|
|
|
*/ |
1167
|
|
|
export function open(path: PathLike, flags: OpenMode, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; |
1168
|
|
|
|
1169
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1170
|
|
|
export namespace open { |
1171
|
|
|
/** |
1172
|
|
|
* Asynchronous open(2) - open and possibly create a file. |
1173
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1174
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`. |
1175
|
|
|
*/ |
1176
|
|
|
function __promisify__(path: PathLike, flags: OpenMode, mode?: Mode | null): Promise<number>; |
1177
|
|
|
} |
1178
|
|
|
|
1179
|
|
|
/** |
1180
|
|
|
* Synchronous open(2) - open and possibly create a file, returning a file descriptor.. |
1181
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1182
|
|
|
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to `0o666`. |
1183
|
|
|
*/ |
1184
|
|
|
export function openSync(path: PathLike, flags: OpenMode, mode?: Mode | null): number; |
1185
|
|
|
|
1186
|
|
|
/** |
1187
|
|
|
* Asynchronously change file timestamps of the file referenced by the supplied path. |
1188
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1189
|
|
|
* @param atime The last access time. If a string is provided, it will be coerced to number. |
1190
|
|
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number. |
1191
|
|
|
*/ |
1192
|
|
|
export function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void; |
1193
|
|
|
|
1194
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1195
|
|
|
export namespace utimes { |
1196
|
|
|
/** |
1197
|
|
|
* Asynchronously change file timestamps of the file referenced by the supplied path. |
1198
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1199
|
|
|
* @param atime The last access time. If a string is provided, it will be coerced to number. |
1200
|
|
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number. |
1201
|
|
|
*/ |
1202
|
|
|
function __promisify__(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>; |
1203
|
|
|
} |
1204
|
|
|
|
1205
|
|
|
/** |
1206
|
|
|
* Synchronously change file timestamps of the file referenced by the supplied path. |
1207
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1208
|
|
|
* @param atime The last access time. If a string is provided, it will be coerced to number. |
1209
|
|
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number. |
1210
|
|
|
*/ |
1211
|
|
|
export function utimesSync(path: PathLike, atime: string | number | Date, mtime: string | number | Date): void; |
1212
|
|
|
|
1213
|
|
|
/** |
1214
|
|
|
* Asynchronously change file timestamps of the file referenced by the supplied file descriptor. |
1215
|
|
|
* @param fd A file descriptor. |
1216
|
|
|
* @param atime The last access time. If a string is provided, it will be coerced to number. |
1217
|
|
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number. |
1218
|
|
|
*/ |
1219
|
|
|
export function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void; |
1220
|
|
|
|
1221
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1222
|
|
|
export namespace futimes { |
1223
|
|
|
/** |
1224
|
|
|
* Asynchronously change file timestamps of the file referenced by the supplied file descriptor. |
1225
|
|
|
* @param fd A file descriptor. |
1226
|
|
|
* @param atime The last access time. If a string is provided, it will be coerced to number. |
1227
|
|
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number. |
1228
|
|
|
*/ |
1229
|
|
|
function __promisify__(fd: number, atime: string | number | Date, mtime: string | number | Date): Promise<void>; |
1230
|
|
|
} |
1231
|
|
|
|
1232
|
|
|
/** |
1233
|
|
|
* Synchronously change file timestamps of the file referenced by the supplied file descriptor. |
1234
|
|
|
* @param fd A file descriptor. |
1235
|
|
|
* @param atime The last access time. If a string is provided, it will be coerced to number. |
1236
|
|
|
* @param mtime The last modified time. If a string is provided, it will be coerced to number. |
1237
|
|
|
*/ |
1238
|
|
|
export function futimesSync(fd: number, atime: string | number | Date, mtime: string | number | Date): void; |
1239
|
|
|
|
1240
|
|
|
/** |
1241
|
|
|
* Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device. |
1242
|
|
|
* @param fd A file descriptor. |
1243
|
|
|
*/ |
1244
|
|
|
export function fsync(fd: number, callback: NoParamCallback): void; |
1245
|
|
|
|
1246
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1247
|
|
|
export namespace fsync { |
1248
|
|
|
/** |
1249
|
|
|
* Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device. |
1250
|
|
|
* @param fd A file descriptor. |
1251
|
|
|
*/ |
1252
|
|
|
function __promisify__(fd: number): Promise<void>; |
1253
|
|
|
} |
1254
|
|
|
|
1255
|
|
|
/** |
1256
|
|
|
* Synchronous fsync(2) - synchronize a file's in-core state with the underlying storage device. |
1257
|
|
|
* @param fd A file descriptor. |
1258
|
|
|
*/ |
1259
|
|
|
export function fsyncSync(fd: number): void; |
1260
|
|
|
|
1261
|
|
|
/** |
1262
|
|
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. |
1263
|
|
|
* @param fd A file descriptor. |
1264
|
|
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`. |
1265
|
|
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`. |
1266
|
|
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
1267
|
|
|
*/ |
1268
|
|
|
export function write<TBuffer extends NodeJS.ArrayBufferView>( |
1269
|
|
|
fd: number, |
1270
|
|
|
buffer: TBuffer, |
1271
|
|
|
offset: number | undefined | null, |
1272
|
|
|
length: number | undefined | null, |
1273
|
|
|
position: number | undefined | null, |
1274
|
|
|
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, |
1275
|
|
|
): void; |
1276
|
|
|
|
1277
|
|
|
/** |
1278
|
|
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. |
1279
|
|
|
* @param fd A file descriptor. |
1280
|
|
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`. |
1281
|
|
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`. |
1282
|
|
|
*/ |
1283
|
|
|
export function write<TBuffer extends NodeJS.ArrayBufferView>( |
1284
|
|
|
fd: number, |
1285
|
|
|
buffer: TBuffer, |
1286
|
|
|
offset: number | undefined | null, |
1287
|
|
|
length: number | undefined | null, |
1288
|
|
|
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void, |
1289
|
|
|
): void; |
1290
|
|
|
|
1291
|
|
|
/** |
1292
|
|
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. |
1293
|
|
|
* @param fd A file descriptor. |
1294
|
|
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`. |
1295
|
|
|
*/ |
1296
|
|
|
export function write<TBuffer extends NodeJS.ArrayBufferView>( |
1297
|
|
|
fd: number, |
1298
|
|
|
buffer: TBuffer, |
1299
|
|
|
offset: number | undefined | null, |
1300
|
|
|
callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void |
1301
|
|
|
): void; |
1302
|
|
|
|
1303
|
|
|
/** |
1304
|
|
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. |
1305
|
|
|
* @param fd A file descriptor. |
1306
|
|
|
*/ |
1307
|
|
|
export function write<TBuffer extends NodeJS.ArrayBufferView>(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void; |
1308
|
|
|
|
1309
|
|
|
/** |
1310
|
|
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor. |
1311
|
|
|
* @param fd A file descriptor. |
1312
|
|
|
* @param string A string to write. |
1313
|
|
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
1314
|
|
|
* @param encoding The expected string encoding. |
1315
|
|
|
*/ |
1316
|
|
|
export function write( |
1317
|
|
|
fd: number, |
1318
|
|
|
string: string, |
1319
|
|
|
position: number | undefined | null, |
1320
|
|
|
encoding: BufferEncoding | undefined | null, |
1321
|
|
|
callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void, |
1322
|
|
|
): void; |
1323
|
|
|
|
1324
|
|
|
/** |
1325
|
|
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor. |
1326
|
|
|
* @param fd A file descriptor. |
1327
|
|
|
* @param string A string to write. |
1328
|
|
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
1329
|
|
|
*/ |
1330
|
|
|
export function write(fd: number, string: string, position: number | undefined | null, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void; |
1331
|
|
|
|
1332
|
|
|
/** |
1333
|
|
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor. |
1334
|
|
|
* @param fd A file descriptor. |
1335
|
|
|
* @param string A string to write. |
1336
|
|
|
*/ |
1337
|
|
|
export function write(fd: number, string: string, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void; |
1338
|
|
|
|
1339
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1340
|
|
|
export namespace write { |
1341
|
|
|
/** |
1342
|
|
|
* Asynchronously writes `buffer` to the file referenced by the supplied file descriptor. |
1343
|
|
|
* @param fd A file descriptor. |
1344
|
|
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`. |
1345
|
|
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`. |
1346
|
|
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
1347
|
|
|
*/ |
1348
|
|
|
function __promisify__<TBuffer extends NodeJS.ArrayBufferView>( |
1349
|
|
|
fd: number, |
1350
|
|
|
buffer?: TBuffer, |
1351
|
|
|
offset?: number, |
1352
|
|
|
length?: number, |
1353
|
|
|
position?: number | null, |
1354
|
|
|
): Promise<{ bytesWritten: number, buffer: TBuffer }>; |
1355
|
|
|
|
1356
|
|
|
/** |
1357
|
|
|
* Asynchronously writes `string` to the file referenced by the supplied file descriptor. |
1358
|
|
|
* @param fd A file descriptor. |
1359
|
|
|
* @param string A string to write. |
1360
|
|
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
1361
|
|
|
* @param encoding The expected string encoding. |
1362
|
|
|
*/ |
1363
|
|
|
function __promisify__(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): Promise<{ bytesWritten: number, buffer: string }>; |
1364
|
|
|
} |
1365
|
|
|
|
1366
|
|
|
/** |
1367
|
|
|
* Synchronously writes `buffer` to the file referenced by the supplied file descriptor, returning the number of bytes written. |
1368
|
|
|
* @param fd A file descriptor. |
1369
|
|
|
* @param offset The part of the buffer to be written. If not supplied, defaults to `0`. |
1370
|
|
|
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`. |
1371
|
|
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
1372
|
|
|
*/ |
1373
|
|
|
export function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number; |
1374
|
|
|
|
1375
|
|
|
/** |
1376
|
|
|
* Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written. |
1377
|
|
|
* @param fd A file descriptor. |
1378
|
|
|
* @param string A string to write. |
1379
|
|
|
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position. |
1380
|
|
|
* @param encoding The expected string encoding. |
1381
|
|
|
*/ |
1382
|
|
|
export function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number; |
1383
|
|
|
|
1384
|
|
|
/** |
1385
|
|
|
* Asynchronously reads data from the file referenced by the supplied file descriptor. |
1386
|
|
|
* @param fd A file descriptor. |
1387
|
|
|
* @param buffer The buffer that the data will be written to. |
1388
|
|
|
* @param offset The offset in the buffer at which to start writing. |
1389
|
|
|
* @param length The number of bytes to read. |
1390
|
|
|
* @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. |
1391
|
|
|
*/ |
1392
|
|
|
export function read<TBuffer extends NodeJS.ArrayBufferView>( |
1393
|
|
|
fd: number, |
1394
|
|
|
buffer: TBuffer, |
1395
|
|
|
offset: number, |
1396
|
|
|
length: number, |
1397
|
|
|
position: number | null, |
1398
|
|
|
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void, |
1399
|
|
|
): void; |
1400
|
|
|
|
1401
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1402
|
|
|
export namespace read { |
1403
|
|
|
/** |
1404
|
|
|
* @param fd A file descriptor. |
1405
|
|
|
* @param buffer The buffer that the data will be written to. |
1406
|
|
|
* @param offset The offset in the buffer at which to start writing. |
1407
|
|
|
* @param length The number of bytes to read. |
1408
|
|
|
* @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. |
1409
|
|
|
*/ |
1410
|
|
|
function __promisify__<TBuffer extends NodeJS.ArrayBufferView>( |
1411
|
|
|
fd: number, |
1412
|
|
|
buffer: TBuffer, |
1413
|
|
|
offset: number, |
1414
|
|
|
length: number, |
1415
|
|
|
position: number | null |
1416
|
|
|
): Promise<{ bytesRead: number, buffer: TBuffer }>; |
1417
|
|
|
} |
1418
|
|
|
|
1419
|
|
|
export interface ReadSyncOptions { |
1420
|
|
|
/** |
1421
|
|
|
* @default 0 |
1422
|
|
|
*/ |
1423
|
|
|
offset?: number; |
1424
|
|
|
/** |
1425
|
|
|
* @default `length of buffer` |
1426
|
|
|
*/ |
1427
|
|
|
length?: number; |
1428
|
|
|
/** |
1429
|
|
|
* @default null |
1430
|
|
|
*/ |
1431
|
|
|
position?: number | null; |
1432
|
|
|
} |
1433
|
|
|
|
1434
|
|
|
/** |
1435
|
|
|
* Synchronously reads data from the file referenced by the supplied file descriptor, returning the number of bytes read. |
1436
|
|
|
* @param fd A file descriptor. |
1437
|
|
|
* @param buffer The buffer that the data will be written to. |
1438
|
|
|
* @param offset The offset in the buffer at which to start writing. |
1439
|
|
|
* @param length The number of bytes to read. |
1440
|
|
|
* @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. |
1441
|
|
|
*/ |
1442
|
|
|
export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number; |
1443
|
|
|
|
1444
|
|
|
/** |
1445
|
|
|
* Similar to the above `fs.readSync` function, this version takes an optional `options` object. |
1446
|
|
|
* If no `options` object is specified, it will default with the above values. |
1447
|
|
|
*/ |
1448
|
|
|
export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number; |
1449
|
|
|
|
1450
|
|
|
/** |
1451
|
|
|
* Asynchronously reads the entire contents of a file. |
1452
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1453
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1454
|
|
|
* @param options An object that may contain an optional flag. |
1455
|
|
|
* If a flag is not provided, it defaults to `'r'`. |
1456
|
|
|
*/ |
1457
|
|
|
export function readFile(path: PathLike | number, options: { encoding?: null; flag?: string; } | undefined | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; |
1458
|
|
|
|
1459
|
|
|
/** |
1460
|
|
|
* Asynchronously reads the entire contents of a file. |
1461
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1462
|
|
|
* URL support is _experimental_. |
1463
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1464
|
|
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. |
1465
|
|
|
* If a flag is not provided, it defaults to `'r'`. |
1466
|
|
|
*/ |
1467
|
|
|
export function readFile(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | string, callback: (err: NodeJS.ErrnoException | null, data: string) => void): void; |
1468
|
|
|
|
1469
|
|
|
/** |
1470
|
|
|
* Asynchronously reads the entire contents of a file. |
1471
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1472
|
|
|
* URL support is _experimental_. |
1473
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1474
|
|
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. |
1475
|
|
|
* If a flag is not provided, it defaults to `'r'`. |
1476
|
|
|
*/ |
1477
|
|
|
export function readFile( |
1478
|
|
|
path: PathLike | number, |
1479
|
|
|
options: BaseEncodingOptions & { flag?: string; } | string | undefined | null, |
1480
|
|
|
callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void, |
1481
|
|
|
): void; |
1482
|
|
|
|
1483
|
|
|
/** |
1484
|
|
|
* Asynchronously reads the entire contents of a file. |
1485
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1486
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1487
|
|
|
*/ |
1488
|
|
|
export function readFile(path: PathLike | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; |
1489
|
|
|
|
1490
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1491
|
|
|
export namespace readFile { |
1492
|
|
|
/** |
1493
|
|
|
* Asynchronously reads the entire contents of a file. |
1494
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1495
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1496
|
|
|
* @param options An object that may contain an optional flag. |
1497
|
|
|
* If a flag is not provided, it defaults to `'r'`. |
1498
|
|
|
*/ |
1499
|
|
|
function __promisify__(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Promise<Buffer>; |
1500
|
|
|
|
1501
|
|
|
/** |
1502
|
|
|
* Asynchronously reads the entire contents of a file. |
1503
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1504
|
|
|
* URL support is _experimental_. |
1505
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1506
|
|
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. |
1507
|
|
|
* If a flag is not provided, it defaults to `'r'`. |
1508
|
|
|
*/ |
1509
|
|
|
function __promisify__(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | string): Promise<string>; |
1510
|
|
|
|
1511
|
|
|
/** |
1512
|
|
|
* Asynchronously reads the entire contents of a file. |
1513
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1514
|
|
|
* URL support is _experimental_. |
1515
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1516
|
|
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. |
1517
|
|
|
* If a flag is not provided, it defaults to `'r'`. |
1518
|
|
|
*/ |
1519
|
|
|
function __promisify__(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string; } | string | null): Promise<string | Buffer>; |
1520
|
|
|
} |
1521
|
|
|
|
1522
|
|
|
/** |
1523
|
|
|
* Synchronously reads the entire contents of a file. |
1524
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1525
|
|
|
* URL support is _experimental_. |
1526
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1527
|
|
|
* @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`. |
1528
|
|
|
*/ |
1529
|
|
|
export function readFileSync(path: PathLike | number, options?: { encoding?: null; flag?: string; } | null): Buffer; |
1530
|
|
|
|
1531
|
|
|
/** |
1532
|
|
|
* Synchronously reads the entire contents of a file. |
1533
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1534
|
|
|
* URL support is _experimental_. |
1535
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1536
|
|
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. |
1537
|
|
|
* If a flag is not provided, it defaults to `'r'`. |
1538
|
|
|
*/ |
1539
|
|
|
export function readFileSync(path: PathLike | number, options: { encoding: BufferEncoding; flag?: string; } | BufferEncoding): string; |
1540
|
|
|
|
1541
|
|
|
/** |
1542
|
|
|
* Synchronously reads the entire contents of a file. |
1543
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1544
|
|
|
* URL support is _experimental_. |
1545
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1546
|
|
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag. |
1547
|
|
|
* If a flag is not provided, it defaults to `'r'`. |
1548
|
|
|
*/ |
1549
|
|
|
export function readFileSync(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string; } | BufferEncoding | null): string | Buffer; |
1550
|
|
|
|
1551
|
|
|
export type WriteFileOptions = BaseEncodingOptions & { mode?: Mode; flag?: string; } | string | null; |
1552
|
|
|
|
1553
|
|
|
/** |
1554
|
|
|
* Asynchronously writes data to a file, replacing the file if it already exists. |
1555
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1556
|
|
|
* URL support is _experimental_. |
1557
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1558
|
|
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. |
1559
|
|
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. |
1560
|
|
|
* If `encoding` is not supplied, the default of `'utf8'` is used. |
1561
|
|
|
* If `mode` is not supplied, the default of `0o666` is used. |
1562
|
|
|
* If `mode` is a string, it is parsed as an octal integer. |
1563
|
|
|
* If `flag` is not supplied, the default of `'w'` is used. |
1564
|
|
|
*/ |
1565
|
|
|
export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void; |
1566
|
|
|
|
1567
|
|
|
/** |
1568
|
|
|
* Asynchronously writes data to a file, replacing the file if it already exists. |
1569
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1570
|
|
|
* URL support is _experimental_. |
1571
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1572
|
|
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. |
1573
|
|
|
*/ |
1574
|
|
|
export function writeFile(path: PathLike | number, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void; |
1575
|
|
|
|
1576
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1577
|
|
|
export namespace writeFile { |
1578
|
|
|
/** |
1579
|
|
|
* Asynchronously writes data to a file, replacing the file if it already exists. |
1580
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1581
|
|
|
* URL support is _experimental_. |
1582
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1583
|
|
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. |
1584
|
|
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. |
1585
|
|
|
* If `encoding` is not supplied, the default of `'utf8'` is used. |
1586
|
|
|
* If `mode` is not supplied, the default of `0o666` is used. |
1587
|
|
|
* If `mode` is a string, it is parsed as an octal integer. |
1588
|
|
|
* If `flag` is not supplied, the default of `'w'` is used. |
1589
|
|
|
*/ |
1590
|
|
|
function __promisify__(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise<void>; |
1591
|
|
|
} |
1592
|
|
|
|
1593
|
|
|
/** |
1594
|
|
|
* Synchronously writes data to a file, replacing the file if it already exists. |
1595
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1596
|
|
|
* URL support is _experimental_. |
1597
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1598
|
|
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. |
1599
|
|
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. |
1600
|
|
|
* If `encoding` is not supplied, the default of `'utf8'` is used. |
1601
|
|
|
* If `mode` is not supplied, the default of `0o666` is used. |
1602
|
|
|
* If `mode` is a string, it is parsed as an octal integer. |
1603
|
|
|
* If `flag` is not supplied, the default of `'w'` is used. |
1604
|
|
|
*/ |
1605
|
|
|
export function writeFileSync(path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void; |
1606
|
|
|
|
1607
|
|
|
/** |
1608
|
|
|
* Asynchronously append data to a file, creating the file if it does not exist. |
1609
|
|
|
* @param file A path to a file. If a URL is provided, it must use the `file:` protocol. |
1610
|
|
|
* URL support is _experimental_. |
1611
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1612
|
|
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. |
1613
|
|
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. |
1614
|
|
|
* If `encoding` is not supplied, the default of `'utf8'` is used. |
1615
|
|
|
* If `mode` is not supplied, the default of `0o666` is used. |
1616
|
|
|
* If `mode` is a string, it is parsed as an octal integer. |
1617
|
|
|
* If `flag` is not supplied, the default of `'a'` is used. |
1618
|
|
|
*/ |
1619
|
|
|
export function appendFile(file: PathLike | number, data: string | Uint8Array, options: WriteFileOptions, callback: NoParamCallback): void; |
1620
|
|
|
|
1621
|
|
|
/** |
1622
|
|
|
* Asynchronously append data to a file, creating the file if it does not exist. |
1623
|
|
|
* @param file A path to a file. If a URL is provided, it must use the `file:` protocol. |
1624
|
|
|
* URL support is _experimental_. |
1625
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1626
|
|
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. |
1627
|
|
|
*/ |
1628
|
|
|
export function appendFile(file: PathLike | number, data: string | Uint8Array, callback: NoParamCallback): void; |
1629
|
|
|
|
1630
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1631
|
|
|
export namespace appendFile { |
1632
|
|
|
/** |
1633
|
|
|
* Asynchronously append data to a file, creating the file if it does not exist. |
1634
|
|
|
* @param file A path to a file. If a URL is provided, it must use the `file:` protocol. |
1635
|
|
|
* URL support is _experimental_. |
1636
|
|
|
* If a file descriptor is provided, the underlying file will _not_ be closed automatically. |
1637
|
|
|
* @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. |
1638
|
|
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. |
1639
|
|
|
* If `encoding` is not supplied, the default of `'utf8'` is used. |
1640
|
|
|
* If `mode` is not supplied, the default of `0o666` is used. |
1641
|
|
|
* If `mode` is a string, it is parsed as an octal integer. |
1642
|
|
|
* If `flag` is not supplied, the default of `'a'` is used. |
1643
|
|
|
*/ |
1644
|
|
|
function __promisify__(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): Promise<void>; |
1645
|
|
|
} |
1646
|
|
|
|
1647
|
|
|
/** |
1648
|
|
|
* Synchronously append data to a file, creating the file if it does not exist. |
1649
|
|
|
* @param file 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 data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string. |
1653
|
|
|
* @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. |
1654
|
|
|
* If `encoding` is not supplied, the default of `'utf8'` is used. |
1655
|
|
|
* If `mode` is not supplied, the default of `0o666` is used. |
1656
|
|
|
* If `mode` is a string, it is parsed as an octal integer. |
1657
|
|
|
* If `flag` is not supplied, the default of `'a'` is used. |
1658
|
|
|
*/ |
1659
|
|
|
export function appendFileSync(file: PathLike | number, data: string | Uint8Array, options?: WriteFileOptions): void; |
1660
|
|
|
|
1661
|
|
|
/** |
1662
|
|
|
* Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed. |
1663
|
|
|
*/ |
1664
|
|
|
export function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number; } | undefined, listener: (curr: Stats, prev: Stats) => void): void; |
1665
|
|
|
|
1666
|
|
|
/** |
1667
|
|
|
* Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed. |
1668
|
|
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1669
|
|
|
* URL support is _experimental_. |
1670
|
|
|
*/ |
1671
|
|
|
export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void; |
1672
|
|
|
|
1673
|
|
|
/** |
1674
|
|
|
* Stop watching for changes on `filename`. |
1675
|
|
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1676
|
|
|
* URL support is _experimental_. |
1677
|
|
|
*/ |
1678
|
|
|
export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void; |
1679
|
|
|
|
1680
|
|
|
/** |
1681
|
|
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. |
1682
|
|
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1683
|
|
|
* URL support is _experimental_. |
1684
|
|
|
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. |
1685
|
|
|
* If `encoding` is not supplied, the default of `'utf8'` is used. |
1686
|
|
|
* If `persistent` is not supplied, the default of `true` is used. |
1687
|
|
|
* If `recursive` is not supplied, the default of `false` is used. |
1688
|
|
|
*/ |
1689
|
|
|
export function watch( |
1690
|
|
|
filename: PathLike, |
1691
|
|
|
options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | BufferEncoding | undefined | null, |
1692
|
|
|
listener?: (event: string, filename: string) => void, |
1693
|
|
|
): FSWatcher; |
1694
|
|
|
|
1695
|
|
|
/** |
1696
|
|
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. |
1697
|
|
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1698
|
|
|
* URL support is _experimental_. |
1699
|
|
|
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. |
1700
|
|
|
* If `encoding` is not supplied, the default of `'utf8'` is used. |
1701
|
|
|
* If `persistent` is not supplied, the default of `true` is used. |
1702
|
|
|
* If `recursive` is not supplied, the default of `false` is used. |
1703
|
|
|
*/ |
1704
|
|
|
export function watch(filename: PathLike, options: { encoding: "buffer", persistent?: boolean, recursive?: boolean } | "buffer", listener?: (event: string, filename: Buffer) => void): FSWatcher; |
1705
|
|
|
|
1706
|
|
|
/** |
1707
|
|
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. |
1708
|
|
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1709
|
|
|
* URL support is _experimental_. |
1710
|
|
|
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options. |
1711
|
|
|
* If `encoding` is not supplied, the default of `'utf8'` is used. |
1712
|
|
|
* If `persistent` is not supplied, the default of `true` is used. |
1713
|
|
|
* If `recursive` is not supplied, the default of `false` is used. |
1714
|
|
|
*/ |
1715
|
|
|
export function watch( |
1716
|
|
|
filename: PathLike, |
1717
|
|
|
options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | string | null, |
1718
|
|
|
listener?: (event: string, filename: string | Buffer) => void, |
1719
|
|
|
): FSWatcher; |
1720
|
|
|
|
1721
|
|
|
/** |
1722
|
|
|
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`. |
1723
|
|
|
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1724
|
|
|
* URL support is _experimental_. |
1725
|
|
|
*/ |
1726
|
|
|
export function watch(filename: PathLike, listener?: (event: string, filename: string) => any): FSWatcher; |
1727
|
|
|
|
1728
|
|
|
/** |
1729
|
|
|
* Asynchronously tests whether or not the given path exists by checking with the file system. |
1730
|
|
|
* @deprecated |
1731
|
|
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1732
|
|
|
* URL support is _experimental_. |
1733
|
|
|
*/ |
1734
|
|
|
export function exists(path: PathLike, callback: (exists: boolean) => void): void; |
1735
|
|
|
|
1736
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1737
|
|
|
export namespace exists { |
1738
|
|
|
/** |
1739
|
|
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1740
|
|
|
* URL support is _experimental_. |
1741
|
|
|
*/ |
1742
|
|
|
function __promisify__(path: PathLike): Promise<boolean>; |
1743
|
|
|
} |
1744
|
|
|
|
1745
|
|
|
/** |
1746
|
|
|
* Synchronously tests whether or not the given path exists by checking with the file system. |
1747
|
|
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1748
|
|
|
* URL support is _experimental_. |
1749
|
|
|
*/ |
1750
|
|
|
export function existsSync(path: PathLike): boolean; |
1751
|
|
|
|
1752
|
|
|
export namespace constants { |
1753
|
|
|
// File Access Constants |
1754
|
|
|
|
1755
|
|
|
/** Constant for fs.access(). File is visible to the calling process. */ |
1756
|
|
|
const F_OK: number; |
1757
|
|
|
|
1758
|
|
|
/** Constant for fs.access(). File can be read by the calling process. */ |
1759
|
|
|
const R_OK: number; |
1760
|
|
|
|
1761
|
|
|
/** Constant for fs.access(). File can be written by the calling process. */ |
1762
|
|
|
const W_OK: number; |
1763
|
|
|
|
1764
|
|
|
/** Constant for fs.access(). File can be executed by the calling process. */ |
1765
|
|
|
const X_OK: number; |
1766
|
|
|
|
1767
|
|
|
// File Copy Constants |
1768
|
|
|
|
1769
|
|
|
/** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */ |
1770
|
|
|
const COPYFILE_EXCL: number; |
1771
|
|
|
|
1772
|
|
|
/** |
1773
|
|
|
* Constant for fs.copyFile. copy operation will attempt to create a copy-on-write reflink. |
1774
|
|
|
* If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used. |
1775
|
|
|
*/ |
1776
|
|
|
const COPYFILE_FICLONE: number; |
1777
|
|
|
|
1778
|
|
|
/** |
1779
|
|
|
* Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink. |
1780
|
|
|
* If the underlying platform does not support copy-on-write, then the operation will fail with an error. |
1781
|
|
|
*/ |
1782
|
|
|
const COPYFILE_FICLONE_FORCE: number; |
1783
|
|
|
|
1784
|
|
|
// File Open Constants |
1785
|
|
|
|
1786
|
|
|
/** Constant for fs.open(). Flag indicating to open a file for read-only access. */ |
1787
|
|
|
const O_RDONLY: number; |
1788
|
|
|
|
1789
|
|
|
/** Constant for fs.open(). Flag indicating to open a file for write-only access. */ |
1790
|
|
|
const O_WRONLY: number; |
1791
|
|
|
|
1792
|
|
|
/** Constant for fs.open(). Flag indicating to open a file for read-write access. */ |
1793
|
|
|
const O_RDWR: number; |
1794
|
|
|
|
1795
|
|
|
/** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */ |
1796
|
|
|
const O_CREAT: number; |
1797
|
|
|
|
1798
|
|
|
/** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */ |
1799
|
|
|
const O_EXCL: number; |
1800
|
|
|
|
1801
|
|
|
/** |
1802
|
|
|
* Constant for fs.open(). Flag indicating that if path identifies a terminal device, |
1803
|
|
|
* opening the path shall not cause that terminal to become the controlling terminal for the process |
1804
|
|
|
* (if the process does not already have one). |
1805
|
|
|
*/ |
1806
|
|
|
const O_NOCTTY: number; |
1807
|
|
|
|
1808
|
|
|
/** 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. */ |
1809
|
|
|
const O_TRUNC: number; |
1810
|
|
|
|
1811
|
|
|
/** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */ |
1812
|
|
|
const O_APPEND: number; |
1813
|
|
|
|
1814
|
|
|
/** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */ |
1815
|
|
|
const O_DIRECTORY: number; |
1816
|
|
|
|
1817
|
|
|
/** |
1818
|
|
|
* constant for fs.open(). |
1819
|
|
|
* Flag indicating reading accesses to the file system will no longer result in |
1820
|
|
|
* an update to the atime information associated with the file. |
1821
|
|
|
* This flag is available on Linux operating systems only. |
1822
|
|
|
*/ |
1823
|
|
|
const O_NOATIME: number; |
1824
|
|
|
|
1825
|
|
|
/** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */ |
1826
|
|
|
const O_NOFOLLOW: number; |
1827
|
|
|
|
1828
|
|
|
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */ |
1829
|
|
|
const O_SYNC: number; |
1830
|
|
|
|
1831
|
|
|
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */ |
1832
|
|
|
const O_DSYNC: number; |
1833
|
|
|
|
1834
|
|
|
/** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */ |
1835
|
|
|
const O_SYMLINK: number; |
1836
|
|
|
|
1837
|
|
|
/** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */ |
1838
|
|
|
const O_DIRECT: number; |
1839
|
|
|
|
1840
|
|
|
/** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */ |
1841
|
|
|
const O_NONBLOCK: number; |
1842
|
|
|
|
1843
|
|
|
// File Type Constants |
1844
|
|
|
|
1845
|
|
|
/** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */ |
1846
|
|
|
const S_IFMT: number; |
1847
|
|
|
|
1848
|
|
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */ |
1849
|
|
|
const S_IFREG: number; |
1850
|
|
|
|
1851
|
|
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */ |
1852
|
|
|
const S_IFDIR: number; |
1853
|
|
|
|
1854
|
|
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */ |
1855
|
|
|
const S_IFCHR: number; |
1856
|
|
|
|
1857
|
|
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */ |
1858
|
|
|
const S_IFBLK: number; |
1859
|
|
|
|
1860
|
|
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */ |
1861
|
|
|
const S_IFIFO: number; |
1862
|
|
|
|
1863
|
|
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */ |
1864
|
|
|
const S_IFLNK: number; |
1865
|
|
|
|
1866
|
|
|
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */ |
1867
|
|
|
const S_IFSOCK: number; |
1868
|
|
|
|
1869
|
|
|
// File Mode Constants |
1870
|
|
|
|
1871
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */ |
1872
|
|
|
const S_IRWXU: number; |
1873
|
|
|
|
1874
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */ |
1875
|
|
|
const S_IRUSR: number; |
1876
|
|
|
|
1877
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */ |
1878
|
|
|
const S_IWUSR: number; |
1879
|
|
|
|
1880
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */ |
1881
|
|
|
const S_IXUSR: number; |
1882
|
|
|
|
1883
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */ |
1884
|
|
|
const S_IRWXG: number; |
1885
|
|
|
|
1886
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */ |
1887
|
|
|
const S_IRGRP: number; |
1888
|
|
|
|
1889
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */ |
1890
|
|
|
const S_IWGRP: number; |
1891
|
|
|
|
1892
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */ |
1893
|
|
|
const S_IXGRP: number; |
1894
|
|
|
|
1895
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */ |
1896
|
|
|
const S_IRWXO: number; |
1897
|
|
|
|
1898
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */ |
1899
|
|
|
const S_IROTH: number; |
1900
|
|
|
|
1901
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */ |
1902
|
|
|
const S_IWOTH: number; |
1903
|
|
|
|
1904
|
|
|
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */ |
1905
|
|
|
const S_IXOTH: number; |
1906
|
|
|
|
1907
|
|
|
/** |
1908
|
|
|
* When set, a memory file mapping is used to access the file. This flag |
1909
|
|
|
* is available on Windows operating systems only. On other operating systems, |
1910
|
|
|
* this flag is ignored. |
1911
|
|
|
*/ |
1912
|
|
|
const UV_FS_O_FILEMAP: number; |
1913
|
|
|
} |
1914
|
|
|
|
1915
|
|
|
/** |
1916
|
|
|
* Asynchronously tests a user's permissions for the file specified by path. |
1917
|
|
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1918
|
|
|
* URL support is _experimental_. |
1919
|
|
|
*/ |
1920
|
|
|
export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void; |
1921
|
|
|
|
1922
|
|
|
/** |
1923
|
|
|
* Asynchronously tests a user's permissions for the file specified by path. |
1924
|
|
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1925
|
|
|
* URL support is _experimental_. |
1926
|
|
|
*/ |
1927
|
|
|
export function access(path: PathLike, callback: NoParamCallback): void; |
1928
|
|
|
|
1929
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1930
|
|
|
export namespace access { |
1931
|
|
|
/** |
1932
|
|
|
* Asynchronously tests a user's permissions for the file specified by path. |
1933
|
|
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1934
|
|
|
* URL support is _experimental_. |
1935
|
|
|
*/ |
1936
|
|
|
function __promisify__(path: PathLike, mode?: number): Promise<void>; |
1937
|
|
|
} |
1938
|
|
|
|
1939
|
|
|
/** |
1940
|
|
|
* Synchronously tests a user's permissions for the file specified by path. |
1941
|
|
|
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol. |
1942
|
|
|
* URL support is _experimental_. |
1943
|
|
|
*/ |
1944
|
|
|
export function accessSync(path: PathLike, mode?: number): void; |
1945
|
|
|
|
1946
|
|
|
/** |
1947
|
|
|
* Returns a new `ReadStream` object. |
1948
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1949
|
|
|
* URL support is _experimental_. |
1950
|
|
|
*/ |
1951
|
|
|
export function createReadStream(path: PathLike, options?: string | { |
1952
|
|
|
flags?: string; |
1953
|
|
|
encoding?: BufferEncoding; |
1954
|
|
|
fd?: number; |
1955
|
|
|
mode?: number; |
1956
|
|
|
autoClose?: boolean; |
1957
|
|
|
/** |
1958
|
|
|
* @default false |
1959
|
|
|
*/ |
1960
|
|
|
emitClose?: boolean; |
1961
|
|
|
start?: number; |
1962
|
|
|
end?: number; |
1963
|
|
|
highWaterMark?: number; |
1964
|
|
|
}): ReadStream; |
1965
|
|
|
|
1966
|
|
|
/** |
1967
|
|
|
* Returns a new `WriteStream` object. |
1968
|
|
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol. |
1969
|
|
|
* URL support is _experimental_. |
1970
|
|
|
*/ |
1971
|
|
|
export function createWriteStream(path: PathLike, options?: string | { |
1972
|
|
|
flags?: string; |
1973
|
|
|
encoding?: BufferEncoding; |
1974
|
|
|
fd?: number; |
1975
|
|
|
mode?: number; |
1976
|
|
|
autoClose?: boolean; |
1977
|
|
|
emitClose?: boolean; |
1978
|
|
|
start?: number; |
1979
|
|
|
highWaterMark?: number; |
1980
|
|
|
}): WriteStream; |
1981
|
|
|
|
1982
|
|
|
/** |
1983
|
|
|
* Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device. |
1984
|
|
|
* @param fd A file descriptor. |
1985
|
|
|
*/ |
1986
|
|
|
export function fdatasync(fd: number, callback: NoParamCallback): void; |
1987
|
|
|
|
1988
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
1989
|
|
|
export namespace fdatasync { |
1990
|
|
|
/** |
1991
|
|
|
* Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device. |
1992
|
|
|
* @param fd A file descriptor. |
1993
|
|
|
*/ |
1994
|
|
|
function __promisify__(fd: number): Promise<void>; |
1995
|
|
|
} |
1996
|
|
|
|
1997
|
|
|
/** |
1998
|
|
|
* Synchronous fdatasync(2) - synchronize a file's in-core state with storage device. |
1999
|
|
|
* @param fd A file descriptor. |
2000
|
|
|
*/ |
2001
|
|
|
export function fdatasyncSync(fd: number): void; |
2002
|
|
|
|
2003
|
|
|
/** |
2004
|
|
|
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists. |
2005
|
|
|
* No arguments other than a possible exception are given to the callback function. |
2006
|
|
|
* Node.js makes no guarantees about the atomicity of the copy operation. |
2007
|
|
|
* If an error occurs after the destination file has been opened for writing, Node.js will attempt |
2008
|
|
|
* to remove the destination. |
2009
|
|
|
* @param src A path to the source file. |
2010
|
|
|
* @param dest A path to the destination file. |
2011
|
|
|
*/ |
2012
|
|
|
export function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void; |
2013
|
|
|
/** |
2014
|
|
|
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists. |
2015
|
|
|
* No arguments other than a possible exception are given to the callback function. |
2016
|
|
|
* Node.js makes no guarantees about the atomicity of the copy operation. |
2017
|
|
|
* If an error occurs after the destination file has been opened for writing, Node.js will attempt |
2018
|
|
|
* to remove the destination. |
2019
|
|
|
* @param src A path to the source file. |
2020
|
|
|
* @param dest A path to the destination file. |
2021
|
|
|
* @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. |
2022
|
|
|
*/ |
2023
|
|
|
export function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoParamCallback): void; |
2024
|
|
|
|
2025
|
|
|
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime. |
2026
|
|
|
export namespace copyFile { |
2027
|
|
|
/** |
2028
|
|
|
* Asynchronously copies src to dest. By default, dest is overwritten if it already exists. |
2029
|
|
|
* No arguments other than a possible exception are given to the callback function. |
2030
|
|
|
* Node.js makes no guarantees about the atomicity of the copy operation. |
2031
|
|
|
* If an error occurs after the destination file has been opened for writing, Node.js will attempt |
2032
|
|
|
* to remove the destination. |
2033
|
|
|
* @param src A path to the source file. |
2034
|
|
|
* @param dest A path to the destination file. |
2035
|
|
|
* @param flags An optional integer that specifies the behavior of the copy operation. |
2036
|
|
|
* The only supported flag is fs.constants.COPYFILE_EXCL, |
2037
|
|
|
* which causes the copy operation to fail if dest already exists. |
2038
|
|
|
*/ |
2039
|
|
|
function __promisify__(src: PathLike, dst: PathLike, flags?: number): Promise<void>; |
2040
|
|
|
} |
2041
|
|
|
|
2042
|
|
|
/** |
2043
|
|
|
* Synchronously copies src to dest. By default, dest is overwritten if it already exists. |
2044
|
|
|
* Node.js makes no guarantees about the atomicity of the copy operation. |
2045
|
|
|
* If an error occurs after the destination file has been opened for writing, Node.js will attempt |
2046
|
|
|
* to remove the destination. |
2047
|
|
|
* @param src A path to the source file. |
2048
|
|
|
* @param dest A path to the destination file. |
2049
|
|
|
* @param flags An optional integer that specifies the behavior of the copy operation. |
2050
|
|
|
* The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists. |
2051
|
|
|
*/ |
2052
|
|
|
export function copyFileSync(src: PathLike, dest: PathLike, flags?: number): void; |
2053
|
|
|
|
2054
|
|
|
/** |
2055
|
|
|
* Write an array of ArrayBufferViews to the file specified by fd using writev(). |
2056
|
|
|
* position is the offset from the beginning of the file where this data should be written. |
2057
|
|
|
* It is unsafe to use fs.writev() multiple times on the same file without waiting for the callback. For this scenario, use fs.createWriteStream(). |
2058
|
|
|
* On Linux, positional writes don't work when the file is opened in append mode. |
2059
|
|
|
* The kernel ignores the position argument and always appends the data to the end of the file. |
2060
|
|
|
*/ |
2061
|
|
|
export function writev( |
2062
|
|
|
fd: number, |
2063
|
|
|
buffers: NodeJS.ArrayBufferView[], |
2064
|
|
|
cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void |
2065
|
|
|
): void; |
2066
|
|
|
export function writev( |
2067
|
|
|
fd: number, |
2068
|
|
|
buffers: NodeJS.ArrayBufferView[], |
2069
|
|
|
position: number, |
2070
|
|
|
cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void |
2071
|
|
|
): void; |
2072
|
|
|
|
2073
|
|
|
export interface WriteVResult { |
2074
|
|
|
bytesWritten: number; |
2075
|
|
|
buffers: NodeJS.ArrayBufferView[]; |
2076
|
|
|
} |
2077
|
|
|
|
2078
|
|
|
export namespace writev { |
2079
|
|
|
function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>; |
2080
|
|
|
} |
2081
|
|
|
|
2082
|
|
|
/** |
2083
|
|
|
* See `writev`. |
2084
|
|
|
*/ |
2085
|
|
|
export function writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number; |
2086
|
|
|
|
2087
|
|
|
export function readv( |
2088
|
|
|
fd: number, |
2089
|
|
|
buffers: NodeJS.ArrayBufferView[], |
2090
|
|
|
cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void |
2091
|
|
|
): void; |
2092
|
|
|
export function readv( |
2093
|
|
|
fd: number, |
2094
|
|
|
buffers: NodeJS.ArrayBufferView[], |
2095
|
|
|
position: number, |
2096
|
|
|
cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void |
2097
|
|
|
): void; |
2098
|
|
|
|
2099
|
|
|
export interface ReadVResult { |
2100
|
|
|
bytesRead: number; |
2101
|
|
|
buffers: NodeJS.ArrayBufferView[]; |
2102
|
|
|
} |
2103
|
|
|
|
2104
|
|
|
export namespace readv { |
2105
|
|
|
function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise<ReadVResult>; |
2106
|
|
|
} |
2107
|
|
|
|
2108
|
|
|
/** |
2109
|
|
|
* See `readv`. |
2110
|
|
|
*/ |
2111
|
|
|
export function readvSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number; |
2112
|
|
|
|
2113
|
|
|
export interface OpenDirOptions { |
2114
|
|
|
encoding?: BufferEncoding; |
2115
|
|
|
/** |
2116
|
|
|
* Number of directory entries that are buffered |
2117
|
|
|
* internally when reading from the directory. Higher values lead to better |
2118
|
|
|
* performance but higher memory usage. |
2119
|
|
|
* @default 32 |
2120
|
|
|
*/ |
2121
|
|
|
bufferSize?: number; |
2122
|
|
|
} |
2123
|
|
|
|
2124
|
|
|
export function opendirSync(path: string, options?: OpenDirOptions): Dir; |
2125
|
|
|
|
2126
|
|
|
export function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void; |
2127
|
|
|
export function opendir(path: string, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void; |
2128
|
|
|
|
2129
|
|
|
export namespace opendir { |
2130
|
|
|
function __promisify__(path: string, options?: OpenDirOptions): Promise<Dir>; |
2131
|
|
|
} |
2132
|
|
|
} |
2133
|
|
|
|