@zenfs/core 0.0.1
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.
- package/README.md +293 -0
- package/dist/ApiError.d.ts +86 -0
- package/dist/ApiError.js +135 -0
- package/dist/backends/AsyncMirror.d.ts +102 -0
- package/dist/backends/AsyncMirror.js +252 -0
- package/dist/backends/AsyncStore.d.ts +166 -0
- package/dist/backends/AsyncStore.js +620 -0
- package/dist/backends/FolderAdapter.d.ts +52 -0
- package/dist/backends/FolderAdapter.js +184 -0
- package/dist/backends/InMemory.d.ts +25 -0
- package/dist/backends/InMemory.js +46 -0
- package/dist/backends/Locked.d.ts +64 -0
- package/dist/backends/Locked.js +302 -0
- package/dist/backends/OverlayFS.d.ts +120 -0
- package/dist/backends/OverlayFS.js +749 -0
- package/dist/backends/SyncStore.d.ts +223 -0
- package/dist/backends/SyncStore.js +479 -0
- package/dist/backends/backend.d.ts +73 -0
- package/dist/backends/backend.js +14 -0
- package/dist/backends/index.d.ts +11 -0
- package/dist/backends/index.js +15 -0
- package/dist/browser.min.js +12 -0
- package/dist/browser.min.js.map +7 -0
- package/dist/cred.d.ts +14 -0
- package/dist/cred.js +15 -0
- package/dist/emulation/callbacks.d.ts +382 -0
- package/dist/emulation/callbacks.js +422 -0
- package/dist/emulation/constants.d.ts +101 -0
- package/dist/emulation/constants.js +110 -0
- package/dist/emulation/fs.d.ts +7 -0
- package/dist/emulation/fs.js +5 -0
- package/dist/emulation/index.d.ts +5 -0
- package/dist/emulation/index.js +7 -0
- package/dist/emulation/promises.d.ts +309 -0
- package/dist/emulation/promises.js +521 -0
- package/dist/emulation/shared.d.ts +62 -0
- package/dist/emulation/shared.js +192 -0
- package/dist/emulation/sync.d.ts +278 -0
- package/dist/emulation/sync.js +392 -0
- package/dist/file.d.ts +449 -0
- package/dist/file.js +576 -0
- package/dist/filesystem.d.ts +367 -0
- package/dist/filesystem.js +542 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +113 -0
- package/dist/inode.d.ts +51 -0
- package/dist/inode.js +112 -0
- package/dist/mutex.d.ts +12 -0
- package/dist/mutex.js +48 -0
- package/dist/stats.d.ts +98 -0
- package/dist/stats.js +226 -0
- package/dist/utils.d.ts +52 -0
- package/dist/utils.js +261 -0
- package/license.md +122 -0
- package/package.json +61 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { ApiError, ErrorCode } from '../ApiError';
|
|
2
|
+
import { nop, normalizeMode } from './shared';
|
|
3
|
+
import * as promises from './promises';
|
|
4
|
+
import { R_OK } from './constants';
|
|
5
|
+
/**
|
|
6
|
+
* Asynchronous rename. No arguments other than a possible exception are given
|
|
7
|
+
* to the completion callback.
|
|
8
|
+
* @param oldPath
|
|
9
|
+
* @param newPath
|
|
10
|
+
* @param callback
|
|
11
|
+
*/
|
|
12
|
+
export function rename(oldPath, newPath, cb = nop) {
|
|
13
|
+
promises
|
|
14
|
+
.rename(oldPath, newPath)
|
|
15
|
+
.then(() => cb())
|
|
16
|
+
.catch(cb);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Test whether or not the given path exists by checking with the file system.
|
|
20
|
+
* Then call the callback argument with either true or false.
|
|
21
|
+
* @example Sample invocation
|
|
22
|
+
* fs.exists('/etc/passwd', function (exists) {
|
|
23
|
+
* util.debug(exists ? "it's there" : "no passwd!");
|
|
24
|
+
* });
|
|
25
|
+
* @param path
|
|
26
|
+
* @param callback
|
|
27
|
+
*/
|
|
28
|
+
export function exists(path, cb = nop) {
|
|
29
|
+
promises
|
|
30
|
+
.exists(path)
|
|
31
|
+
.then(cb)
|
|
32
|
+
.catch(() => cb(false));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Asynchronous `stat`.
|
|
36
|
+
* @param path
|
|
37
|
+
* @param callback
|
|
38
|
+
*/
|
|
39
|
+
export function stat(path, cb = nop) {
|
|
40
|
+
promises
|
|
41
|
+
.stat(path)
|
|
42
|
+
.then(stats => cb(null, stats))
|
|
43
|
+
.catch(cb);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Asynchronous `lstat`.
|
|
47
|
+
* `lstat()` is identical to `stat()`, except that if path is a symbolic link,
|
|
48
|
+
* then the link itself is stat-ed, not the file that it refers to.
|
|
49
|
+
* @param path
|
|
50
|
+
* @param callback
|
|
51
|
+
*/
|
|
52
|
+
export function lstat(path, cb = nop) {
|
|
53
|
+
promises
|
|
54
|
+
.lstat(path)
|
|
55
|
+
.then(stats => cb(null, stats))
|
|
56
|
+
.catch(cb);
|
|
57
|
+
}
|
|
58
|
+
export function truncate(path, arg2 = 0, cb = nop) {
|
|
59
|
+
cb = typeof arg2 === 'function' ? arg2 : cb;
|
|
60
|
+
const len = typeof arg2 === 'number' ? arg2 : 0;
|
|
61
|
+
promises
|
|
62
|
+
.truncate(path, len)
|
|
63
|
+
.then(() => cb())
|
|
64
|
+
.catch(cb);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Asynchronous `unlink`.
|
|
68
|
+
* @param path
|
|
69
|
+
* @param callback
|
|
70
|
+
*/
|
|
71
|
+
export function unlink(path, cb = nop) {
|
|
72
|
+
promises
|
|
73
|
+
.unlink(path)
|
|
74
|
+
.then(() => cb())
|
|
75
|
+
.catch(cb);
|
|
76
|
+
}
|
|
77
|
+
export function open(path, flag, arg2, cb = nop) {
|
|
78
|
+
const mode = normalizeMode(arg2, 0o644);
|
|
79
|
+
cb = typeof arg2 === 'function' ? arg2 : cb;
|
|
80
|
+
promises
|
|
81
|
+
.open(path, flag, mode)
|
|
82
|
+
.then(fd => cb(null, fd))
|
|
83
|
+
.catch(cb);
|
|
84
|
+
}
|
|
85
|
+
export function readFile(filename, arg2 = {}, cb = nop) {
|
|
86
|
+
cb = typeof arg2 === 'function' ? arg2 : cb;
|
|
87
|
+
promises.readFile(filename, typeof arg2 === 'function' ? null : arg2);
|
|
88
|
+
}
|
|
89
|
+
export function writeFile(filename, data, arg3 = {}, cb = nop) {
|
|
90
|
+
cb = typeof arg3 === 'function' ? arg3 : cb;
|
|
91
|
+
promises.writeFile(filename, data, typeof arg3 === 'function' ? undefined : arg3);
|
|
92
|
+
}
|
|
93
|
+
export function appendFile(filename, data, arg3, cb = nop) {
|
|
94
|
+
cb = typeof arg3 === 'function' ? arg3 : cb;
|
|
95
|
+
promises.appendFile(filename, data, typeof arg3 === 'function' ? null : arg3);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Asynchronous `fstat`.
|
|
99
|
+
* `fstat()` is identical to `stat()`, except that the file to be stat-ed is
|
|
100
|
+
* specified by the file descriptor `fd`.
|
|
101
|
+
* @param fd
|
|
102
|
+
* @param callback
|
|
103
|
+
*/
|
|
104
|
+
export function fstat(fd, cb = nop) {
|
|
105
|
+
promises
|
|
106
|
+
.fstat(fd)
|
|
107
|
+
.then(stats => cb(null, stats))
|
|
108
|
+
.catch(cb);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Asynchronous close.
|
|
112
|
+
* @param fd
|
|
113
|
+
* @param callback
|
|
114
|
+
*/
|
|
115
|
+
export function close(fd, cb = nop) {
|
|
116
|
+
promises
|
|
117
|
+
.close(fd)
|
|
118
|
+
.then(() => cb())
|
|
119
|
+
.catch(cb);
|
|
120
|
+
}
|
|
121
|
+
export function ftruncate(fd, arg2, cb = nop) {
|
|
122
|
+
const length = typeof arg2 === 'number' ? arg2 : 0;
|
|
123
|
+
cb = typeof arg2 === 'function' ? arg2 : cb;
|
|
124
|
+
promises.ftruncate(fd, length);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Asynchronous fsync.
|
|
128
|
+
* @param fd
|
|
129
|
+
* @param callback
|
|
130
|
+
*/
|
|
131
|
+
export function fsync(fd, cb = nop) {
|
|
132
|
+
promises
|
|
133
|
+
.fsync(fd)
|
|
134
|
+
.then(() => cb())
|
|
135
|
+
.catch(cb);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Asynchronous fdatasync.
|
|
139
|
+
* @param fd
|
|
140
|
+
* @param callback
|
|
141
|
+
*/
|
|
142
|
+
export function fdatasync(fd, cb = nop) {
|
|
143
|
+
promises
|
|
144
|
+
.fdatasync(fd)
|
|
145
|
+
.then(() => cb())
|
|
146
|
+
.catch(cb);
|
|
147
|
+
}
|
|
148
|
+
export function write(fd, arg2, arg3, arg4, arg5, cb = nop) {
|
|
149
|
+
let buffer, offset, length, position = null, encoding;
|
|
150
|
+
if (typeof arg2 === 'string') {
|
|
151
|
+
// Signature 1: (fd, string, [position?, [encoding?]], cb?)
|
|
152
|
+
encoding = 'utf8';
|
|
153
|
+
switch (typeof arg3) {
|
|
154
|
+
case 'function':
|
|
155
|
+
// (fd, string, cb)
|
|
156
|
+
cb = arg3;
|
|
157
|
+
break;
|
|
158
|
+
case 'number':
|
|
159
|
+
// (fd, string, position, encoding?, cb?)
|
|
160
|
+
position = arg3;
|
|
161
|
+
encoding = (typeof arg4 === 'string' ? arg4 : 'utf8');
|
|
162
|
+
cb = typeof arg5 === 'function' ? arg5 : cb;
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
// ...try to find the callback and get out of here!
|
|
166
|
+
cb = typeof arg4 === 'function' ? arg4 : typeof arg5 === 'function' ? arg5 : cb;
|
|
167
|
+
cb(new ApiError(ErrorCode.EINVAL, 'Invalid arguments.'));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
buffer = Buffer.from(arg2, encoding);
|
|
171
|
+
offset = 0;
|
|
172
|
+
length = buffer.length;
|
|
173
|
+
const _cb = cb;
|
|
174
|
+
promises
|
|
175
|
+
.write(fd, buffer, offset, length, position)
|
|
176
|
+
.then(bytesWritten => _cb(null, bytesWritten, buffer.toString(encoding)))
|
|
177
|
+
.catch(_cb);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
// Signature 2: (fd, buffer, offset, length, position?, cb?)
|
|
181
|
+
buffer = arg2;
|
|
182
|
+
offset = arg3;
|
|
183
|
+
length = arg4;
|
|
184
|
+
position = typeof arg5 === 'number' ? arg5 : null;
|
|
185
|
+
const _cb = (typeof arg5 === 'function' ? arg5 : cb);
|
|
186
|
+
promises
|
|
187
|
+
.write(fd, buffer, offset, length, position)
|
|
188
|
+
.then(bytesWritten => _cb(null, bytesWritten, buffer))
|
|
189
|
+
.catch(_cb);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Read data from the file specified by `fd`.
|
|
194
|
+
* @param buffer The buffer that the data will be
|
|
195
|
+
* written to.
|
|
196
|
+
* @param offset The offset within the buffer where writing will
|
|
197
|
+
* start.
|
|
198
|
+
* @param length An integer specifying the number of bytes to read.
|
|
199
|
+
* @param position An integer specifying where to begin reading from
|
|
200
|
+
* in the file. If position is null, data will be read from the current file
|
|
201
|
+
* position.
|
|
202
|
+
* @param callback The number is the number of bytes read
|
|
203
|
+
*/
|
|
204
|
+
export function read(fd, buffer, offset, length, position, cb = nop) {
|
|
205
|
+
promises
|
|
206
|
+
.read(fd, buffer, offset, length, position)
|
|
207
|
+
.then(({ bytesRead, buffer }) => cb(null, bytesRead, buffer))
|
|
208
|
+
.catch(cb);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Asynchronous `fchown`.
|
|
212
|
+
* @param fd
|
|
213
|
+
* @param uid
|
|
214
|
+
* @param gid
|
|
215
|
+
* @param callback
|
|
216
|
+
*/
|
|
217
|
+
export function fchown(fd, uid, gid, cb = nop) {
|
|
218
|
+
promises
|
|
219
|
+
.fchown(fd, uid, gid)
|
|
220
|
+
.then(() => cb())
|
|
221
|
+
.catch(cb);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Asynchronous `fchmod`.
|
|
225
|
+
* @param fd
|
|
226
|
+
* @param mode
|
|
227
|
+
* @param callback
|
|
228
|
+
*/
|
|
229
|
+
export function fchmod(fd, mode, cb) {
|
|
230
|
+
promises
|
|
231
|
+
.fchmod(fd, mode)
|
|
232
|
+
.then(() => cb())
|
|
233
|
+
.catch(cb);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Change the file timestamps of a file referenced by the supplied file
|
|
237
|
+
* descriptor.
|
|
238
|
+
* @param fd
|
|
239
|
+
* @param atime
|
|
240
|
+
* @param mtime
|
|
241
|
+
* @param callback
|
|
242
|
+
*/
|
|
243
|
+
export function futimes(fd, atime, mtime, cb = nop) {
|
|
244
|
+
promises
|
|
245
|
+
.futimes(fd, atime, mtime)
|
|
246
|
+
.then(() => cb())
|
|
247
|
+
.catch(cb);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Asynchronous `rmdir`.
|
|
251
|
+
* @param path
|
|
252
|
+
* @param callback
|
|
253
|
+
*/
|
|
254
|
+
export function rmdir(path, cb = nop) {
|
|
255
|
+
promises
|
|
256
|
+
.rmdir(path)
|
|
257
|
+
.then(() => cb())
|
|
258
|
+
.catch(cb);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Asynchronous `mkdir`.
|
|
262
|
+
* @param path
|
|
263
|
+
* @param mode defaults to `0777`
|
|
264
|
+
* @param callback
|
|
265
|
+
*/
|
|
266
|
+
export function mkdir(path, mode, cb = nop) {
|
|
267
|
+
promises
|
|
268
|
+
.mkdir(path, mode)
|
|
269
|
+
.then(() => cb())
|
|
270
|
+
.catch(cb);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Asynchronous `readdir`. Reads the contents of a directory.
|
|
274
|
+
* The callback gets two arguments `(err, files)` where `files` is an array of
|
|
275
|
+
* the names of the files in the directory excluding `'.'` and `'..'`.
|
|
276
|
+
* @param path
|
|
277
|
+
* @param callback
|
|
278
|
+
*/
|
|
279
|
+
export function readdir(path, cb = nop) {
|
|
280
|
+
promises
|
|
281
|
+
.readdir(path)
|
|
282
|
+
.then(entries => cb(null, entries))
|
|
283
|
+
.catch(cb);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Asynchronous `link`.
|
|
287
|
+
* @param srcpath
|
|
288
|
+
* @param dstpath
|
|
289
|
+
* @param callback
|
|
290
|
+
*/
|
|
291
|
+
export function link(srcpath, dstpath, cb = nop) {
|
|
292
|
+
promises
|
|
293
|
+
.link(srcpath, dstpath)
|
|
294
|
+
.then(() => cb())
|
|
295
|
+
.catch(cb);
|
|
296
|
+
}
|
|
297
|
+
export function symlink(srcpath, dstpath, arg3, cb = nop) {
|
|
298
|
+
const type = typeof arg3 === 'string' ? arg3 : 'file';
|
|
299
|
+
cb = typeof arg3 === 'function' ? arg3 : cb;
|
|
300
|
+
promises
|
|
301
|
+
.symlink(srcpath, dstpath, typeof arg3 === 'function' ? null : arg3)
|
|
302
|
+
.then(() => cb())
|
|
303
|
+
.catch(cb);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Asynchronous readlink.
|
|
307
|
+
* @param path
|
|
308
|
+
* @param callback
|
|
309
|
+
*/
|
|
310
|
+
export function readlink(path, cb = nop) {
|
|
311
|
+
promises
|
|
312
|
+
.readlink(path)
|
|
313
|
+
.then(result => cb(null, result))
|
|
314
|
+
.catch(cb);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Asynchronous `chown`.
|
|
318
|
+
* @param path
|
|
319
|
+
* @param uid
|
|
320
|
+
* @param gid
|
|
321
|
+
* @param callback
|
|
322
|
+
*/
|
|
323
|
+
export function chown(path, uid, gid, cb = nop) {
|
|
324
|
+
promises
|
|
325
|
+
.chown(path, uid, gid)
|
|
326
|
+
.then(() => cb())
|
|
327
|
+
.catch(cb);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Asynchronous `lchown`.
|
|
331
|
+
* @param path
|
|
332
|
+
* @param uid
|
|
333
|
+
* @param gid
|
|
334
|
+
* @param callback
|
|
335
|
+
*/
|
|
336
|
+
export function lchown(path, uid, gid, cb = nop) {
|
|
337
|
+
promises
|
|
338
|
+
.lchown(path, uid, gid)
|
|
339
|
+
.then(() => cb())
|
|
340
|
+
.catch(cb);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Asynchronous `chmod`.
|
|
344
|
+
* @param path
|
|
345
|
+
* @param mode
|
|
346
|
+
* @param callback
|
|
347
|
+
*/
|
|
348
|
+
export function chmod(path, mode, cb = nop) {
|
|
349
|
+
promises
|
|
350
|
+
.chmod(path, mode)
|
|
351
|
+
.then(() => cb())
|
|
352
|
+
.catch(cb);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Asynchronous `lchmod`.
|
|
356
|
+
* @param path
|
|
357
|
+
* @param mode
|
|
358
|
+
* @param callback
|
|
359
|
+
*/
|
|
360
|
+
export function lchmod(path, mode, cb = nop) {
|
|
361
|
+
promises
|
|
362
|
+
.lchmod(path, mode)
|
|
363
|
+
.then(() => cb())
|
|
364
|
+
.catch(cb);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Change file timestamps of the file referenced by the supplied path.
|
|
368
|
+
* @param path
|
|
369
|
+
* @param atime
|
|
370
|
+
* @param mtime
|
|
371
|
+
* @param callback
|
|
372
|
+
*/
|
|
373
|
+
export function utimes(path, atime, mtime, cb = nop) {
|
|
374
|
+
promises
|
|
375
|
+
.utimes(path, atime, mtime)
|
|
376
|
+
.then(() => cb())
|
|
377
|
+
.catch(cb);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Change file timestamps of the file referenced by the supplied path.
|
|
381
|
+
* @param path
|
|
382
|
+
* @param atime
|
|
383
|
+
* @param mtime
|
|
384
|
+
* @param callback
|
|
385
|
+
*/
|
|
386
|
+
export function lutimes(path, atime, mtime, cb = nop) {
|
|
387
|
+
promises
|
|
388
|
+
.lutimes(path, atime, mtime)
|
|
389
|
+
.then(() => cb())
|
|
390
|
+
.catch(cb);
|
|
391
|
+
}
|
|
392
|
+
export function realpath(path, arg2, cb = nop) {
|
|
393
|
+
const cache = typeof arg2 === 'object' ? arg2 : {};
|
|
394
|
+
cb = typeof arg2 === 'function' ? arg2 : cb;
|
|
395
|
+
promises
|
|
396
|
+
.realpath(path, typeof arg2 === 'function' ? null : arg2)
|
|
397
|
+
.then(result => cb(null, result))
|
|
398
|
+
.catch(cb);
|
|
399
|
+
}
|
|
400
|
+
export function access(path, arg2, cb = nop) {
|
|
401
|
+
const mode = typeof arg2 === 'number' ? arg2 : R_OK;
|
|
402
|
+
cb = typeof arg2 === 'function' ? arg2 : cb;
|
|
403
|
+
promises
|
|
404
|
+
.access(path, typeof arg2 === 'function' ? null : arg2)
|
|
405
|
+
.then(() => cb())
|
|
406
|
+
.catch(cb);
|
|
407
|
+
}
|
|
408
|
+
export function watchFile(filename, arg2, listener = nop) {
|
|
409
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
410
|
+
}
|
|
411
|
+
export function unwatchFile(filename, listener = nop) {
|
|
412
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
413
|
+
}
|
|
414
|
+
export function watch(filename, arg2, listener = nop) {
|
|
415
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
416
|
+
}
|
|
417
|
+
export function createReadStream(path, options) {
|
|
418
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
419
|
+
}
|
|
420
|
+
export function createWriteStream(path, options) {
|
|
421
|
+
throw new ApiError(ErrorCode.ENOTSUP);
|
|
422
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** Constant for fs.access(). File is visible to the calling process. */
|
|
2
|
+
export declare const F_OK = 0;
|
|
3
|
+
/** Constant for fs.access(). File can be read by the calling process. */
|
|
4
|
+
export declare const R_OK = 4;
|
|
5
|
+
/** Constant for fs.access(). File can be written by the calling process. */
|
|
6
|
+
export declare const W_OK = 2;
|
|
7
|
+
/** Constant for fs.access(). File can be executed by the calling process. */
|
|
8
|
+
export declare const X_OK = 1;
|
|
9
|
+
/** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */
|
|
10
|
+
export declare const COPYFILE_EXCL = 1;
|
|
11
|
+
/**
|
|
12
|
+
* Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
|
|
13
|
+
* If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
|
|
14
|
+
*/
|
|
15
|
+
export declare const COPYFILE_FICLONE = 2;
|
|
16
|
+
/**
|
|
17
|
+
* Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
|
|
18
|
+
* If the underlying platform does not support copy-on-write, then the operation will fail with an error.
|
|
19
|
+
*/
|
|
20
|
+
export declare const COPYFILE_FICLONE_FORCE = 4;
|
|
21
|
+
/** Constant for fs.open(). Flag indicating to open a file for read-only access. */
|
|
22
|
+
export declare const O_RDONLY = 0;
|
|
23
|
+
/** Constant for fs.open(). Flag indicating to open a file for write-only access. */
|
|
24
|
+
export declare const O_WRONLY = 1;
|
|
25
|
+
/** Constant for fs.open(). Flag indicating to open a file for read-write access. */
|
|
26
|
+
export declare const O_RDWR = 2;
|
|
27
|
+
/** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */
|
|
28
|
+
export declare const O_CREAT = 64;
|
|
29
|
+
/** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */
|
|
30
|
+
export declare const O_EXCL = 128;
|
|
31
|
+
/**
|
|
32
|
+
* Constant for fs.open(). Flag indicating that if path identifies a terminal device,
|
|
33
|
+
* opening the path shall not cause that terminal to become the controlling terminal for the process
|
|
34
|
+
* (if the process does not already have one).
|
|
35
|
+
*/
|
|
36
|
+
export declare const O_NOCTTY = 256;
|
|
37
|
+
/** 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. */
|
|
38
|
+
export declare const O_TRUNC = 512;
|
|
39
|
+
/** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */
|
|
40
|
+
export declare const O_APPEND = 1024;
|
|
41
|
+
/** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */
|
|
42
|
+
export declare const O_DIRECTORY = 65536;
|
|
43
|
+
/**
|
|
44
|
+
* constant for fs.open().
|
|
45
|
+
* Flag indicating reading accesses to the file system will no longer result in
|
|
46
|
+
* an update to the atime information associated with the file.
|
|
47
|
+
* This flag is available on Linux operating systems only.
|
|
48
|
+
*/
|
|
49
|
+
export declare const O_NOATIME = 262144;
|
|
50
|
+
/** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */
|
|
51
|
+
export declare const O_NOFOLLOW = 131072;
|
|
52
|
+
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */
|
|
53
|
+
export declare const O_SYNC = 1052672;
|
|
54
|
+
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */
|
|
55
|
+
export declare const O_DSYNC = 4096;
|
|
56
|
+
/** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */
|
|
57
|
+
export declare const O_SYMLINK = 32768;
|
|
58
|
+
/** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */
|
|
59
|
+
export declare const O_DIRECT = 16384;
|
|
60
|
+
/** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */
|
|
61
|
+
export declare const O_NONBLOCK = 2048;
|
|
62
|
+
/** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
|
|
63
|
+
export declare const S_IFMT = 61440;
|
|
64
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
|
|
65
|
+
export declare const S_IFREG = 32768;
|
|
66
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */
|
|
67
|
+
export declare const S_IFDIR = 16384;
|
|
68
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */
|
|
69
|
+
export declare const S_IFCHR = 8192;
|
|
70
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */
|
|
71
|
+
export declare const S_IFBLK = 24576;
|
|
72
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */
|
|
73
|
+
export declare const S_IFIFO = 4096;
|
|
74
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */
|
|
75
|
+
export declare const S_IFLNK = 40960;
|
|
76
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */
|
|
77
|
+
export declare const S_IFSOCK = 49152;
|
|
78
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */
|
|
79
|
+
export declare const S_IRWXU = 448;
|
|
80
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */
|
|
81
|
+
export declare const S_IRUSR = 256;
|
|
82
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */
|
|
83
|
+
export declare const S_IWUSR = 128;
|
|
84
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */
|
|
85
|
+
export declare const S_IXUSR = 64;
|
|
86
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */
|
|
87
|
+
export declare const S_IRWXG = 56;
|
|
88
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */
|
|
89
|
+
export declare const S_IRGRP = 32;
|
|
90
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */
|
|
91
|
+
export declare const S_IWGRP = 16;
|
|
92
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */
|
|
93
|
+
export declare const S_IXGRP = 8;
|
|
94
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */
|
|
95
|
+
export declare const S_IRWXO = 7;
|
|
96
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */
|
|
97
|
+
export declare const S_IROTH = 4;
|
|
98
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */
|
|
99
|
+
export declare const S_IWOTH = 2;
|
|
100
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
|
|
101
|
+
export declare const S_IXOTH = 1;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*
|
|
2
|
+
FS Constants
|
|
3
|
+
See https://nodejs.org/api/fs.html#file-access-constants
|
|
4
|
+
*/
|
|
5
|
+
// File Access Constants
|
|
6
|
+
/** Constant for fs.access(). File is visible to the calling process. */
|
|
7
|
+
export const F_OK = 0;
|
|
8
|
+
/** Constant for fs.access(). File can be read by the calling process. */
|
|
9
|
+
export const R_OK = 4;
|
|
10
|
+
/** Constant for fs.access(). File can be written by the calling process. */
|
|
11
|
+
export const W_OK = 2;
|
|
12
|
+
/** Constant for fs.access(). File can be executed by the calling process. */
|
|
13
|
+
export const X_OK = 1;
|
|
14
|
+
// File Copy Constants
|
|
15
|
+
/** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */
|
|
16
|
+
export const COPYFILE_EXCL = 1;
|
|
17
|
+
/**
|
|
18
|
+
* Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
|
|
19
|
+
* If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.
|
|
20
|
+
*/
|
|
21
|
+
export const COPYFILE_FICLONE = 2;
|
|
22
|
+
/**
|
|
23
|
+
* Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.
|
|
24
|
+
* If the underlying platform does not support copy-on-write, then the operation will fail with an error.
|
|
25
|
+
*/
|
|
26
|
+
export const COPYFILE_FICLONE_FORCE = 4;
|
|
27
|
+
// File Open Constants
|
|
28
|
+
/** Constant for fs.open(). Flag indicating to open a file for read-only access. */
|
|
29
|
+
export const O_RDONLY = 0;
|
|
30
|
+
/** Constant for fs.open(). Flag indicating to open a file for write-only access. */
|
|
31
|
+
export const O_WRONLY = 1;
|
|
32
|
+
/** Constant for fs.open(). Flag indicating to open a file for read-write access. */
|
|
33
|
+
export const O_RDWR = 2;
|
|
34
|
+
/** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */
|
|
35
|
+
export const O_CREAT = 0o100; // Node internal is
|
|
36
|
+
/** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */
|
|
37
|
+
export const O_EXCL = 0o200;
|
|
38
|
+
/**
|
|
39
|
+
* Constant for fs.open(). Flag indicating that if path identifies a terminal device,
|
|
40
|
+
* opening the path shall not cause that terminal to become the controlling terminal for the process
|
|
41
|
+
* (if the process does not already have one).
|
|
42
|
+
*/
|
|
43
|
+
export const O_NOCTTY = 0o400;
|
|
44
|
+
/** 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. */
|
|
45
|
+
export const O_TRUNC = 0o1000;
|
|
46
|
+
/** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */
|
|
47
|
+
export const O_APPEND = 0o2000;
|
|
48
|
+
/** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */
|
|
49
|
+
export const O_DIRECTORY = 0o200000;
|
|
50
|
+
/**
|
|
51
|
+
* constant for fs.open().
|
|
52
|
+
* Flag indicating reading accesses to the file system will no longer result in
|
|
53
|
+
* an update to the atime information associated with the file.
|
|
54
|
+
* This flag is available on Linux operating systems only.
|
|
55
|
+
*/
|
|
56
|
+
export const O_NOATIME = 0o1000000;
|
|
57
|
+
/** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */
|
|
58
|
+
export const O_NOFOLLOW = 0o400000;
|
|
59
|
+
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */
|
|
60
|
+
export const O_SYNC = 0o4010000;
|
|
61
|
+
/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */
|
|
62
|
+
export const O_DSYNC = 0o10000;
|
|
63
|
+
/** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */
|
|
64
|
+
export const O_SYMLINK = 0o100000;
|
|
65
|
+
/** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */
|
|
66
|
+
export const O_DIRECT = 0o40000;
|
|
67
|
+
/** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */
|
|
68
|
+
export const O_NONBLOCK = 0o4000;
|
|
69
|
+
// File Type Constants
|
|
70
|
+
/** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */
|
|
71
|
+
export const S_IFMT = 0o170000;
|
|
72
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */
|
|
73
|
+
export const S_IFREG = 0o100000;
|
|
74
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */
|
|
75
|
+
export const S_IFDIR = 0o40000;
|
|
76
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */
|
|
77
|
+
export const S_IFCHR = 0o20000;
|
|
78
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */
|
|
79
|
+
export const S_IFBLK = 0o60000;
|
|
80
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */
|
|
81
|
+
export const S_IFIFO = 0o10000;
|
|
82
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */
|
|
83
|
+
export const S_IFLNK = 0o120000;
|
|
84
|
+
/** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */
|
|
85
|
+
export const S_IFSOCK = 0o140000;
|
|
86
|
+
// File Mode Constants
|
|
87
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */
|
|
88
|
+
export const S_IRWXU = 0o700;
|
|
89
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */
|
|
90
|
+
export const S_IRUSR = 0o400;
|
|
91
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */
|
|
92
|
+
export const S_IWUSR = 0o200;
|
|
93
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */
|
|
94
|
+
export const S_IXUSR = 0o100;
|
|
95
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */
|
|
96
|
+
export const S_IRWXG = 0o70;
|
|
97
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */
|
|
98
|
+
export const S_IRGRP = 0o40;
|
|
99
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */
|
|
100
|
+
export const S_IWGRP = 0o20;
|
|
101
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */
|
|
102
|
+
export const S_IXGRP = 0o10;
|
|
103
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */
|
|
104
|
+
export const S_IRWXO = 7;
|
|
105
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */
|
|
106
|
+
export const S_IROTH = 4;
|
|
107
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */
|
|
108
|
+
export const S_IWOTH = 2;
|
|
109
|
+
/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
|
|
110
|
+
export const S_IXOTH = 1;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './callbacks';
|
|
2
|
+
export * from './sync';
|
|
3
|
+
import * as promises_1 from './promises';
|
|
4
|
+
export { promises_1 as promises };
|
|
5
|
+
import * as constants_1 from './constants';
|
|
6
|
+
export { constants_1 as constants };
|
|
7
|
+
export { initialize, getMount, getMounts, mount, umount, _toUnixTimestamp } from './shared';
|