@zenfs/core 0.11.2 → 0.12.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.
- package/dist/backends/fetch.d.ts +19 -32
- package/dist/backends/fetch.js +38 -85
- package/dist/backends/index/fs.d.ts +49 -0
- package/dist/backends/index/fs.js +86 -0
- package/dist/backends/index/index.d.ts +37 -0
- package/dist/backends/index/index.js +82 -0
- package/dist/browser.min.js +4 -4
- package/dist/browser.min.js.map +4 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/stats.d.ts +10 -10
- package/package.json +1 -1
- package/scripts/make-index.js +31 -19
- package/src/backends/fetch.ts +42 -101
- package/src/backends/index/fs.ts +113 -0
- package/src/backends/index/index.ts +98 -0
- package/src/backends/index/readme.md +3 -0
- package/src/file.ts +2 -2
- package/src/index.ts +1 -1
- package/src/stats.ts +10 -10
- package/dist/backends/Index.d.ts +0 -204
- package/dist/backends/Index.js +0 -410
- package/src/backends/Index.ts +0 -504
package/src/backends/Index.ts
DELETED
|
@@ -1,504 +0,0 @@
|
|
|
1
|
-
import { ErrnoError, Errno } from '../error.js';
|
|
2
|
-
import type { Cred } from '../cred.js';
|
|
3
|
-
import { basename, dirname, join } from '../emulation/path.js';
|
|
4
|
-
import { NoSyncFile, flagToMode, isWriteable } from '../file.js';
|
|
5
|
-
import { FileSystem, Readonly } from '../filesystem.js';
|
|
6
|
-
import { FileType, Stats } from '../stats.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export type ListingTree = { [key: string]: ListingTree | null };
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export interface ListingQueueNode<TData> {
|
|
17
|
-
pwd: string;
|
|
18
|
-
tree: ListingTree;
|
|
19
|
-
parent: IndexDirInode<TData>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* A simple class for storing a filesystem index. Assumes that all paths passed
|
|
24
|
-
* to it are *absolute* paths.
|
|
25
|
-
*
|
|
26
|
-
* Can be used as a partial or a full index, although care must be taken if used
|
|
27
|
-
* for the former purpose, especially when directories are concerned.
|
|
28
|
-
*
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export class FileIndex<TData> {
|
|
32
|
-
/**
|
|
33
|
-
* Static method for constructing indices from a JSON listing.
|
|
34
|
-
* @param listing Directory listing generated by tools
|
|
35
|
-
* @return A new FileIndex object.
|
|
36
|
-
*/
|
|
37
|
-
public static FromListing<T>(listing: ListingTree): FileIndex<T> {
|
|
38
|
-
const index = new FileIndex<T>();
|
|
39
|
-
// Add a root DirNode.
|
|
40
|
-
const rootInode = new IndexDirInode<T>();
|
|
41
|
-
index._index.set('/', rootInode);
|
|
42
|
-
const queue: ListingQueueNode<T | Stats>[] = [{ pwd: '', tree: listing, parent: rootInode }];
|
|
43
|
-
while (queue.length > 0) {
|
|
44
|
-
let inode: IndexFileInode<Stats> | IndexDirInode<T>;
|
|
45
|
-
const { tree, pwd, parent } = queue.pop()!;
|
|
46
|
-
for (const node in tree) {
|
|
47
|
-
if (!Object.hasOwn(tree, node)) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const children = tree[node];
|
|
51
|
-
|
|
52
|
-
if (children) {
|
|
53
|
-
const path = pwd + '/' + node;
|
|
54
|
-
inode = new IndexDirInode<T>();
|
|
55
|
-
index._index.set(path, inode);
|
|
56
|
-
queue.push({ pwd: path, tree: children, parent: inode });
|
|
57
|
-
} else {
|
|
58
|
-
// This inode doesn't have correct size information, noted with -1.
|
|
59
|
-
inode = new IndexFileInode<Stats>(new Stats({ mode: FileType.FILE | 0o555 }));
|
|
60
|
-
}
|
|
61
|
-
if (!parent) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
parent._listing.set(node, inode);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return index;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Maps directory paths to directory inodes, which contain files.
|
|
71
|
-
protected _index: Map<string, IndexDirInode<TData>> = new Map();
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Constructs a new FileIndex.
|
|
75
|
-
*/
|
|
76
|
-
constructor() {
|
|
77
|
-
// _index is a single-level key,value store that maps *directory* paths to
|
|
78
|
-
// DirInodes. File information is only contained in DirInodes themselves.
|
|
79
|
-
// Create the root directory.
|
|
80
|
-
this.add('/', new IndexDirInode());
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public files(): IndexFileInode<TData>[] {
|
|
84
|
-
const files: IndexFileInode<TData>[] = [];
|
|
85
|
-
|
|
86
|
-
for (const dir of this._index.values()) {
|
|
87
|
-
for (const file of dir.listing) {
|
|
88
|
-
const item = dir.get(file);
|
|
89
|
-
if (!item) {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (!item.isFile()) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
files.push(item);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return files;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Adds the given absolute path to the index if it is not already in the index.
|
|
104
|
-
* Creates any needed parent directories.
|
|
105
|
-
* @param path The path to add to the index.
|
|
106
|
-
* @param inode The inode for the
|
|
107
|
-
* path to add.
|
|
108
|
-
* @return 'True' if it was added or already exists, 'false' if there
|
|
109
|
-
* was an issue adding it (e.g. item in path is a file, item exists but is
|
|
110
|
-
* different).
|
|
111
|
-
* @todo If adding fails and implicitly creates directories, we do not clean up
|
|
112
|
-
* the new empty directories.
|
|
113
|
-
*/
|
|
114
|
-
public add(path: string, inode: IndexInode<TData>): boolean {
|
|
115
|
-
if (!inode) {
|
|
116
|
-
throw new ErrnoError(Errno.EINVAL, 'Inode must be specified', path, 'FileIndex.add');
|
|
117
|
-
}
|
|
118
|
-
if (!path.startsWith('/')) {
|
|
119
|
-
throw new ErrnoError(Errno.EINVAL, 'Path not absolute', path, 'FileIndex.add');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Check if it already exists.
|
|
123
|
-
if (this._index.has(path)) {
|
|
124
|
-
return this._index.get(path) === inode;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const dirpath = dirname(path);
|
|
128
|
-
|
|
129
|
-
const hasParent = this._index.has(dirpath);
|
|
130
|
-
|
|
131
|
-
const parent = hasParent ? this._index.get(dirpath)! : new IndexDirInode<TData>();
|
|
132
|
-
|
|
133
|
-
// Try to add to its parent directory first.
|
|
134
|
-
if (!hasParent && path != '/') {
|
|
135
|
-
if (!this.add(dirpath, parent)) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Add to parent.
|
|
141
|
-
if (path != '/' && !parent.add(basename(path), inode)) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// If a directory, add to the index.
|
|
146
|
-
if (inode.isDirectory()) {
|
|
147
|
-
this._index.set(path, inode);
|
|
148
|
-
}
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Adds the given absolute path to the index if it is not already in the index.
|
|
154
|
-
* The path is added without special treatment (no joining of adjacent separators, etc).
|
|
155
|
-
* Creates any needed parent directories.
|
|
156
|
-
* @param path The path to add to the index.
|
|
157
|
-
* @param inode The inode for the path to add.
|
|
158
|
-
* @return 'True' if it was added or already exists, 'false' if there
|
|
159
|
-
* was an issue adding it (e.g. item in path is a file, item exists but is
|
|
160
|
-
* different).
|
|
161
|
-
* @todo If adding fails and implicitly creates directories, we do not clean up the new empty directories.
|
|
162
|
-
*/
|
|
163
|
-
public addFast(path: string, inode: IndexInode<TData>): boolean {
|
|
164
|
-
const parentPath = dirname(path);
|
|
165
|
-
const itemName = basename(path);
|
|
166
|
-
|
|
167
|
-
// Try to add to its parent directory first.
|
|
168
|
-
let parent = this._index.get(parentPath);
|
|
169
|
-
if (!parent) {
|
|
170
|
-
// Create parent.
|
|
171
|
-
parent = new IndexDirInode<TData>();
|
|
172
|
-
this.addFast(parentPath, parent);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (!parent.add(itemName, inode)) {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// If adding a directory, add to the index as well.
|
|
180
|
-
if (inode.isDirectory()) {
|
|
181
|
-
this._index.set(path, <IndexDirInode<TData>>inode);
|
|
182
|
-
}
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Removes the given path. Can be a file or a directory.
|
|
188
|
-
* @return The removed item,
|
|
189
|
-
* or null if it did not exist.
|
|
190
|
-
*/
|
|
191
|
-
public remove(path: string): IndexInode<TData> | void {
|
|
192
|
-
const dirpath = dirname(path);
|
|
193
|
-
|
|
194
|
-
// Try to remove it from its parent directory first.
|
|
195
|
-
const parent = this._index.get(dirpath);
|
|
196
|
-
if (!parent) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
// Remove from parent.
|
|
200
|
-
const inode = parent.remove(basename(path));
|
|
201
|
-
if (!inode) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (!inode.isDirectory()) {
|
|
206
|
-
return inode;
|
|
207
|
-
}
|
|
208
|
-
// If a directory, remove from the index, and remove children.
|
|
209
|
-
const children = inode.listing;
|
|
210
|
-
for (const child of children) {
|
|
211
|
-
this.remove(join(path, child));
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Remove the directory from the index, unless it's the root.
|
|
215
|
-
if (path != '/') {
|
|
216
|
-
this._index.delete(path);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Retrieves the directory listing of the given path.
|
|
222
|
-
* @return An array of files in the given path, or 'null' if it does not exist.
|
|
223
|
-
*/
|
|
224
|
-
public ls(path: string): string[] | void {
|
|
225
|
-
return this._index.get(path)?.listing;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Returns the inode of the given item.
|
|
230
|
-
* @return Returns null if the item does not exist.
|
|
231
|
-
*/
|
|
232
|
-
public get(path: string): IndexInode<TData> | void | null {
|
|
233
|
-
const dirpath = dirname(path);
|
|
234
|
-
|
|
235
|
-
// Retrieve from its parent directory.
|
|
236
|
-
const parent = this._index.get(dirpath);
|
|
237
|
-
// Root case
|
|
238
|
-
if (dirpath == path) {
|
|
239
|
-
return parent;
|
|
240
|
-
}
|
|
241
|
-
return parent?.get(basename(path));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Generic interface for file/directory inodes.
|
|
247
|
-
* Note that Stats objects are what we use for file inodes.
|
|
248
|
-
*/
|
|
249
|
-
export abstract class IndexInode<TData> {
|
|
250
|
-
constructor(public data?: TData) {}
|
|
251
|
-
/**
|
|
252
|
-
* Whether this inode is for a file
|
|
253
|
-
*/
|
|
254
|
-
abstract isFile(): this is IndexFileInode<TData>;
|
|
255
|
-
/**
|
|
256
|
-
* Whether this inode is for a directory
|
|
257
|
-
*/
|
|
258
|
-
abstract isDirectory(): this is IndexDirInode<TData>;
|
|
259
|
-
|
|
260
|
-
abstract toStats(): Stats;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Inode for a file. Stores an arbitrary (filesystem-specific) data payload.
|
|
265
|
-
*/
|
|
266
|
-
export class IndexFileInode<TData> extends IndexInode<TData> {
|
|
267
|
-
public isFile() {
|
|
268
|
-
return true;
|
|
269
|
-
}
|
|
270
|
-
public isDirectory() {
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
public toStats(): Stats {
|
|
275
|
-
return new Stats({ mode: FileType.FILE | 0o666, size: 4096 });
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Inode for a directory. Currently only contains the directory listing.
|
|
281
|
-
*/
|
|
282
|
-
export class IndexDirInode<TData> extends IndexInode<TData> {
|
|
283
|
-
/**
|
|
284
|
-
* @internal
|
|
285
|
-
*/
|
|
286
|
-
_listing: Map<string, IndexInode<TData>> = new Map();
|
|
287
|
-
|
|
288
|
-
public isFile(): boolean {
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
public isDirectory(): boolean {
|
|
293
|
-
return true;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Return a Stats object for this inode.
|
|
298
|
-
* @todo Should probably remove this at some point. This isn't the responsibility of the FileIndex.
|
|
299
|
-
*/
|
|
300
|
-
public get stats(): Stats {
|
|
301
|
-
return new Stats({ mode: FileType.DIRECTORY | 0o555, size: 4096 });
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Alias of getStats()
|
|
305
|
-
* @todo Remove this at some point. This isn't the responsibility of the FileIndex.
|
|
306
|
-
*/
|
|
307
|
-
public toStats(): Stats {
|
|
308
|
-
return this.stats;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Returns the directory listing for this directory. Paths in the directory are
|
|
312
|
-
* relative to the directory's path.
|
|
313
|
-
* @return The directory listing for this directory.
|
|
314
|
-
*/
|
|
315
|
-
public get listing(): string[] {
|
|
316
|
-
return [...this._listing.keys()];
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Returns the inode for the indicated item, or null if it does not exist.
|
|
321
|
-
* @param path Name of item in this directory.
|
|
322
|
-
*/
|
|
323
|
-
public get(path: string): IndexInode<TData> | void {
|
|
324
|
-
return this._listing.get(path);
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Add the given item to the directory listing. Note that the given inode is
|
|
328
|
-
* not copied, and will be mutated by the DirInode if it is a DirInode.
|
|
329
|
-
* @param path Item name to add to the directory listing.
|
|
330
|
-
* @param inode The inode for the
|
|
331
|
-
* item to add to the directory inode.
|
|
332
|
-
* @return True if it was added, false if it already existed.
|
|
333
|
-
*/
|
|
334
|
-
public add(path: string, inode: IndexInode<TData>): boolean {
|
|
335
|
-
if (this._listing.has(path)) {
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
this._listing.set(path, inode);
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Removes the given item from the directory listing.
|
|
343
|
-
* @param path Name of item to remove from the directory listing.
|
|
344
|
-
* @return Returns the item
|
|
345
|
-
* removed, or null if the item did not exist.
|
|
346
|
-
*/
|
|
347
|
-
public remove(path: string): IndexInode<TData> | void {
|
|
348
|
-
const item = this._listing.get(path);
|
|
349
|
-
if (!item) {
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
this._listing.delete(path);
|
|
353
|
-
return item;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
export abstract class IndexFS<TData> extends Readonly(FileSystem) {
|
|
358
|
-
protected _index: FileIndex<TData>;
|
|
359
|
-
|
|
360
|
-
constructor(index: ListingTree) {
|
|
361
|
-
super();
|
|
362
|
-
this._index = FileIndex.FromListing<TData>(index);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
public async stat(path: string): Promise<Stats> {
|
|
366
|
-
const inode = this._index.get(path);
|
|
367
|
-
if (!inode) {
|
|
368
|
-
throw ErrnoError.With('ENOENT', path, 'stat');
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (inode.isDirectory()) {
|
|
372
|
-
return inode.stats;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (inode.isFile()) {
|
|
376
|
-
return this.statFileInode(inode, path);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
throw new ErrnoError(Errno.EINVAL, 'Invalid inode.');
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
public statSync(path: string): Stats {
|
|
383
|
-
const inode = this._index.get(path);
|
|
384
|
-
if (!inode) {
|
|
385
|
-
throw ErrnoError.With('ENOENT', path, 'stat');
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (inode.isDirectory()) {
|
|
389
|
-
return inode.stats;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
if (inode.isFile()) {
|
|
393
|
-
return this.statFileInodeSync(inode, path);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
throw new ErrnoError(Errno.EINVAL, 'Invalid inode.');
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
public async openFile(path: string, flag: string, cred: Cred): Promise<NoSyncFile<this>> {
|
|
400
|
-
if (isWriteable(flag)) {
|
|
401
|
-
// You can't write to files on this file system.
|
|
402
|
-
throw new ErrnoError(Errno.EPERM, path);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// Check if the path exists, and is a file.
|
|
406
|
-
const inode = this._index.get(path);
|
|
407
|
-
|
|
408
|
-
if (!inode) {
|
|
409
|
-
throw ErrnoError.With('ENOENT', path, 'openFile');
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
if (!inode.toStats().hasAccess(flagToMode(flag), cred)) {
|
|
413
|
-
throw ErrnoError.With('EACCES', path, 'openFile');
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
if (inode.isDirectory()) {
|
|
417
|
-
const stats = inode.stats;
|
|
418
|
-
return new NoSyncFile(this, path, flag, stats, stats.fileData);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
return this.openFileInode(inode, path, flag);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
public openFileSync(path: string, flag: string, cred: Cred): NoSyncFile<this> {
|
|
425
|
-
if (isWriteable(flag)) {
|
|
426
|
-
// You can't write to files on this file system.
|
|
427
|
-
throw new ErrnoError(Errno.EPERM, path);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// Check if the path exists, and is a file.
|
|
431
|
-
const inode = this._index.get(path);
|
|
432
|
-
|
|
433
|
-
if (!inode) {
|
|
434
|
-
throw ErrnoError.With('ENOENT', path, 'openFile');
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
if (!inode.toStats().hasAccess(flagToMode(flag), cred)) {
|
|
438
|
-
throw ErrnoError.With('EACCES', path, 'openFile');
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
if (inode.isDirectory()) {
|
|
442
|
-
const stats = inode.stats;
|
|
443
|
-
return new NoSyncFile(this, path, flag, stats, stats.fileData);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
return this.openFileInodeSync(inode, path, flag);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
public async readdir(path: string): Promise<string[]> {
|
|
450
|
-
// Check if it exists.
|
|
451
|
-
const inode = this._index.get(path);
|
|
452
|
-
if (!inode) {
|
|
453
|
-
throw ErrnoError.With('ENOENT', path, 'readdir');
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
if (inode.isDirectory()) {
|
|
457
|
-
return inode.listing;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
throw ErrnoError.With('ENOTDIR', path, 'readdir');
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
public readdirSync(path: string): string[] {
|
|
464
|
-
// Check if it exists.
|
|
465
|
-
const inode = this._index.get(path);
|
|
466
|
-
if (!inode) {
|
|
467
|
-
throw ErrnoError.With('ENOENT', path, 'readdir');
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
if (inode.isDirectory()) {
|
|
471
|
-
return inode.listing;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
throw ErrnoError.With('ENOTDIR', path, 'readdir');
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
protected abstract statFileInode(inode: IndexFileInode<TData>, path: string): Promise<Stats>;
|
|
478
|
-
|
|
479
|
-
protected abstract statFileInodeSync(inode: IndexFileInode<TData>, path: string): Stats;
|
|
480
|
-
|
|
481
|
-
protected abstract openFileInode(inode: IndexFileInode<TData>, path: string, flag: string): Promise<NoSyncFile<this>>;
|
|
482
|
-
|
|
483
|
-
protected abstract openFileInodeSync(inode: IndexFileInode<TData>, path: string, flag: string): NoSyncFile<this>;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
export abstract class SyncIndexFS<TData> extends IndexFS<TData> {
|
|
487
|
-
protected async statFileInode(inode: IndexFileInode<TData>, path: string): Promise<Stats> {
|
|
488
|
-
return this.statFileInodeSync(inode, path);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
protected async openFileInode(inode: IndexFileInode<TData>, path: string, flag: string): Promise<NoSyncFile<this>> {
|
|
492
|
-
return this.openFileInodeSync(inode, path, flag);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
export abstract class AsyncIndexFS<TData> extends IndexFS<TData> {
|
|
497
|
-
protected statFileInodeSync(inode: IndexFileInode<TData>, path: string): Stats {
|
|
498
|
-
throw ErrnoError.With('ENOSYS', path, 'AsyncIndexFS.statFileInodeSync');
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
protected openFileInodeSync(inode: IndexFileInode<TData>, path: string, flag: string): NoSyncFile<this> {
|
|
502
|
-
throw ErrnoError.With('ENOSYS', path, 'AsyncIndexFS.openFileInodeSync');
|
|
503
|
-
}
|
|
504
|
-
}
|