@reliverse/relifso 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +6 -1
  2. package/bin/impl/async.d.ts +7 -0
  3. package/bin/impl/async.js +9 -0
  4. package/bin/impl/copy.d.ts +20 -0
  5. package/bin/impl/copy.js +28 -0
  6. package/bin/impl/create-file.d.ts +1 -0
  7. package/bin/impl/create-file.js +8 -0
  8. package/bin/impl/dive.d.ts +17 -0
  9. package/bin/impl/dive.js +56 -0
  10. package/bin/impl/empty-dir.d.ts +1 -0
  11. package/bin/impl/empty-dir.js +10 -0
  12. package/bin/impl/mkdirs.d.ts +1 -0
  13. package/bin/impl/mkdirs.js +7 -0
  14. package/bin/impl/move.d.ts +14 -0
  15. package/bin/impl/move.js +42 -0
  16. package/bin/impl/output-file.d.ts +8 -0
  17. package/bin/impl/output-file.js +8 -0
  18. package/bin/impl/output-json.d.ts +8 -0
  19. package/bin/impl/output-json.js +8 -0
  20. package/bin/impl/path-exists.d.ts +1 -0
  21. package/bin/impl/path-exists.js +4 -0
  22. package/bin/impl/read-file.d.ts +12 -0
  23. package/bin/impl/read-file.js +12 -0
  24. package/bin/impl/read-json.d.ts +14 -0
  25. package/bin/impl/read-json.js +24 -0
  26. package/bin/impl/remove.d.ts +1 -0
  27. package/bin/impl/remove.js +4 -0
  28. package/bin/impl/write-file.d.ts +11 -0
  29. package/bin/impl/write-file.js +9 -0
  30. package/bin/impl/write-json.d.ts +20 -0
  31. package/bin/impl/write-json.js +11 -0
  32. package/bin/mod.d.ts +50 -2
  33. package/bin/mod.js +158 -2
  34. package/package.json +6 -8
  35. package/bin/d.ts.txt +0 -1000
  36. package/bin/impl/args-impl.d.ts +0 -0
  37. package/bin/impl/args-impl.js +0 -0
  38. package/bin/impl/array-polyfill.d.ts +0 -15
  39. package/bin/impl/external/path-is-inside.d.ts +0 -1
  40. package/bin/impl/external/path-is-inside.js +0 -16
  41. package/bin/impl/external/vacuum.d.ts +0 -26
  42. package/bin/impl/external/vacuum.js +0 -95
  43. package/bin/impl/fs/dive.d.ts +0 -8
  44. package/bin/impl/fs/dive.js +0 -91
  45. package/bin/impl/fs/exists.d.ts +0 -31
  46. package/bin/impl/fs/exists.js +0 -10
  47. package/bin/impl/fs/for-each-child.d.ts +0 -34
  48. package/bin/impl/fs/for-each-child.js +0 -37
  49. package/bin/impl/fs/index.d.ts +0 -1118
  50. package/bin/impl/fs/index.js +0 -66
  51. package/bin/impl/fs/is-directory.d.ts +0 -14
  52. package/bin/impl/fs/is-directory.js +0 -16
  53. package/bin/impl/fs/map-children.d.ts +0 -17
  54. package/bin/impl/fs/map-children.js +0 -31
  55. package/bin/impl/fs/map-structure.d.ts +0 -35
  56. package/bin/impl/fs/map-structure.js +0 -44
  57. package/bin/impl/fs/read-lines.d.ts +0 -16
  58. package/bin/impl/fs/read-lines.js +0 -32
  59. package/bin/impl/fs/read-text.d.ts +0 -13
  60. package/bin/impl/fs/read-text.js +0 -10
  61. package/bin/impl/fs/universalify.d.ts +0 -18
  62. package/bin/impl/fs/universalify.js +0 -38
  63. package/bin/impl/fs/write-file.d.ts +0 -93
  64. package/bin/impl/fs/write-file.js +0 -47
  65. package/bin/impl/helpers.d.ts +0 -1
  66. package/bin/impl/helpers.js +0 -37
  67. package/bin/impl/json.d.ts +0 -16
  68. package/bin/impl/json.js +0 -90
  69. package/bin/impl/lib/copy/copy-sync.d.ts +0 -25
  70. package/bin/impl/lib/copy/copy-sync.js +0 -119
  71. package/bin/impl/lib/copy/copy.d.ts +0 -7
  72. package/bin/impl/lib/copy/copy.js +0 -144
  73. package/bin/impl/lib/copy/index.d.ts +0 -5
  74. package/bin/impl/lib/copy/index.js +0 -2
  75. package/bin/impl/lib/empty/index.d.ts +0 -1
  76. package/bin/impl/lib/empty/index.js +0 -29
  77. package/bin/impl/lib/ensure/file.d.ts +0 -2
  78. package/bin/impl/lib/ensure/file.js +0 -56
  79. package/bin/impl/lib/ensure/index.d.ts +0 -8
  80. package/bin/impl/lib/ensure/index.js +0 -12
  81. package/bin/impl/lib/ensure/link.d.ts +0 -2
  82. package/bin/impl/lib/ensure/link.js +0 -53
  83. package/bin/impl/lib/ensure/symlink-paths.d.ts +0 -5
  84. package/bin/impl/lib/ensure/symlink-paths.js +0 -63
  85. package/bin/impl/lib/ensure/symlink-type.d.ts +0 -2
  86. package/bin/impl/lib/ensure/symlink-type.js +0 -23
  87. package/bin/impl/lib/ensure/symlink.d.ts +0 -2
  88. package/bin/impl/lib/ensure/symlink.js +0 -59
  89. package/bin/impl/lib/fs/index.d.ts +0 -1
  90. package/bin/impl/lib/fs/index.js +0 -1
  91. package/bin/impl/lib/index.d.ts +0 -15
  92. package/bin/impl/lib/index.js +0 -34
  93. package/bin/impl/lib/index_rollup.d.ts +0 -10
  94. package/bin/impl/lib/index_rollup.js +0 -10
  95. package/bin/impl/lib/json/index.d.ts +0 -3
  96. package/bin/impl/lib/json/index.js +0 -10
  97. package/bin/impl/lib/json/output-json-sync.d.ts +0 -1
  98. package/bin/impl/lib/json/output-json-sync.js +0 -6
  99. package/bin/impl/lib/json/output-json.d.ts +0 -1
  100. package/bin/impl/lib/json/output-json.js +0 -6
  101. package/bin/impl/lib/mkdirs/index.d.ts +0 -1
  102. package/bin/impl/lib/mkdirs/index.js +0 -4
  103. package/bin/impl/lib/mkdirs/make-dir.d.ts +0 -2
  104. package/bin/impl/lib/mkdirs/make-dir.js +0 -21
  105. package/bin/impl/lib/mkdirs/utils.d.ts +0 -1
  106. package/bin/impl/lib/mkdirs/utils.js +0 -13
  107. package/bin/impl/lib/move/index.d.ts +0 -30
  108. package/bin/impl/lib/move/index.js +0 -2
  109. package/bin/impl/lib/move/move-sync.d.ts +0 -8
  110. package/bin/impl/lib/move/move-sync.js +0 -51
  111. package/bin/impl/lib/move/move.d.ts +0 -6
  112. package/bin/impl/lib/move/move.js +0 -48
  113. package/bin/impl/lib/output-file/index.d.ts +0 -1
  114. package/bin/impl/lib/output-file/index.js +0 -24
  115. package/bin/impl/lib/remove/index.d.ts +0 -53
  116. package/bin/impl/lib/remove/index.js +0 -8
  117. package/bin/impl/lib/util/stat.d.ts +0 -39
  118. package/bin/impl/lib/util/stat.js +0 -140
  119. package/bin/impl/lib/util/utimes.d.ts +0 -7
  120. package/bin/impl/lib/util/utimes.js +0 -31
  121. package/bin/impl/subindex.d.ts +0 -43
  122. package/bin/impl/subindex.js +0 -161
  123. package/bin/types.d.ts +0 -100
  124. package/bin/types.js +0 -1
