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