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