@@ -1,1118 +0,0 @@
1
- import type * as fs from "node:fs";
2
- export * from "graceful-fs";
3
- /**
4
- * Asynchronously rename file at `oldPath` to the pathname provided
5
- * as `newPath`. In the case that `newPath` already exists, it will
6
- * be overwritten. If there is a directory at `newPath`, an error will
7
- * be raised instead. No arguments other than a possible exception are
8
- * given to the completion callback.
9
- *
10
- * See also: [`rename(2)`](http://man7.org/linux/man-pages/man2/rename.2.html).
11
- *
12
- * ```js
13
- * import { rename } from 'node:fs';
14
- *
15
- * rename('oldFile.txt', 'newFile.txt', (err) => {
16
- * if (err) throw err;
17
- * console.log('Rename complete!');
18
- * });
19
- * ```
20
- * @since v0.0.2
21
- * @see {@link fs.rename}
22
- * @see {@link fs.promises.rename}
23
- */
24
- export declare const rename: typeof fs.rename & typeof fs.rename.__promisify__;
25
- /**
26
- * Truncates the file. No arguments other than a possible exception are
27
- * given to the completion callback. A file descriptor can also be passed as the
28
- * first argument. In this case, `fs.ftruncate()` is called.
29
- *
30
- * ```js
31
- * import { truncate } from 'node:fs';
32
- * // Assuming that 'path/file.txt' is a regular file.
33
- * truncate('path/file.txt', (err) => {
34
- * if (err) throw err;
35
- * console.log('path/file.txt was truncated');
36
- * });
37
- * ```
38
- *
39
- * Passing a file descriptor is deprecated and may result in an error being thrown
40
- * in the future.
41
- *
42
- * See the POSIX [`truncate(2)`](http://man7.org/linux/man-pages/man2/truncate.2.html) documentation for more details.
43
- * @since v0.8.6
44
- * @param [len=0]
45
- * @see {@link fs.truncate}
46
- * @see {@link fs.promises.truncate}
47
- */
48
- export declare const truncate: typeof fs.truncate & typeof fs.truncate.__promisify__;
49
- /**
50
- * Truncates the file descriptor. No arguments other than a possible exception are
51
- * given to the completion callback.
52
- *
53
- * See the POSIX [`ftruncate(2)`](http://man7.org/linux/man-pages/man2/ftruncate.2.html) documentation for more detail.
54
- *
55
- * If the file referred to by the file descriptor was larger than `len` bytes, only
56
- * the first `len` bytes will be retained in the file.
57
- *
58
- * For example, the following program retains only the first four bytes of the
59
- * file:
60
- *
61
- * ```js
62
- * import { open, close, ftruncate } from 'node:fs';
63
- *
64
- * function closeFd(fd) {
65
- * close(fd, (err) => {
66
- * if (err) throw err;
67
- * });
68
- * }
69
- *
70
- * open('temp.txt', 'r+', (err, fd) => {
71
- * if (err) throw err;
72
- *
73
- * try {
74
- * ftruncate(fd, 4, (err) => {
75
- * closeFd(fd);
76
- * if (err) throw err;
77
- * });
78
- * } catch (err) {
79
- * closeFd(fd);
80
- * if (err) throw err;
81
- * }
82
- * });
83
- * ```
84
- *
85
- * If the file previously was shorter than `len` bytes, it is extended, and the
86
- * extended part is filled with null bytes (`'\0'`):
87
- *
88
- * If `len` is negative then `0` will be used.
89
- * @since v0.8.6
90
- * @param [len=0]
91
- * @see {@link fs.ftruncate}
92
- * @see {@link fs.promises.ftruncate}
93
- */
94
- export declare const ftruncate: typeof fs.ftruncate & typeof fs.ftruncate.__promisify__;
95
- /**
96
- * Asynchronously changes owner and group of a file. No arguments other than a
97
- * possible exception are given to the completion callback.
98
- *
99
- * See the POSIX [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html) documentation for more detail.
100
- * @since v0.1.97
101
- * @see {@link fs.chown}
102
- * @see {@link fs.promises.chown}
103
- */
104
- export declare const chown: typeof fs.chown & typeof fs.chown.__promisify__;
105
- /**
106
- * Sets the owner of the file. No arguments other than a possible exception are
107
- * given to the completion callback.
108
- *
109
- * See the POSIX [`fchown(2)`](http://man7.org/linux/man-pages/man2/fchown.2.html) documentation for more detail.
110
- * @since v0.4.7
111
- * @see {@link fs.fchown}
112
- * @see {@link fs.promises.fchown}
113
- */
114
- export declare const fchown: typeof fs.fchown & typeof fs.fchown.__promisify__;
115
- /**
116
- * Set the owner of the symbolic link. No arguments other than a possible
117
- * exception are given to the completion callback.
118
- *
119
- * See the POSIX [`lchown(2)`](http://man7.org/linux/man-pages/man2/lchown.2.html) documentation for more detail.
120
- * @see {@link fs.lchown}
121
- * @see {@link fs.promises.lchown}
122
- */
123
- export declare const lchown: typeof fs.lchown & typeof fs.lchown.__promisify__;
124
- /**
125
- * Changes the access and modification times of a file in the same way as {@link utimes}, with the difference that if the path refers to a symbolic
126
- * link, then the link is not dereferenced: instead, the timestamps of the
127
- * symbolic link itself are changed.
128
- *
129
- * No arguments other than a possible exception are given to the completion
130
- * callback.
131
- * @since v14.5.0, v12.19.0
132
- * @see {@link fs.lutimes}
133
- * @see {@link fs.promises.lutimes}
134
- */
135
- export declare const lutimes: typeof fs.lutimes & typeof fs.lutimes.__promisify__;
136
- /**
137
- * Asynchronously changes the permissions of a file. No arguments other than a
138
- * possible exception are given to the completion callback.
139
- *
140
- * See the POSIX [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html) documentation for more detail.
141
- *
142
- * ```js
143
- * import { chmod } from 'node:fs';
144
- *
145
- * chmod('my_file.txt', 0o775, (err) => {
146
- * if (err) throw err;
147
- * console.log('The permissions for file "my_file.txt" have been changed!');
148
- * });
149
- * ```
150
- * @since v0.1.30
151
- * @see {@link fs.chmod}
152
- * @see {@link fs.promises.chmod}
153
- */
154
- export declare const chmod: typeof fs.chmod & typeof fs.chmod.__promisify__;
155
- /**
156
- * Sets the permissions on the file. No arguments other than a possible exception
157
- * are given to the completion callback.
158
- *
159
- * See the POSIX [`fchmod(2)`](http://man7.org/linux/man-pages/man2/fchmod.2.html) documentation for more detail.
160
- * @since v0.4.7
161
- * @see {@link fs.fchmod}
162
- * @see {@link fs.promises.fchmod}
163
- */
164
- export declare const fchmod: typeof fs.fchmod & typeof fs.fchmod.__promisify__;
165
- /**
166
- * Changes the permissions on a symbolic link. No arguments other than a possible
167
- * exception are given to the completion callback.
168
- *
169
- * This method is only implemented on macOS.
170
- *
171
- * See the POSIX [`lchmod(2)`](https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2) documentation for more detail.
172
- * @deprecated Since v0.4.7
173
- * @see {@link fs.lchmod}
174
- * @see {@link fs.promises.lchmod}
175
- */
176
- export declare const lchmod: typeof fs.lchmod & typeof fs.lchmod.__promisify__;
177
- /**
178
- * Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where`stats` is an `fs.Stats` object.
179
- *
180
- * In case of an error, the `err.code` will be one of `Common System Errors`.
181
- *
182
- * {@link stat} follows symbolic links. Use {@link lstat} to look at the
183
- * links themselves.
184
- *
185
- * Using `fs.stat()` to check for the existence of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()` is not recommended.
186
- * Instead, user code should open/read/write the file directly and handle the
187
- * error raised if the file is not available.
188
- *
189
- * To check if a file exists without manipulating it afterwards, {@link access} is recommended.
190
- *
191
- * For example, given the following directory structure:
192
- *
193
- * ```text
194
- * - txtDir
195
- * -- file.txt
196
- * - app.js
197
- * ```
198
- *
199
- * The next program will check for the stats of the given paths:
200
- *
201
- * ```js
202
- * import { stat } from 'node:fs';
203
- *
204
- * const pathsToCheck = ['./txtDir', './txtDir/file.txt'];
205
- *
206
- * for (let i = 0; i < pathsToCheck.length; i++) {
207
- * stat(pathsToCheck[i], (err, stats) => {
208
- * console.log(stats.isDirectory());
209
- * console.log(stats);
210
- * });
211
- * }
212
- * ```
213
- *
214
- * The resulting output will resemble:
215
- *
216
- * ```console
217
- * true
218
- * Stats {
219
- * dev: 16777220,
220
- * mode: 16877,
221
- * nlink: 3,
222
- * uid: 501,
223
- * gid: 20,
224
- * rdev: 0,
225
- * blksize: 4096,
226
- * ino: 14214262,
227
- * size: 96,
228
- * blocks: 0,
229
- * atimeMs: 1561174653071.963,
230
- * mtimeMs: 1561174614583.3518,
231
- * ctimeMs: 1561174626623.5366,
232
- * birthtimeMs: 1561174126937.2893,
233
- * atime: 2019-06-22T03:37:33.072Z,
234
- * mtime: 2019-06-22T03:36:54.583Z,
235
- * ctime: 2019-06-22T03:37:06.624Z,
236
- * birthtime: 2019-06-22T03:28:46.937Z
237
- * }
238
- * false
239
- * Stats {
240
- * dev: 16777220,
241
- * mode: 33188,
242
- * nlink: 1,
243
- * uid: 501,
244
- * gid: 20,
245
- * rdev: 0,
246
- * blksize: 4096,
247
- * ino: 14214074,
248
- * size: 8,
249
- * blocks: 8,
250
- * atimeMs: 1561174616618.8555,
251
- * mtimeMs: 1561174614584,
252
- * ctimeMs: 1561174614583.8145,
253
- * birthtimeMs: 1561174007710.7478,
254
- * atime: 2019-06-22T03:36:56.619Z,
255
- * mtime: 2019-06-22T03:36:54.584Z,
256
- * ctime: 2019-06-22T03:36:54.584Z,
257
- * birthtime: 2019-06-22T03:26:47.711Z
258
- * }
259
- * ```
260
- * @since v0.0.2
261
- * @see {@link fs.stat}
262
- * @see {@link fs.promises.stat}
263
- */
264
- export declare const stat: typeof fs.stat & typeof fs.stat.__promisify__;
265
- /**
266
- * Invokes the callback with the `fs.Stats` for the file descriptor.
267
- *
268
- * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.
269
- * @since v0.1.95
270
- * @see {@link fs.fstat}
271
- * @see {@link fs.promises.fstat}
272
- */
273
- export declare const fstat: typeof fs.fstat & typeof fs.fstat.__promisify__;
274
- /**
275
- * Retrieves the `fs.Stats` for the symbolic link referred to by the path.
276
- * The callback gets two arguments `(err, stats)` where `stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic
277
- * link, then the link itself is stat-ed, not the file that it refers to.
278
- *
279
- * See the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details.
280
- * @since v0.1.30
281
- * @see {@link fs.lstat}
282
- * @see {@link fs.promises.lstat}
283
- */
284
- export declare const lstat: typeof fs.lstat & typeof fs.lstat.__promisify__;
285
- /**
286
- * Asynchronous [`statfs(2)`](http://man7.org/linux/man-pages/man2/statfs.2.html). Returns information about the mounted file system which
287
- * contains `path`. The callback gets two arguments `(err, stats)` where `stats`is an `fs.StatFs` object.
288
- *
289
- * In case of an error, the `err.code` will be one of `Common System Errors`.
290
- * @since v19.6.0, v18.15.0
291
- * @param path A path to an existing file or directory on the file system to be queried.
292
- * @see {@link fs.statfs}
293
- * @see {@link fs.promises.statfs}
294
- */
295
- export declare const statfs: typeof fs.statfs & typeof fs.statfs.__promisify__;
296
- /**
297
- * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. No arguments other than
298
- * a possible
299
- * exception are given to the completion callback.
300
- * @since v0.1.31
301
- * @see {@link fs.link}
302
- * @see {@link fs.promises.link}
303
- */
304
- export declare const link: typeof fs.link & typeof fs.link.__promisify__;
305
- /**
306
- * Creates the link called `path` pointing to `target`. No arguments other than a
307
- * possible exception are given to the completion callback.
308
- *
309
- * See the POSIX [`symlink(2)`](http://man7.org/linux/man-pages/man2/symlink.2.html) documentation for more details.
310
- *
311
- * The `type` argument is only available on Windows and ignored on other platforms.
312
- * It can be set to `'dir'`, `'file'`, or `'junction'`. If the `type` argument is
313
- * not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`.
314
- * If the `target` does not exist, `'file'` will be used. Windows junction points
315
- * require the destination path to be absolute. When using `'junction'`, the`target` argument will automatically be normalized to absolute path. Junction
316
- * points on NTFS volumes can only point to directories.
317
- *
318
- * Relative targets are relative to the link's parent directory.
319
- *
320
- * ```js
321
- * import { symlink } from 'node:fs';
322
- *
323
- * symlink('./mew', './mewtwo', callback);
324
- * ```
325
- *
326
- * The above example creates a symbolic link `mewtwo` which points to `mew` in the
327
- * same directory:
328
- *
329
- * ```bash
330
- * $ tree .
331
- * .
332
- * ├── mew
333
- * └── mewtwo -> ./mew
334
- * ```
335
- * @since v0.1.31
336
- * @param [type='null']
337
- * @see {@link fs.symlink}
338
- * @see {@link fs.promises.symlink}
339
- */
340
- export declare const symlink: typeof fs.symlink & typeof fs.symlink.__promisify__;
341
- /**
342
- * Reads the contents of the symbolic link referred to by `path`. The callback gets
343
- * two arguments `(err, linkString)`.
344
- *
345
- * See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more details.
346
- *
347
- * The optional `options` argument can be a string specifying an encoding, or an
348
- * object with an `encoding` property specifying the character encoding to use for
349
- * the link path passed to the callback. If the `encoding` is set to `'buffer'`,
350
- * the link path returned will be passed as a `Buffer` object.
351
- * @since v0.1.31
352
- * @see {@link fs.readlink}
353
- * @see {@link fs.promises.readlink}
354
- */
355
- export declare const readlink: typeof fs.readlink & typeof fs.readlink.__promisify__;
356
- /**
357
- * Asynchronously computes the canonical pathname by resolving `.`, `..`, and
358
- * symbolic links.
359
- *
360
- * A canonical pathname is not necessarily unique. Hard links and bind mounts can
361
- * expose a file system entity through many pathnames.
362
- *
363
- * This function behaves like [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html), with some exceptions:
364
- *
365
- * 1. No case conversion is performed on case-insensitive file systems.
366
- * 2. The maximum number of symbolic links is platform-independent and generally
367
- * (much) higher than what the native [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html) implementation supports.
368
- *
369
- * The `callback` gets two arguments `(err, resolvedPath)`. May use `process.cwd`to resolve relative paths.
370
- *
371
- * Only paths that can be converted to UTF8 strings are supported.
372
- *
373
- * The optional `options` argument can be a string specifying an encoding, or an
374
- * object with an `encoding` property specifying the character encoding to use for
375
- * the path passed to the callback. If the `encoding` is set to `'buffer'`,
376
- * the path returned will be passed as a `Buffer` object.
377
- *
378
- * If `path` resolves to a socket or a pipe, the function will return a system
379
- * dependent name for that object.
380
- * @since v0.1.31
381
- * @see {@link fs.realpath}
382
- * @see {@link fs.promises.realpath}
383
- */
384
- export declare const realpath: typeof fs.realpath & typeof fs.realpath.__promisify__ & {
385
- native: {
386
- (path: fs.PathLike, options: fs.EncodingOption): Promise<string>;
387
- (path: fs.PathLike, options: fs.BufferEncodingOption): Promise<Buffer>;
388
- (path: fs.PathLike, options: fs.EncodingOption): Promise<string | Buffer>;
389
- (path: fs.PathLike): Promise<string>;
390
- };
391
- };
392
- /**
393
- * Asynchronously removes a file or symbolic link. No arguments other than a
394
- * possible exception are given to the completion callback.
395
- *
396
- * ```js
397
- * import { unlink } from 'node:fs';
398
- * // Assuming that 'path/file.txt' is a regular file.
399
- * unlink('path/file.txt', (err) => {
400
- * if (err) throw err;
401
- * console.log('path/file.txt was deleted');
402
- * });
403
- * ```
404
- *
405
- * `fs.unlink()` will not work on a directory, empty or otherwise. To remove a
406
- * directory, use {@link rmdir}.
407
- *
408
- * See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more details.
409
- * @since v0.0.2
410
- * @see {@link fs.unlink}
411
- * @see {@link fs.promises.unlink}
412
- */
413
- export declare const unlink: typeof fs.unlink & typeof fs.unlink.__promisify__;
414
- /**
415
- * Asynchronous [`rmdir(2)`](http://man7.org/linux/man-pages/man2/rmdir.2.html). No arguments other than a possible exception are given
416
- * to the completion callback.
417
- *
418
- * Using `fs.rmdir()` on a file (not a directory) results in an `ENOENT` error on
419
- * Windows and an `ENOTDIR` error on POSIX.
420
- *
421
- * To get a behavior similar to the `rm -rf` Unix command, use {@link rm} with options `{ recursive: true, force: true }`.
422
- * @since v0.0.2
423
- * @see {@link fs.rmdir}
424
- * @see {@link fs.promises.rmdir}
425
- */
426
- export declare const rmdir: typeof fs.rmdir & typeof fs.rmdir.__promisify__;
427
- /**
428
- * Asynchronously removes files and directories (modeled on the standard POSIX `rm`utility). No arguments other than a possible exception are given to the
429
- * completion callback.
430
- * @since v14.14.0
431
- * @see {@link fs.rm}
432
- * @see {@link fs.promises.rm}
433
- */
434
- export declare const rm: typeof fs.rm & typeof fs.rm.__promisify__;
435
- /**
436
- * Asynchronously creates a directory.
437
- *
438
- * The callback is given a possible exception and, if `recursive` is `true`, the
439
- * first directory path created, `(err[, path])`.`path` can still be `undefined` when `recursive` is `true`, if no directory was
440
- * created (for instance, if it was previously created).
441
- *
442
- * The optional `options` argument can be an integer specifying `mode` (permission
443
- * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fs.mkdir()` when `path` is a directory that
444
- * exists results in an error only
445
- * when `recursive` is false. If `recursive` is false and the directory exists,
446
- * an `EEXIST` error occurs.
447
- *
448
- * ```js
449
- * import { mkdir } from 'node:fs';
450
- *
451
- * // Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist.
452
- * mkdir('./tmp/a/apple', { recursive: true }, (err) => {
453
- * if (err) throw err;
454
- * });
455
- * ```
456
- *
457
- * On Windows, using `fs.mkdir()` on the root directory even with recursion will
458
- * result in an error:
459
- *
460
- * ```js
461
- * import { mkdir } from 'node:fs';
462
- *
463
- * mkdir('/', { recursive: true }, (err) => {
464
- * // => [Error: EPERM: operation not permitted, mkdir 'C:\']
465
- * });
466
- * ```
467
- *
468
- * See the POSIX [`mkdir(2)`](http://man7.org/linux/man-pages/man2/mkdir.2.html) documentation for more details.
469
- * @since v0.1.8
470
- * @see {@link fs.mkdir}
471
- * @see {@link fs.promises.mkdir}
472
- */
473
- export declare const mkdir: typeof fs.mkdir & typeof fs.mkdir.__promisify__;
474
- /**
475
- * Creates a unique temporary directory.
476
- *
477
- * Generates six random characters to be appended behind a required`prefix` to create a unique temporary directory. Due to platform
478
- * inconsistencies, avoid trailing `X` characters in `prefix`. Some platforms,
479
- * notably the BSDs, can return more than six random characters, and replace
480
- * trailing `X` characters in `prefix` with random characters.
481
- *
482
- * The created directory path is passed as a string to the callback's second
483
- * parameter.
484
- *
485
- * The optional `options` argument can be a string specifying an encoding, or an
486
- * object with an `encoding` property specifying the character encoding to use.
487
- *
488
- * ```js
489
- * import { mkdtemp } from 'node:fs';
490
- * import { join } from 'node:path';
491
- * import { tmpdir } from 'node:os';
492
- *
493
- * mkdtemp(join(tmpdir(), 'foo-'), (err, directory) => {
494
- * if (err) throw err;
495
- * console.log(directory);
496
- * // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2
497
- * });
498
- * ```
499
- *
500
- * The `fs.mkdtemp()` method will append the six randomly selected characters
501
- * directly to the `prefix` string. For instance, given a directory `/tmp`, if the
502
- * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator
503
- * (`require('node:path').sep`).
504
- *
505
- * ```js
506
- * import { tmpdir } from 'node:os';
507
- * import { mkdtemp } from 'node:fs';
508
- *
509
- * // The parent directory for the new temporary directory
510
- * const tmpDir = tmpdir();
511
- *
512
- * // This method is *INCORRECT*:
513
- * mkdtemp(tmpDir, (err, directory) => {
514
- * if (err) throw err;
515
- * console.log(directory);
516
- * // Will print something similar to `/tmpabc123`.
517
- * // A new temporary directory is created at the file system root
518
- * // rather than *within* the /tmp directory.
519
- * });
520
- *
521
- * // This method is *CORRECT*:
522
- * import { sep } from 'node:path';
523
- * mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
524
- * if (err) throw err;
525
- * console.log(directory);
526
- * // Will print something similar to `/tmp/abc123`.
527
- * // A new temporary directory is created within
528
- * // the /tmp directory.
529
- * });
530
- * ```
531
- * @since v5.10.0
532
- * @see {@link fs.mkdtemp}
533
- * @see {@link fs.promises.mkdtemp}
534
- */
535
- export declare const mkdtemp: typeof fs.mkdtemp & typeof fs.mkdtemp.__promisify__;
536
- /**
537
- * Reads the contents of a directory. The callback gets two arguments `(err, files)`where `files` is an array of the names of the files in the directory excluding`'.'` and `'..'`.
538
- *
539
- * See the POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more details.
540
- *
541
- * The optional `options` argument can be a string specifying an encoding, or an
542
- * object with an `encoding` property specifying the character encoding to use for
543
- * the filenames passed to the callback. If the `encoding` is set to `'buffer'`,
544
- * the filenames returned will be passed as `Buffer` objects.
545
- *
546
- * If `options.withFileTypes` is set to `true`, the `files` array will contain `fs.Dirent` objects.
547
- * @since v0.1.8
548
- * @see {@link fs.readdir}
549
- * @see {@link fs.promises.readdir}
550
- */
551
- export declare const readdir: typeof fs.readdir & typeof fs.readdir.__promisify__;
552
- /**
553
- * Closes the file descriptor. No arguments other than a possible exception are
554
- * given to the completion callback.
555
- *
556
- * Calling `fs.close()` on any file descriptor (`fd`) that is currently in use
557
- * through any other `fs` operation may lead to undefined behavior.
558
- *
559
- * See the POSIX [`close(2)`](http://man7.org/linux/man-pages/man2/close.2.html) documentation for more detail.
560
- * @since v0.0.2
561
- * @see {@link fs.close}
562
- * @see {@link fs.promises.close}
563
- */
564
- export declare const close: typeof fs.close.__promisify__ & typeof fs.close;
565
- /**
566
- * Asynchronous file open. See the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more details.
567
- *
568
- * `mode` sets the file mode (permission and sticky bits), but only if the file was
569
- * created. On Windows, only the write permission can be manipulated; see {@link chmod}.
570
- *
571
- * The callback gets two arguments `(err, fd)`.
572
- *
573
- * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
574
- * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
575
- * a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
576
- *
577
- * Functions based on `fs.open()` exhibit this behavior as well:`fs.writeFile()`, `fs.readFile()`, etc.
578
- * @since v0.0.2
579
- * @param [flags='r'] See `support of file system `flags``.
580
- * @param [mode=0o666]
581
- * @see {@link fs.open}
582
- * @see {@link fs.promises.open}
583
- */
584
- export declare const open: typeof fs.open & typeof fs.open.__promisify__;
585
- /**
586
- * Change the file system timestamps of the object referenced by `path`.
587
- *
588
- * The `atime` and `mtime` arguments follow these rules:
589
- *
590
- * * Values can be either numbers representing Unix epoch time in seconds,`Date`s, or a numeric string like `'123456789.0'`.
591
- * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or`-Infinity`, an `Error` will be thrown.
592
- * @since v0.4.2
593
- * @see {@link fs.utimes}
594
- * @see {@link fs.promises.utimes}
595
- */
596
- export declare const utimes: typeof fs.utimes & typeof fs.utimes.__promisify__;
597
- /**
598
- * Change the file system timestamps of the object referenced by the supplied file
599
- * descriptor. See {@link utimes}.
600
- * @since v0.4.2
601
- * @see {@link fs.futimes}
602
- * @see {@link fs.promises.futimes}
603
- */
604
- export declare const futimes: typeof fs.futimes & typeof fs.futimes.__promisify__;
605
- /**
606
- * Write `buffer` to the file specified by `fd`.
607
- *
608
- * `offset` determines the part of the buffer to be written, and `length` is
609
- * an integer specifying the number of bytes to write.
610
- *
611
- * `position` refers to the offset from the beginning of the file where this data
612
- * should be written. If `typeof position !== 'number'`, the data will be written
613
- * at the current position. See [`pwrite(2)`](http://man7.org/linux/man-pages/man2/pwrite.2.html).
614
- *
615
- * The callback will be given three arguments `(err, bytesWritten, buffer)` where`bytesWritten` specifies how many _bytes_ were written from `buffer`.
616
- *
617
- * If this method is invoked as its `util.promisify()` ed version, it returns
618
- * a promise for an `Object` with `bytesWritten` and `buffer` properties.
619
- *
620
- * It is unsafe to use `fs.write()` multiple times on the same file without waiting
621
- * for the callback. For this scenario, {@link createWriteStream} is
622
- * recommended.
623
- *
624
- * On Linux, positional writes don't work when the file is opened in append mode.
625
- * The kernel ignores the position argument and always appends the data to
626
- * the end of the file.
627
- * @since v0.0.2
628
- * @param [offset=0]
629
- * @param [length=buffer.byteLength - offset]
630
- * @param [position='null']
631
- * @see {@link fs.write}
632
- * @see {@link fs.promises.write}
633
- */
634
- export declare const write: typeof fs.write & typeof fs.write.__promisify__;
635
- /**
636
- * Read data from the file specified by `fd`.
637
- *
638
- * The callback is given the three arguments, `(err, bytesRead, buffer)`.
639
- *
640
- * If the file is not modified concurrently, the end-of-file is reached when the
641
- * number of bytes read is zero.
642
- *
643
- * If this method is invoked as its `util.promisify()` ed version, it returns
644
- * a promise for an `Object` with `bytesRead` and `buffer` properties.
645
- * @since v0.0.2
646
- * @param buffer The buffer that the data will be written to.
647
- * @param offset The position in `buffer` to write the data to.
648
- * @param length The number of bytes to read.
649
- * @param position Specifies where to begin reading from in the file. If `position` is `null` or `-1 `, data will be read from the current file position, and the file position will be updated. If
650
- * `position` is an integer, the file position will be unchanged.
651
- * @see {@link fs.read}
652
- * @see {@link fs.promises.read}
653
- */
654
- export declare const read: typeof fs.read & typeof fs.read.__promisify__;
655
- /**
656
- * Asynchronously reads the entire contents of a file.
657
- *
658
- * ```js
659
- * import { readFile } from 'node:fs';
660
- *
661
- * readFile('/etc/passwd', (err, data) => {
662
- * if (err) throw err;
663
- * console.log(data);
664
- * });
665
- * ```
666
- *
667
- * The callback is passed two arguments `(err, data)`, where `data` is the
668
- * contents of the file.
669
- *
670
- * If no encoding is specified, then the raw buffer is returned.
671
- *
672
- * If `options` is a string, then it specifies the encoding:
673
- *
674
- * ```js
675
- * import { readFile } from 'node:fs';
676
- *
677
- * readFile('/etc/passwd', 'utf8', callback);
678
- * ```
679
- *
680
- * When the path is a directory, the behavior of `fs.readFile()` and {@link fs.readFileSync} is platform-specific. On macOS, Linux, and Windows, an
681
- * error will be returned. On FreeBSD, a representation of the directory's contents
682
- * will be returned.
683
- *
684
- * ```js
685
- * import { readFile } from 'node:fs';
686
- *
687
- * // macOS, Linux, and Windows
688
- * readFile('<directory>', (err, data) => {
689
- * // => [Error: EISDIR: illegal operation on a directory, read <directory>]
690
- * });
691
- *
692
- * // FreeBSD
693
- * readFile('<directory>', (err, data) => {
694
- * // => null, <data>
695
- * });
696
- * ```
697
- *
698
- * It is possible to abort an ongoing request using an `AbortSignal`. If a
699
- * request is aborted the callback is called with an `AbortError`:
700
- *
701
- * ```js
702
- * import { readFile } from 'node:fs';
703
- *
704
- * const controller = new AbortController();
705
- * const signal = controller.signal;
706
- * readFile(fileInfo[0].name, { signal }, (err, buf) => {
707
- * // ...
708
- * });
709
- * // When you want to abort the request
710
- * controller.abort();
711
- * ```
712
- *
713
- * The `fs.readFile()` function buffers the entire file. To minimize memory costs,
714
- * when possible prefer streaming via `fs.createReadStream()`.
715
- *
716
- * Aborting an ongoing request does not abort individual operating
717
- * system requests but rather the internal buffering `fs.readFile` performs.
718
- * @since v0.1.29
719
- * @param path filename or file descriptor
720
- * @see {@link fs.readFile}
721
- * @see {@link fs.promises.readFile}
722
- */
723
- export declare const readFile: typeof fs.readFile & typeof fs.readFile.__promisify__;
724
- /**
725
- * When `file` is a filename, asynchronously writes data to the file, replacing the
726
- * file if it already exists. `data` can be a string or a buffer.
727
- *
728
- * When `file` is a file descriptor, the behavior is similar to calling`fs.write()` directly (which is recommended). See the notes below on using
729
- * a file descriptor.
730
- *
731
- * The `encoding` option is ignored if `data` is a buffer.
732
- *
733
- * The `mode` option only affects the newly created file. See {@link open} for more details.
734
- *
735
- * ```js
736
- * import { writeFile } from 'node:fs';
737
- * import { Buffer } from 'node:buffer';
738
- *
739
- * const data = new Uint8Array(Buffer.from('Hello Node.js'));
740
- * writeFile('message.txt', data, (err) => {
741
- * if (err) throw err;
742
- * console.log('The file has been saved!');
743
- * });
744
- * ```
745
- *
746
- * If `options` is a string, then it specifies the encoding:
747
- *
748
- * ```js
749
- * import { writeFile } from 'node:fs';
750
- *
751
- * writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
752
- * ```
753
- *
754
- * It is unsafe to use `fs.writeFile()` multiple times on the same file without
755
- * waiting for the callback. For this scenario, {@link createWriteStream} is
756
- * recommended.
757
- *
758
- * Similarly to `fs.readFile` \- `fs.writeFile` is a convenience method that
759
- * performs multiple `write` calls internally to write the buffer passed to it.
760
- * For performance sensitive code consider using {@link createWriteStream}.
761
- *
762
- * It is possible to use an `AbortSignal` to cancel an `fs.writeFile()`.
763
- * Cancelation is "best effort", and some amount of data is likely still
764
- * to be written.
765
- *
766
- * ```js
767
- * import { writeFile } from 'node:fs';
768
- * import { Buffer } from 'node:buffer';
769
- *
770
- * const controller = new AbortController();
771
- * const { signal } = controller;
772
- * const data = new Uint8Array(Buffer.from('Hello Node.js'));
773
- * writeFile('message.txt', data, { signal }, (err) => {
774
- * // When a request is aborted - the callback is called with an AbortError
775
- * });
776
- * // When the request should be aborted
777
- * controller.abort();
778
- * ```
779
- *
780
- * Aborting an ongoing request does not abort individual operating
781
- * system requests but rather the internal buffering `fs.writeFile` performs.
782
- * @since v0.1.29
783
- * @param file filename or file descriptor
784
- * @see {@link fs.writeFile}
785
- * @see {@link fs.promises.writeFile}
786
- */
787
- export declare const writeFile: typeof fs.writeFile & typeof fs.writeFile.__promisify__;
788
- /**
789
- * Asynchronously append data to a file, creating the file if it does not yet
790
- * exist. `data` can be a string or a `Buffer`.
791
- *
792
- * The `mode` option only affects the newly created file. See {@link open} for more details.
793
- *
794
- * ```js
795
- * import { appendFile } from 'node:fs';
796
- *
797
- * appendFile('message.txt', 'data to append', (err) => {
798
- * if (err) throw err;
799
- * console.log('The "data to append" was appended to file!');
800
- * });
801
- * ```
802
- *
803
- * If `options` is a string, then it specifies the encoding:
804
- *
805
- * ```js
806
- * import { appendFile } from 'node:fs';
807
- *
808
- * appendFile('message.txt', 'data to append', 'utf8', callback);
809
- * ```
810
- *
811
- * The `path` may be specified as a numeric file descriptor that has been opened
812
- * for appending (using `fs.open()` or `fs.openSync()`). The file descriptor will
813
- * not be closed automatically.
814
- *
815
- * ```js
816
- * import { open, close, appendFile } from 'node:fs';
817
- *
818
- * function closeFd(fd) {
819
- * close(fd, (err) => {
820
- * if (err) throw err;
821
- * });
822
- * }
823
- *
824
- * open('message.txt', 'a', (err, fd) => {
825
- * if (err) throw err;
826
- *
827
- * try {
828
- * appendFile(fd, 'data to append', 'utf8', (err) => {
829
- * closeFd(fd);
830
- * if (err) throw err;
831
- * });
832
- * } catch (err) {
833
- * closeFd(fd);
834
- * throw err;
835
- * }
836
- * });
837
- * ```
838
- * @since v0.6.7
839
- * @param path filename or file descriptor
840
- * @see {@link fs.appendFile}
841
- * @see {@link fs.promises.appendFile}
842
- */
843
- export declare const appendFile: typeof fs.appendFile & typeof fs.appendFile.__promisify__;
844
- /**
845
- * Tests a user's permissions for the file or directory specified by `path`.
846
- * The `mode` argument is an optional integer that specifies the accessibility
847
- * checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
848
- * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
849
- * possible values of `mode`.
850
- *
851
- * The final argument, `callback`, is a callback function that is invoked with
852
- * a possible error argument. If any of the accessibility checks fail, the error
853
- * argument will be an `Error` object. The following examples check if`package.json` exists, and if it is readable or writable.
854
- *
855
- * ```js
856
- * import { access, constants } from 'node:fs';
857
- *
858
- * const file = 'package.json';
859
- *
860
- * // Check if the file exists in the current directory.
861
- * access(file, constants.F_OK, (err) => {
862
- * console.log(`${file} ${err ? 'does not exist' : 'exists'}`);
863
- * });
864
- *
865
- * // Check if the file is readable.
866
- * access(file, constants.R_OK, (err) => {
867
- * console.log(`${file} ${err ? 'is not readable' : 'is readable'}`);
868
- * });
869
- *
870
- * // Check if the file is writable.
871
- * access(file, constants.W_OK, (err) => {
872
- * console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);
873
- * });
874
- *
875
- * // Check if the file is readable and writable.
876
- * access(file, constants.R_OK | constants.W_OK, (err) => {
877
- * console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`);
878
- * });
879
- * ```
880
- *
881
- * Do not use `fs.access()` to check for the accessibility of a file before calling`fs.open()`, `fs.readFile()`, or `fs.writeFile()`. Doing
882
- * so introduces a race condition, since other processes may change the file's
883
- * state between the two calls. Instead, user code should open/read/write the
884
- * file directly and handle the error raised if the file is not accessible.
885
- *
886
- * **write (NOT RECOMMENDED)**
887
- *
888
- * ```js
889
- * import { access, open, close } from 'node:fs';
890
- *
891
- * access('myfile', (err) => {
892
- * if (!err) {
893
- * console.error('myfile already exists');
894
- * return;
895
- * }
896
- *
897
- * open('myfile', 'wx', (err, fd) => {
898
- * if (err) throw err;
899
- *
900
- * try {
901
- * writeMyData(fd);
902
- * } finally {
903
- * close(fd, (err) => {
904
- * if (err) throw err;
905
- * });
906
- * }
907
- * });
908
- * });
909
- * ```
910
- *
911
- * **write (RECOMMENDED)**
912
- *
913
- * ```js
914
- * import { open, close } from 'node:fs';
915
- *
916
- * open('myfile', 'wx', (err, fd) => {
917
- * if (err) {
918
- * if (err.code === 'EEXIST') {
919
- * console.error('myfile already exists');
920
- * return;
921
- * }
922
- *
923
- * throw err;
924
- * }
925
- *
926
- * try {
927
- * writeMyData(fd);
928
- * } finally {
929
- * close(fd, (err) => {
930
- * if (err) throw err;
931
- * });
932
- * }
933
- * });
934
- * ```
935
- *
936
- * **read (NOT RECOMMENDED)**
937
- *
938
- * ```js
939
- * import { access, open, close } from 'node:fs';
940
- * access('myfile', (err) => {
941
- * if (err) {
942
- * if (err.code === 'ENOENT') {
943
- * console.error('myfile does not exist');
944
- * return;
945
- * }
946
- *
947
- * throw err;
948
- * }
949
- *
950
- * open('myfile', 'r', (err, fd) => {
951
- * if (err) throw err;
952
- *
953
- * try {
954
- * readMyData(fd);
955
- * } finally {
956
- * close(fd, (err) => {
957
- * if (err) throw err;
958
- * });
959
- * }
960
- * });
961
- * });
962
- * ```
963
- *
964
- * **read (RECOMMENDED)**
965
- *
966
- * ```js
967
- * import { open, close } from 'node:fs';
968
- *
969
- * open('myfile', 'r', (err, fd) => {
970
- * if (err) {
971
- * if (err.code === 'ENOENT') {
972
- * console.error('myfile does not exist');
973
- * return;
974
- * }
975
- *
976
- * throw err;
977
- * }
978
- *
979
- * try {
980
- * readMyData(fd);
981
- * } finally {
982
- * close(fd, (err) => {
983
- * if (err) throw err;
984
- * });
985
- * }
986
- * });
987
- * ```
988
- *
989
- * The "not recommended" examples above check for accessibility and then use the
990
- * file; the "recommended" examples are better because they use the file directly
991
- * and handle the error, if any.
992
- *
993
- * In general, check for the accessibility of a file only if the file will not be
994
- * used directly, for example when its accessibility is a signal from another
995
- * process.
996
- *
997
- * On Windows, access-control policies (ACLs) on a directory may limit access to
998
- * a file or directory. The `fs.access()` function, however, does not check the
999
- * ACL and therefore may report that a path is accessible even if the ACL restricts
1000
- * the user from reading or writing to it.
1001
- * @since v0.11.15
1002
- * @param [mode=fs.constants.F_OK]
1003
- * @see {@link fs.access}
1004
- * @see {@link fs.promises.access}
1005
- */
1006
- export declare const access: typeof fs.access & typeof fs.access.__promisify__;
1007
- /**
1008
- * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
1009
- * already exists. No arguments other than a possible exception are given to the
1010
- * callback function. Node.js makes no guarantees about the atomicity of the copy
1011
- * operation. If an error occurs after the destination file has been opened for
1012
- * writing, Node.js will attempt to remove the destination.
1013
- *
1014
- * `mode` is an optional integer that specifies the behavior
1015
- * of the copy operation. It is possible to create a mask consisting of the bitwise
1016
- * OR of two or more values (e.g.`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
1017
- *
1018
- * * `fs.constants.COPYFILE_EXCL`: The copy operation will fail if `dest` already
1019
- * exists.
1020
- * * `fs.constants.COPYFILE_FICLONE`: The copy operation will attempt to create a
1021
- * copy-on-write reflink. If the platform does not support copy-on-write, then a
1022
- * fallback copy mechanism is used.
1023
- * * `fs.constants.COPYFILE_FICLONE_FORCE`: The copy operation will attempt to
1024
- * create a copy-on-write reflink. If the platform does not support
1025
- * copy-on-write, then the operation will fail.
1026
- *
1027
- * ```js
1028
- * import { copyFile, constants } from 'node:fs';
1029
- *
1030
- * function callback(err) {
1031
- * if (err) throw err;
1032
- * console.log('source.txt was copied to destination.txt');
1033
- * }
1034
- *
1035
- * // destination.txt will be created or overwritten by default.
1036
- * copyFile('source.txt', 'destination.txt', callback);
1037
- *
1038
- * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
1039
- * copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL, callback);
1040
- * ```
1041
- * @since v8.5.0
1042
- * @param src source filename to copy
1043
- * @param dest destination filename of the copy operation
1044
- * @param [mode=0] modifiers for copy operation.
1045
- * @see {@link fs.copyFile}
1046
- * @see {@link fs.promises.copyFile}
1047
- */
1048
- export declare const copyFile: typeof fs.copyFile & typeof fs.copyFile.__promisify__;
1049
- /**
1050
- * Write an array of `ArrayBufferView`s to the file specified by `fd` using`writev()`.
1051
- *
1052
- * `position` is the offset from the beginning of the file where this data
1053
- * should be written. If `typeof position !== 'number'`, the data will be written
1054
- * at the current position.
1055
- *
1056
- * The callback will be given three arguments: `err`, `bytesWritten`, and`buffers`. `bytesWritten` is how many bytes were written from `buffers`.
1057
- *
1058
- * If this method is `util.promisify()` ed, it returns a promise for an`Object` with `bytesWritten` and `buffers` properties.
1059
- *
1060
- * It is unsafe to use `fs.writev()` multiple times on the same file without
1061
- * waiting for the callback. For this scenario, use {@link createWriteStream}.
1062
- *
1063
- * On Linux, positional writes don't work when the file is opened in append mode.
1064
- * The kernel ignores the position argument and always appends the data to
1065
- * the end of the file.
1066
- * @since v12.9.0
1067
- * @param [position='null']
1068
- * @see {@link fs.writev}
1069
- * @see {@link fs.promises.writev}
1070
- */
1071
- export declare const writev: typeof fs.writev & typeof fs.writev.__promisify__;
1072
- /**
1073
- * Read from a file specified by `fd` and write to an array of `ArrayBufferView`s
1074
- * using `readv()`.
1075
- *
1076
- * `position` is the offset from the beginning of the file from where data
1077
- * should be read. If `typeof position !== 'number'`, the data will be read
1078
- * from the current position.
1079
- *
1080
- * The callback will be given three arguments: `err`, `bytesRead`, and`buffers`. `bytesRead` is how many bytes were read from the file.
1081
- *
1082
- * If this method is invoked as its `util.promisify()` ed version, it returns
1083
- * a promise for an `Object` with `bytesRead` and `buffers` properties.
1084
- * @since v13.13.0, v12.17.0
1085
- * @param [position='null']
1086
- * @see {@link fs.readv}
1087
- * @see {@link fs.promises.readv}
1088
- */
1089
- export declare const readv: typeof fs.readv & typeof fs.readv.__promisify__;
1090
- /**
1091
- * Asynchronously open a directory. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for
1092
- * more details.
1093
- *
1094
- * Creates an `fs.Dir`, which contains all further functions for reading from
1095
- * and cleaning up the directory.
1096
- *
1097
- * The `encoding` option sets the encoding for the `path` while opening the
1098
- * directory and subsequent read operations.
1099
- * @since v12.12.0
1100
- * @see {@link fs.opendir}
1101
- * @see {@link fs.promises.opendir}
1102
- */
1103
- export declare const opendir: typeof fs.opendir & typeof fs.opendir.__promisify__;
1104
- /**
1105
- * Asynchronously copies the entire directory structure from `src` to `dest`,
1106
- * including subdirectories and files.
1107
- *
1108
- * When copying a directory to another directory, globs are not supported and
1109
- * behavior is similar to `cp dir1/ dir2/`.
1110
- * @since v16.7.0
1111
- * @experimental
1112
- * @param src source path to copy.
1113
- * @param dest destination path to copy to.
1114
- */
1115
- export declare const cp: typeof fs.cp & {
1116
- cp(source: string | URL, destination: string | URL): Promise<void>;
1117
- cp(source: string | URL, destination: string | URL, opts: fs.CopyOptions): Promise<void>;
1118
- };