@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
package/dist/file.d.ts
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Stats } from './stats';
|
|
3
|
+
import { FileSystem } from './filesystem';
|
|
4
|
+
export declare enum ActionType {
|
|
5
|
+
NOP = 0,
|
|
6
|
+
THROW_EXCEPTION = 1,
|
|
7
|
+
TRUNCATE_FILE = 2,
|
|
8
|
+
CREATE_FILE = 3
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Represents one of the following file flags. A convenience object.
|
|
12
|
+
*
|
|
13
|
+
* * `'r'` - Open file for reading. An exception occurs if the file does not exist.
|
|
14
|
+
* * `'r+'` - Open file for reading and writing. An exception occurs if the file does not exist.
|
|
15
|
+
* * `'rs'` - Open file for reading in synchronous mode. Instructs the filesystem to not cache writes.
|
|
16
|
+
* * `'rs+'` - Open file for reading and writing, and opens the file in synchronous mode.
|
|
17
|
+
* * `'w'` - Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
|
|
18
|
+
* * `'wx'` - Like 'w' but opens the file in exclusive mode.
|
|
19
|
+
* * `'w+'` - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
|
|
20
|
+
* * `'wx+'` - Like 'w+' but opens the file in exclusive mode.
|
|
21
|
+
* * `'a'` - Open file for appending. The file is created if it does not exist.
|
|
22
|
+
* * `'ax'` - Like 'a' but opens the file in exclusive mode.
|
|
23
|
+
* * `'a+'` - Open file for reading and appending. The file is created if it does not exist.
|
|
24
|
+
* * `'ax+'` - Like 'a+' but opens the file in exclusive mode.
|
|
25
|
+
*
|
|
26
|
+
* Exclusive mode ensures that the file path is newly created.
|
|
27
|
+
*/
|
|
28
|
+
export declare class FileFlag {
|
|
29
|
+
private static flagCache;
|
|
30
|
+
private static validFlagStrs;
|
|
31
|
+
/**
|
|
32
|
+
* Get an object representing the given file flag.
|
|
33
|
+
* @param modeStr The string representing the flag
|
|
34
|
+
* @return The FileFlag object representing the flag
|
|
35
|
+
* @throw when the flag string is invalid
|
|
36
|
+
*/
|
|
37
|
+
static getFileFlag(flagStr: string): FileFlag;
|
|
38
|
+
private flagStr;
|
|
39
|
+
/**
|
|
40
|
+
* This should never be called directly.
|
|
41
|
+
* @param modeStr The string representing the mode
|
|
42
|
+
* @throw when the mode string is invalid
|
|
43
|
+
*/
|
|
44
|
+
constructor(flagStr: string);
|
|
45
|
+
/**
|
|
46
|
+
* Get the underlying flag string for this flag.
|
|
47
|
+
*/
|
|
48
|
+
getFlagString(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Get the equivalent mode (0b0xxx: read, write, execute)
|
|
51
|
+
* Note: Execute will always be 0
|
|
52
|
+
*/
|
|
53
|
+
getMode(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Returns true if the file is readable.
|
|
56
|
+
*/
|
|
57
|
+
isReadable(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Returns true if the file is writeable.
|
|
60
|
+
*/
|
|
61
|
+
isWriteable(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Returns true if the file mode should truncate.
|
|
64
|
+
*/
|
|
65
|
+
isTruncating(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Returns true if the file is appendable.
|
|
68
|
+
*/
|
|
69
|
+
isAppendable(): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Returns true if the file is open in synchronous mode.
|
|
72
|
+
*/
|
|
73
|
+
isSynchronous(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Returns true if the file is open in exclusive mode.
|
|
76
|
+
*/
|
|
77
|
+
isExclusive(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Returns one of the static fields on this object that indicates the
|
|
80
|
+
* appropriate response to the path existing.
|
|
81
|
+
*/
|
|
82
|
+
pathExistsAction(): ActionType;
|
|
83
|
+
/**
|
|
84
|
+
* Returns one of the static fields on this object that indicates the
|
|
85
|
+
* appropriate response to the path not existing.
|
|
86
|
+
*/
|
|
87
|
+
pathNotExistsAction(): ActionType;
|
|
88
|
+
}
|
|
89
|
+
export interface File {
|
|
90
|
+
/**
|
|
91
|
+
* **Core**: Get the current file position.
|
|
92
|
+
*/
|
|
93
|
+
getPos(): number | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* **Core**: Asynchronous `stat`.
|
|
96
|
+
*/
|
|
97
|
+
stat(): Promise<Stats>;
|
|
98
|
+
/**
|
|
99
|
+
* **Core**: Synchronous `stat`.
|
|
100
|
+
*/
|
|
101
|
+
statSync(): Stats;
|
|
102
|
+
/**
|
|
103
|
+
* **Core**: Asynchronous close.
|
|
104
|
+
*/
|
|
105
|
+
close(): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* **Core**: Synchronous close.
|
|
108
|
+
*/
|
|
109
|
+
closeSync(): void;
|
|
110
|
+
/**
|
|
111
|
+
* **Core**: Asynchronous truncate.
|
|
112
|
+
*/
|
|
113
|
+
truncate(len: number): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* **Core**: Synchronous truncate.
|
|
116
|
+
*/
|
|
117
|
+
truncateSync(len: number): void;
|
|
118
|
+
/**
|
|
119
|
+
* **Core**: Asynchronous sync.
|
|
120
|
+
*/
|
|
121
|
+
sync(): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* **Core**: Synchronous sync.
|
|
124
|
+
*/
|
|
125
|
+
syncSync(): void;
|
|
126
|
+
/**
|
|
127
|
+
* **Core**: Write buffer to the file.
|
|
128
|
+
* Note that it is unsafe to use fs.write multiple times on the same file
|
|
129
|
+
* without waiting for the callback.
|
|
130
|
+
* @param buffer Buffer containing the data to write to
|
|
131
|
+
* the file.
|
|
132
|
+
* @param offset Offset in the buffer to start reading data from.
|
|
133
|
+
* @param length The amount of bytes to write to the file.
|
|
134
|
+
* @param position Offset from the beginning of the file where this
|
|
135
|
+
* data should be written. If position is null, the data will be written at
|
|
136
|
+
* the current position.
|
|
137
|
+
* @returns Promise resolving to the new length of the buffer
|
|
138
|
+
*/
|
|
139
|
+
write(buffer: Buffer, offset: number, length: number, position: number | null): Promise<number>;
|
|
140
|
+
/**
|
|
141
|
+
* **Core**: Write buffer to the file.
|
|
142
|
+
* Note that it is unsafe to use fs.writeSync multiple times on the same file
|
|
143
|
+
* without waiting for it to return.
|
|
144
|
+
* @param buffer Buffer containing the data to write to
|
|
145
|
+
* the file.
|
|
146
|
+
* @param offset Offset in the buffer to start reading data from.
|
|
147
|
+
* @param length The amount of bytes to write to the file.
|
|
148
|
+
* @param position Offset from the beginning of the file where this
|
|
149
|
+
* data should be written. If position is null, the data will be written at
|
|
150
|
+
* the current position.
|
|
151
|
+
*/
|
|
152
|
+
writeSync(buffer: Buffer, offset: number, length: number, position: number | null): number;
|
|
153
|
+
/**
|
|
154
|
+
* **Core**: Read data from the file.
|
|
155
|
+
* @param buffer The buffer that the data will be
|
|
156
|
+
* written to.
|
|
157
|
+
* @param offset The offset within the buffer where writing will
|
|
158
|
+
* start.
|
|
159
|
+
* @param length An integer specifying the number of bytes to read.
|
|
160
|
+
* @param position An integer specifying where to begin reading from
|
|
161
|
+
* in the file. If position is null, data will be read from the current file
|
|
162
|
+
* position.
|
|
163
|
+
* @returns Promise resolving to the new length of the buffer
|
|
164
|
+
*/
|
|
165
|
+
read(buffer: Buffer, offset: number, length: number, position: number | null): Promise<{
|
|
166
|
+
bytesRead: number;
|
|
167
|
+
buffer: Buffer;
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* **Core**: Read data from the file.
|
|
171
|
+
* @param buffer The buffer that the data will be written to.
|
|
172
|
+
* @param offset The offset within the buffer where writing will start.
|
|
173
|
+
* @param length An integer specifying the number of bytes to read.
|
|
174
|
+
* @param position An integer specifying where to begin reading from
|
|
175
|
+
* in the file. If position is null, data will be read from the current file
|
|
176
|
+
* position.
|
|
177
|
+
*/
|
|
178
|
+
readSync(buffer: Buffer, offset: number, length: number, position: number): number;
|
|
179
|
+
/**
|
|
180
|
+
* **Supplementary**: Asynchronous `datasync`.
|
|
181
|
+
*
|
|
182
|
+
* Default implementation maps to `sync`.
|
|
183
|
+
*/
|
|
184
|
+
datasync(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* **Supplementary**: Synchronous `datasync`.
|
|
187
|
+
*
|
|
188
|
+
* Default implementation maps to `syncSync`.
|
|
189
|
+
*/
|
|
190
|
+
datasyncSync(): void;
|
|
191
|
+
/**
|
|
192
|
+
* **Optional**: Asynchronous `chown`.
|
|
193
|
+
*/
|
|
194
|
+
chown(uid: number, gid: number): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* **Optional**: Synchronous `chown`.
|
|
197
|
+
*/
|
|
198
|
+
chownSync(uid: number, gid: number): void;
|
|
199
|
+
/**
|
|
200
|
+
* **Optional**: Asynchronous `fchmod`.
|
|
201
|
+
*/
|
|
202
|
+
chmod(mode: number): Promise<void>;
|
|
203
|
+
/**
|
|
204
|
+
* **Optional**: Synchronous `fchmod`.
|
|
205
|
+
*/
|
|
206
|
+
chmodSync(mode: number): void;
|
|
207
|
+
/**
|
|
208
|
+
* **Optional**: Change the file timestamps of the file.
|
|
209
|
+
*/
|
|
210
|
+
utimes(atime: Date, mtime: Date): Promise<void>;
|
|
211
|
+
/**
|
|
212
|
+
* **Optional**: Change the file timestamps of the file.
|
|
213
|
+
*/
|
|
214
|
+
utimesSync(atime: Date, mtime: Date): void;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Base class that contains shared implementations of functions for the file
|
|
218
|
+
* object.
|
|
219
|
+
*/
|
|
220
|
+
export declare class BaseFile {
|
|
221
|
+
sync(): Promise<void>;
|
|
222
|
+
syncSync(): void;
|
|
223
|
+
datasync(): Promise<void>;
|
|
224
|
+
datasyncSync(): void;
|
|
225
|
+
chown(uid: number, gid: number): Promise<void>;
|
|
226
|
+
chownSync(uid: number, gid: number): void;
|
|
227
|
+
chmod(mode: number): Promise<void>;
|
|
228
|
+
chmodSync(mode: number): void;
|
|
229
|
+
utimes(atime: Date, mtime: Date): Promise<void>;
|
|
230
|
+
utimesSync(atime: Date, mtime: Date): void;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* An implementation of the File interface that operates on a file that is
|
|
234
|
+
* completely in-memory. PreloadFiles are backed by a Buffer.
|
|
235
|
+
*
|
|
236
|
+
* This is also an abstract class, as it lacks an implementation of 'sync' and
|
|
237
|
+
* 'close'. Each filesystem that wishes to use this file representation must
|
|
238
|
+
* extend this class and implement those two methods.
|
|
239
|
+
* @todo 'close' lever that disables functionality once closed.
|
|
240
|
+
*/
|
|
241
|
+
export declare class PreloadFile<T extends FileSystem> extends BaseFile {
|
|
242
|
+
protected _fs: T;
|
|
243
|
+
protected _pos: number;
|
|
244
|
+
protected _path: string;
|
|
245
|
+
protected _stat: Stats;
|
|
246
|
+
protected _flag: FileFlag;
|
|
247
|
+
protected _buffer: Buffer;
|
|
248
|
+
protected _dirty: boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Creates a file with the given path and, optionally, the given contents. Note
|
|
251
|
+
* that, if contents is specified, it will be mutated by the file!
|
|
252
|
+
* @param _fs The file system that created the file.
|
|
253
|
+
* @param _path
|
|
254
|
+
* @param _mode The mode that the file was opened using.
|
|
255
|
+
* Dictates permissions and where the file pointer starts.
|
|
256
|
+
* @param _stat The stats object for the given file.
|
|
257
|
+
* PreloadFile will mutate this object. Note that this object must contain
|
|
258
|
+
* the appropriate mode that the file was opened as.
|
|
259
|
+
* @param contents A buffer containing the entire
|
|
260
|
+
* contents of the file. PreloadFile will mutate this buffer. If not
|
|
261
|
+
* specified, we assume it is a new file.
|
|
262
|
+
*/
|
|
263
|
+
constructor(_fs: T, _path: string, _flag: FileFlag, _stat: Stats, contents?: Buffer);
|
|
264
|
+
/**
|
|
265
|
+
* NONSTANDARD: Get the underlying buffer for this file. !!DO NOT MUTATE!! Will mess up dirty tracking.
|
|
266
|
+
*/
|
|
267
|
+
getBuffer(): Buffer;
|
|
268
|
+
/**
|
|
269
|
+
* NONSTANDARD: Get underlying stats for this file. !!DO NOT MUTATE!!
|
|
270
|
+
*/
|
|
271
|
+
getStats(): Stats;
|
|
272
|
+
getFlag(): FileFlag;
|
|
273
|
+
/**
|
|
274
|
+
* Get the path to this file.
|
|
275
|
+
* @return [String] The path to the file.
|
|
276
|
+
*/
|
|
277
|
+
getPath(): string;
|
|
278
|
+
/**
|
|
279
|
+
* Get the current file position.
|
|
280
|
+
*
|
|
281
|
+
* We emulate the following bug mentioned in the Node documentation:
|
|
282
|
+
* > On Linux, positional writes don't work when the file is opened in append
|
|
283
|
+
* mode. The kernel ignores the position argument and always appends the data
|
|
284
|
+
* to the end of the file.
|
|
285
|
+
* @return [Number] The current file position.
|
|
286
|
+
*/
|
|
287
|
+
getPos(): number;
|
|
288
|
+
/**
|
|
289
|
+
* Advance the current file position by the indicated number of positions.
|
|
290
|
+
* @param [Number] delta
|
|
291
|
+
*/
|
|
292
|
+
advancePos(delta: number): number;
|
|
293
|
+
/**
|
|
294
|
+
* Set the file position.
|
|
295
|
+
* @param [Number] newPos
|
|
296
|
+
*/
|
|
297
|
+
setPos(newPos: number): number;
|
|
298
|
+
/**
|
|
299
|
+
* **Core**: Asynchronous sync. Must be implemented by subclasses of this
|
|
300
|
+
* class.
|
|
301
|
+
* @param [Function(ZenFS.ApiError)] cb
|
|
302
|
+
*/
|
|
303
|
+
sync(): Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* **Core**: Synchronous sync.
|
|
306
|
+
*/
|
|
307
|
+
syncSync(): void;
|
|
308
|
+
/**
|
|
309
|
+
* **Core**: Asynchronous close. Must be implemented by subclasses of this
|
|
310
|
+
* class.
|
|
311
|
+
* @param [Function(ZenFS.ApiError)] cb
|
|
312
|
+
*/
|
|
313
|
+
close(): Promise<void>;
|
|
314
|
+
/**
|
|
315
|
+
* **Core**: Synchronous close.
|
|
316
|
+
*/
|
|
317
|
+
closeSync(): void;
|
|
318
|
+
/**
|
|
319
|
+
* Asynchronous `stat`.
|
|
320
|
+
* @param [Function(ZenFS.ApiError, ZenFS.node.fs.Stats)] cb
|
|
321
|
+
*/
|
|
322
|
+
stat(): Promise<Stats>;
|
|
323
|
+
/**
|
|
324
|
+
* Synchronous `stat`.
|
|
325
|
+
*/
|
|
326
|
+
statSync(): Stats;
|
|
327
|
+
/**
|
|
328
|
+
* Asynchronous truncate.
|
|
329
|
+
* @param [Number] len
|
|
330
|
+
* @param [Function(ZenFS.ApiError)] cb
|
|
331
|
+
*/
|
|
332
|
+
truncate(len: number): Promise<void>;
|
|
333
|
+
/**
|
|
334
|
+
* Synchronous truncate.
|
|
335
|
+
* @param [Number] len
|
|
336
|
+
*/
|
|
337
|
+
truncateSync(len: number): void;
|
|
338
|
+
/**
|
|
339
|
+
* Write buffer to the file.
|
|
340
|
+
* Note that it is unsafe to use fs.write multiple times on the same file
|
|
341
|
+
* without waiting for the callback.
|
|
342
|
+
* @param [ZenFS.node.Buffer] buffer Buffer containing the data to write to
|
|
343
|
+
* the file.
|
|
344
|
+
* @param [Number] offset Offset in the buffer to start reading data from.
|
|
345
|
+
* @param [Number] length The amount of bytes to write to the file.
|
|
346
|
+
* @param [Number] position Offset from the beginning of the file where this
|
|
347
|
+
* data should be written. If position is null, the data will be written at
|
|
348
|
+
* the current position.
|
|
349
|
+
* @param [Function(ZenFS.ApiError, Number, ZenFS.node.Buffer)]
|
|
350
|
+
* cb The number specifies the number of bytes written into the file.
|
|
351
|
+
*/
|
|
352
|
+
write(buffer: Buffer, offset: number, length: number, position: number): Promise<number>;
|
|
353
|
+
/**
|
|
354
|
+
* Write buffer to the file.
|
|
355
|
+
* Note that it is unsafe to use fs.writeSync multiple times on the same file
|
|
356
|
+
* without waiting for the callback.
|
|
357
|
+
* @param [ZenFS.node.Buffer] buffer Buffer containing the data to write to
|
|
358
|
+
* the file.
|
|
359
|
+
* @param [Number] offset Offset in the buffer to start reading data from.
|
|
360
|
+
* @param [Number] length The amount of bytes to write to the file.
|
|
361
|
+
* @param [Number] position Offset from the beginning of the file where this
|
|
362
|
+
* data should be written. If position is null, the data will be written at
|
|
363
|
+
* the current position.
|
|
364
|
+
* @return [Number]
|
|
365
|
+
*/
|
|
366
|
+
writeSync(buffer: Buffer, offset: number, length: number, position: number): number;
|
|
367
|
+
/**
|
|
368
|
+
* Read data from the file.
|
|
369
|
+
* @param [ZenFS.node.Buffer] buffer The buffer that the data will be
|
|
370
|
+
* written to.
|
|
371
|
+
* @param [Number] offset The offset within the buffer where writing will
|
|
372
|
+
* start.
|
|
373
|
+
* @param [Number] length An integer specifying the number of bytes to read.
|
|
374
|
+
* @param [Number] position An integer specifying where to begin reading from
|
|
375
|
+
* in the file. If position is null, data will be read from the current file
|
|
376
|
+
* position.
|
|
377
|
+
* @param [Function(ZenFS.ApiError, Number, ZenFS.node.Buffer)] cb The
|
|
378
|
+
* number is the number of bytes read
|
|
379
|
+
*/
|
|
380
|
+
read(buffer: Buffer, offset: number, length: number, position: number): Promise<{
|
|
381
|
+
bytesRead: number;
|
|
382
|
+
buffer: Buffer;
|
|
383
|
+
}>;
|
|
384
|
+
/**
|
|
385
|
+
* Read data from the file.
|
|
386
|
+
* @param [ZenFS.node.Buffer] buffer The buffer that the data will be
|
|
387
|
+
* written to.
|
|
388
|
+
* @param [Number] offset The offset within the buffer where writing will
|
|
389
|
+
* start.
|
|
390
|
+
* @param [Number] length An integer specifying the number of bytes to read.
|
|
391
|
+
* @param [Number] position An integer specifying where to begin reading from
|
|
392
|
+
* in the file. If position is null, data will be read from the current file
|
|
393
|
+
* position.
|
|
394
|
+
* @return [Number]
|
|
395
|
+
*/
|
|
396
|
+
readSync(buffer: Buffer, offset: number, length: number, position: number): number;
|
|
397
|
+
/**
|
|
398
|
+
* Asynchronous `fchmod`.
|
|
399
|
+
* @param [Number|String] mode
|
|
400
|
+
*/
|
|
401
|
+
chmod(mode: number): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* Synchronous `fchmod`.
|
|
404
|
+
* @param [Number] mode
|
|
405
|
+
*/
|
|
406
|
+
chmodSync(mode: number): void;
|
|
407
|
+
/**
|
|
408
|
+
* Asynchronous `fchown`.
|
|
409
|
+
* @param [Number] uid
|
|
410
|
+
* @param [Number] gid
|
|
411
|
+
*/
|
|
412
|
+
chown(uid: number, gid: number): Promise<void>;
|
|
413
|
+
/**
|
|
414
|
+
* Synchronous `fchown`.
|
|
415
|
+
* @param [Number] uid
|
|
416
|
+
* @param [Number] gid
|
|
417
|
+
*/
|
|
418
|
+
chownSync(uid: number, gid: number): void;
|
|
419
|
+
protected isDirty(): boolean;
|
|
420
|
+
/**
|
|
421
|
+
* Resets the dirty bit. Should only be called after a sync has completed successfully.
|
|
422
|
+
*/
|
|
423
|
+
protected resetDirty(): void;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* File class for the InMemory and XHR file systems.
|
|
427
|
+
* Doesn't sync to anything, so it works nicely for memory-only files.
|
|
428
|
+
*/
|
|
429
|
+
export declare class NoSyncFile<T extends FileSystem> extends PreloadFile<T> implements File {
|
|
430
|
+
constructor(_fs: T, _path: string, _flag: FileFlag, _stat: Stats, contents?: Buffer);
|
|
431
|
+
/**
|
|
432
|
+
* Asynchronous sync. Doesn't do anything, simply calls the cb.
|
|
433
|
+
* @param [Function(ZenFS.ApiError)] cb
|
|
434
|
+
*/
|
|
435
|
+
sync(): Promise<void>;
|
|
436
|
+
/**
|
|
437
|
+
* Synchronous sync. Doesn't do anything.
|
|
438
|
+
*/
|
|
439
|
+
syncSync(): void;
|
|
440
|
+
/**
|
|
441
|
+
* Asynchronous close. Doesn't do anything, simply calls the cb.
|
|
442
|
+
* @param [Function(ZenFS.ApiError)] cb
|
|
443
|
+
*/
|
|
444
|
+
close(): Promise<void>;
|
|
445
|
+
/**
|
|
446
|
+
* Synchronous close. Doesn't do anything.
|
|
447
|
+
*/
|
|
448
|
+
closeSync(): void;
|
|
449
|
+
}
|