@zenfs/core 0.10.0 → 0.11.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 (61) hide show
  1. package/dist/backends/Index.d.ts +3 -3
  2. package/dist/backends/Index.js +4 -4
  3. package/dist/backends/backend.js +2 -1
  4. package/dist/backends/{Fetch.d.ts → fetch.d.ts} +4 -4
  5. package/dist/backends/{Fetch.js → fetch.js} +6 -7
  6. package/dist/backends/{Locked.d.ts → locked.d.ts} +2 -2
  7. package/dist/backends/{Locked.js → locked.js} +4 -5
  8. package/dist/backends/{InMemory.d.ts → memory.d.ts} +7 -9
  9. package/dist/backends/memory.js +38 -0
  10. package/dist/backends/{Overlay.d.ts → overlay.d.ts} +12 -13
  11. package/dist/backends/{Overlay.js → overlay.js} +98 -103
  12. package/dist/backends/port/fs.d.ts +15 -16
  13. package/dist/backends/port/fs.js +20 -22
  14. package/dist/backends/store/fs.d.ts +169 -0
  15. package/dist/backends/store/fs.js +743 -0
  16. package/dist/backends/store/simple.d.ts +64 -0
  17. package/dist/backends/store/simple.js +111 -0
  18. package/dist/backends/store/store.d.ts +111 -0
  19. package/dist/backends/store/store.js +62 -0
  20. package/dist/browser.min.js +4 -4
  21. package/dist/browser.min.js.map +4 -4
  22. package/dist/config.d.ts +1 -1
  23. package/dist/emulation/shared.js +1 -1
  24. package/dist/error.d.ts +0 -1
  25. package/dist/error.js +0 -1
  26. package/dist/file.js +1 -1
  27. package/dist/filesystem.d.ts +3 -3
  28. package/dist/filesystem.js +26 -29
  29. package/dist/index.d.ts +5 -7
  30. package/dist/index.js +5 -7
  31. package/dist/inode.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/src/backends/Index.ts +4 -4
  34. package/src/backends/backend.ts +2 -1
  35. package/src/backends/{Fetch.ts → fetch.ts} +13 -14
  36. package/src/backends/{Locked.ts → locked.ts} +5 -6
  37. package/src/backends/memory.ts +44 -0
  38. package/src/backends/{Overlay.ts → overlay.ts} +99 -105
  39. package/src/backends/port/fs.ts +24 -26
  40. package/src/backends/store/fs.ts +881 -0
  41. package/src/backends/store/readme.md +9 -0
  42. package/src/backends/store/simple.ts +144 -0
  43. package/src/backends/store/store.ts +164 -0
  44. package/src/config.ts +2 -2
  45. package/src/emulation/shared.ts +1 -1
  46. package/src/error.ts +0 -1
  47. package/src/file.ts +1 -1
  48. package/src/filesystem.ts +29 -32
  49. package/src/index.ts +5 -7
  50. package/src/inode.ts +1 -1
  51. package/dist/backends/AsyncStore.d.ts +0 -204
  52. package/dist/backends/AsyncStore.js +0 -509
  53. package/dist/backends/InMemory.js +0 -49
  54. package/dist/backends/SyncStore.d.ts +0 -213
  55. package/dist/backends/SyncStore.js +0 -445
  56. package/dist/backends/port/store.d.ts +0 -30
  57. package/dist/backends/port/store.js +0 -142
  58. package/src/backends/AsyncStore.ts +0 -655
  59. package/src/backends/InMemory.ts +0 -56
  60. package/src/backends/SyncStore.ts +0 -589
  61. package/src/backends/port/store.ts +0 -187
@@ -2,7 +2,7 @@ import { FileSystem, FileSystemMetadata } from '../filesystem.js';
2
2
  import { ErrnoError, Errno } from '../error.js';
3
3
  import { File, PreloadFile, parseFlag } from '../file.js';
4
4
  import { Stats } from '../stats.js';
5
- import { LockedFS } from './Locked.js';
5
+ import { LockedFS } from './locked.js';
6
6
  import { dirname } from '../emulation/path.js';
7
7
  import { Cred, rootCred } from '../cred.js';
8
8
  import { decode, encode } from '../utils.js';
@@ -35,11 +35,10 @@ export interface OverlayOptions {
35
35
  * @internal
36
36
  */
37
37
  export class UnlockedOverlayFS extends FileSystem {
38
- async ready(): Promise<this> {
38
+ async ready(): Promise<void> {
39
39
  await this._readable.ready();
40
40
  await this._writable.ready();
41
41
  await this._ready;
42
- return this;
43
42
  }
44
43
 
45
44
  private _writable: FileSystem;
@@ -155,30 +154,30 @@ export class UnlockedOverlayFS extends FileSystem {
155
154
  }
156
155
  }
157
156
 
158
- public async stat(p: string, cred: Cred): Promise<Stats> {
157
+ public async stat(path: string, cred: Cred): Promise<Stats> {
159
158
  this.checkInitialized();
160
159
  try {
161
- return this._writable.stat(p, cred);
160
+ return this._writable.stat(path, cred);
162
161
  } catch (e) {
163
- if (this._deletedFiles.has(p)) {
164
- throw ErrnoError.With('ENOENT', p, 'stat');
162
+ if (this._deletedFiles.has(path)) {
163
+ throw ErrnoError.With('ENOENT', path, 'stat');
165
164
  }
166
- const oldStat = new Stats(await this._readable.stat(p, cred));
165
+ const oldStat = new Stats(await this._readable.stat(path, cred));
167
166
  // Make the oldStat's mode writable. Preserve the topmost part of the mode, which specifies the type
168
167
  oldStat.mode |= 0o222;
169
168
  return oldStat;
170
169
  }
171
170
  }
172
171
 
173
- public statSync(p: string, cred: Cred): Stats {
172
+ public statSync(path: string, cred: Cred): Stats {
174
173
  this.checkInitialized();
175
174
  try {
176
- return this._writable.statSync(p, cred);
175
+ return this._writable.statSync(path, cred);
177
176
  } catch (e) {
178
- if (this._deletedFiles.has(p)) {
179
- throw ErrnoError.With('ENOENT', p, 'stat');
177
+ if (this._deletedFiles.has(path)) {
178
+ throw ErrnoError.With('ENOENT', path, 'stat');
180
179
  }
181
- const oldStat = new Stats(this._readable.statSync(p, cred));
180
+ const oldStat = new Stats(this._readable.statSync(path, cred));
182
181
  // Make the oldStat's mode writable. Preserve the topmost part of the mode, which specifies the type.
183
182
  oldStat.mode |= 0o222;
184
183
  return oldStat;
@@ -230,153 +229,153 @@ export class UnlockedOverlayFS extends FileSystem {
230
229
  this._writable.linkSync(srcpath, dstpath, cred);
231
230
  }
232
231
 
233
- public async unlink(p: string, cred: Cred): Promise<void> {
232
+ public async unlink(path: string, cred: Cred): Promise<void> {
234
233
  this.checkInitialized();
235
- this.checkPath(p);
236
- if (!(await this.exists(p, cred))) {
237
- throw ErrnoError.With('ENOENT', p, 'unlink');
234
+ this.checkPath(path);
235
+ if (!(await this.exists(path, cred))) {
236
+ throw ErrnoError.With('ENOENT', path, 'unlink');
238
237
  }
239
238
 
240
- if (await this._writable.exists(p, cred)) {
241
- await this._writable.unlink(p, cred);
239
+ if (await this._writable.exists(path, cred)) {
240
+ await this._writable.unlink(path, cred);
242
241
  }
243
242
 
244
243
  // if it still exists add to the delete log
245
- if (await this.exists(p, cred)) {
246
- this.deletePath(p, cred);
244
+ if (await this.exists(path, cred)) {
245
+ this.deletePath(path, cred);
247
246
  }
248
247
  }
249
248
 
250
- public unlinkSync(p: string, cred: Cred): void {
249
+ public unlinkSync(path: string, cred: Cred): void {
251
250
  this.checkInitialized();
252
- this.checkPath(p);
253
- if (!this.existsSync(p, cred)) {
254
- throw ErrnoError.With('ENOENT', p, 'unlink');
251
+ this.checkPath(path);
252
+ if (!this.existsSync(path, cred)) {
253
+ throw ErrnoError.With('ENOENT', path, 'unlink');
255
254
  }
256
255
 
257
- if (this._writable.existsSync(p, cred)) {
258
- this._writable.unlinkSync(p, cred);
256
+ if (this._writable.existsSync(path, cred)) {
257
+ this._writable.unlinkSync(path, cred);
259
258
  }
260
259
 
261
260
  // if it still exists add to the delete log
262
- if (this.existsSync(p, cred)) {
263
- this.deletePath(p, cred);
261
+ if (this.existsSync(path, cred)) {
262
+ this.deletePath(path, cred);
264
263
  }
265
264
  }
266
265
 
267
- public async rmdir(p: string, cred: Cred): Promise<void> {
266
+ public async rmdir(path: string, cred: Cred): Promise<void> {
268
267
  this.checkInitialized();
269
- if (!(await this.exists(p, cred))) {
270
- throw ErrnoError.With('ENOENT', p, 'rmdir');
268
+ if (!(await this.exists(path, cred))) {
269
+ throw ErrnoError.With('ENOENT', path, 'rmdir');
271
270
  }
272
- if (await this._writable.exists(p, cred)) {
273
- await this._writable.rmdir(p, cred);
271
+ if (await this._writable.exists(path, cred)) {
272
+ await this._writable.rmdir(path, cred);
274
273
  }
275
- if (await this.exists(p, cred)) {
274
+ if (await this.exists(path, cred)) {
276
275
  // Check if directory is empty.
277
- if ((await this.readdir(p, cred)).length > 0) {
278
- throw ErrnoError.With('ENOTEMPTY', p, 'rmdir');
276
+ if ((await this.readdir(path, cred)).length > 0) {
277
+ throw ErrnoError.With('ENOTEMPTY', path, 'rmdir');
279
278
  } else {
280
- this.deletePath(p, cred);
279
+ this.deletePath(path, cred);
281
280
  }
282
281
  }
283
282
  }
284
283
 
285
- public rmdirSync(p: string, cred: Cred): void {
284
+ public rmdirSync(path: string, cred: Cred): void {
286
285
  this.checkInitialized();
287
- if (!this.existsSync(p, cred)) {
288
- throw ErrnoError.With('ENOENT', p, 'rmdir');
286
+ if (!this.existsSync(path, cred)) {
287
+ throw ErrnoError.With('ENOENT', path, 'rmdir');
289
288
  }
290
- if (this._writable.existsSync(p, cred)) {
291
- this._writable.rmdirSync(p, cred);
289
+ if (this._writable.existsSync(path, cred)) {
290
+ this._writable.rmdirSync(path, cred);
292
291
  }
293
- if (this.existsSync(p, cred)) {
292
+ if (this.existsSync(path, cred)) {
294
293
  // Check if directory is empty.
295
- if (this.readdirSync(p, cred).length > 0) {
296
- throw ErrnoError.With('ENOTEMPTY', p, 'rmdir');
294
+ if (this.readdirSync(path, cred).length > 0) {
295
+ throw ErrnoError.With('ENOTEMPTY', path, 'rmdir');
297
296
  } else {
298
- this.deletePath(p, cred);
297
+ this.deletePath(path, cred);
299
298
  }
300
299
  }
301
300
  }
302
301
 
303
- public async mkdir(p: string, mode: number, cred: Cred): Promise<void> {
302
+ public async mkdir(path: string, mode: number, cred: Cred): Promise<void> {
304
303
  this.checkInitialized();
305
- if (await this.exists(p, cred)) {
306
- throw ErrnoError.With('EEXIST', p, 'mkdir');
304
+ if (await this.exists(path, cred)) {
305
+ throw ErrnoError.With('EEXIST', path, 'mkdir');
307
306
  }
308
307
  // The below will throw should any of the parent directories fail to exist on _writable.
309
- await this.createParentDirectories(p, cred);
310
- await this._writable.mkdir(p, mode, cred);
308
+ await this.createParentDirectories(path, cred);
309
+ await this._writable.mkdir(path, mode, cred);
311
310
  }
312
311
 
313
- public mkdirSync(p: string, mode: number, cred: Cred): void {
312
+ public mkdirSync(path: string, mode: number, cred: Cred): void {
314
313
  this.checkInitialized();
315
- if (this.existsSync(p, cred)) {
316
- throw ErrnoError.With('EEXIST', p, 'mkdir');
314
+ if (this.existsSync(path, cred)) {
315
+ throw ErrnoError.With('EEXIST', path, 'mkdir');
317
316
  }
318
317
  // The below will throw should any of the parent directories fail to exist on _writable.
319
- this.createParentDirectoriesSync(p, cred);
320
- this._writable.mkdirSync(p, mode, cred);
318
+ this.createParentDirectoriesSync(path, cred);
319
+ this._writable.mkdirSync(path, mode, cred);
321
320
  }
322
321
 
323
- public async readdir(p: string, cred: Cred): Promise<string[]> {
322
+ public async readdir(path: string, cred: Cred): Promise<string[]> {
324
323
  this.checkInitialized();
325
- const dirStats = await this.stat(p, cred);
324
+ const dirStats = await this.stat(path, cred);
326
325
  if (!dirStats.isDirectory()) {
327
- throw ErrnoError.With('ENOTDIR', p, 'readdir');
326
+ throw ErrnoError.With('ENOTDIR', path, 'readdir');
328
327
  }
329
328
 
330
329
  // Readdir in both, check delete log on RO file system's listing, merge, return.
331
330
  const contents: string[] = [];
332
331
  try {
333
- contents.push(...(await this._writable.readdir(p, cred)));
332
+ contents.push(...(await this._writable.readdir(path, cred)));
334
333
  } catch (e) {
335
334
  // NOP.
336
335
  }
337
336
  try {
338
- contents.push(...(await this._readable.readdir(p, cred)).filter((fPath: string) => !this._deletedFiles.has(`${p}/${fPath}`)));
337
+ contents.push(...(await this._readable.readdir(path, cred)).filter((fPath: string) => !this._deletedFiles.has(`${path}/${fPath}`)));
339
338
  } catch (e) {
340
339
  // NOP.
341
340
  }
342
341
  const seenMap: { [name: string]: boolean } = {};
343
- return contents.filter((fileP: string) => {
344
- const result = !seenMap[fileP];
345
- seenMap[fileP] = true;
342
+ return contents.filter((path: string) => {
343
+ const result = !seenMap[path];
344
+ seenMap[path] = true;
346
345
  return result;
347
346
  });
348
347
  }
349
348
 
350
- public readdirSync(p: string, cred: Cred): string[] {
349
+ public readdirSync(path: string, cred: Cred): string[] {
351
350
  this.checkInitialized();
352
- const dirStats = this.statSync(p, cred);
351
+ const dirStats = this.statSync(path, cred);
353
352
  if (!dirStats.isDirectory()) {
354
- throw ErrnoError.With('ENOTDIR', p, 'readdir');
353
+ throw ErrnoError.With('ENOTDIR', path, 'readdir');
355
354
  }
356
355
 
357
356
  // Readdir in both, check delete log on RO file system's listing, merge, return.
358
357
  let contents: string[] = [];
359
358
  try {
360
- contents = contents.concat(this._writable.readdirSync(p, cred));
359
+ contents = contents.concat(this._writable.readdirSync(path, cred));
361
360
  } catch (e) {
362
361
  // NOP.
363
362
  }
364
363
  try {
365
- contents = contents.concat(this._readable.readdirSync(p, cred).filter((fPath: string) => !this._deletedFiles.has(`${p}/${fPath}`)));
364
+ contents = contents.concat(this._readable.readdirSync(path, cred).filter((fPath: string) => !this._deletedFiles.has(`${path}/${fPath}`)));
366
365
  } catch (e) {
367
366
  // NOP.
368
367
  }
369
368
  const seenMap: { [name: string]: boolean } = {};
370
- return contents.filter((fileP: string) => {
371
- const result = !seenMap[fileP];
372
- seenMap[fileP] = true;
369
+ return contents.filter((path: string) => {
370
+ const result = !seenMap[path];
371
+ seenMap[path] = true;
373
372
  return result;
374
373
  });
375
374
  }
376
375
 
377
- private deletePath(p: string, cred: Cred): void {
378
- this._deletedFiles.add(p);
379
- this.updateLog(`d${p}\n`, cred);
376
+ private deletePath(path: string, cred: Cred): void {
377
+ this._deletedFiles.add(path);
378
+ this.updateLog(`d${path}\n`, cred);
380
379
  }
381
380
 
382
381
  private async updateLog(addition: string, cred: Cred) {
@@ -437,8 +436,8 @@ export class UnlockedOverlayFS extends FileSystem {
437
436
  * With the given path, create the needed parent directories on the writable storage
438
437
  * should they not exist. Use modes from the read-only storage.
439
438
  */
440
- private createParentDirectoriesSync(p: string, cred: Cred): void {
441
- let parent = dirname(p),
439
+ private createParentDirectoriesSync(path: string, cred: Cred): void {
440
+ let parent = dirname(path),
442
441
  toCreate: string[] = [];
443
442
  while (!this._writable.existsSync(parent, cred)) {
444
443
  toCreate.push(parent);
@@ -451,8 +450,8 @@ export class UnlockedOverlayFS extends FileSystem {
451
450
  }
452
451
  }
453
452
 
454
- private async createParentDirectories(p: string, cred: Cred): Promise<void> {
455
- let parent = dirname(p),
453
+ private async createParentDirectories(path: string, cred: Cred): Promise<void> {
454
+ let parent = dirname(path),
456
455
  toCreate: string[] = [];
457
456
  while (!(await this._writable.exists(parent, cred))) {
458
457
  toCreate.push(parent);
@@ -471,24 +470,24 @@ export class UnlockedOverlayFS extends FileSystem {
471
470
  * - Ensures p is on writable before proceeding. Throws an error if it doesn't exist.
472
471
  * - Calls f to perform operation on writable.
473
472
  */
474
- private operateOnWritable(p: string, cred: Cred): void {
475
- if (!this.existsSync(p, cred)) {
476
- throw ErrnoError.With('ENOENT', p, 'operateOnWriteable');
473
+ private operateOnWritable(path: string, cred: Cred): void {
474
+ if (!this.existsSync(path, cred)) {
475
+ throw ErrnoError.With('ENOENT', path, 'operateOnWriteable');
477
476
  }
478
- if (!this._writable.existsSync(p, cred)) {
477
+ if (!this._writable.existsSync(path, cred)) {
479
478
  // File is on readable storage. Copy to writable storage before
480
479
  // changing its mode.
481
- this.copyToWritableSync(p, cred);
480
+ this.copyToWritableSync(path, cred);
482
481
  }
483
482
  }
484
483
 
485
- private async operateOnWritableAsync(p: string, cred: Cred): Promise<void> {
486
- if (!(await this.exists(p, cred))) {
487
- throw ErrnoError.With('ENOENT', p, 'operateOnWritable');
484
+ private async operateOnWritableAsync(path: string, cred: Cred): Promise<void> {
485
+ if (!(await this.exists(path, cred))) {
486
+ throw ErrnoError.With('ENOENT', path, 'operateOnWritable');
488
487
  }
489
488
 
490
- if (!(await this._writable.exists(p, cred))) {
491
- return this.copyToWritable(p, cred);
489
+ if (!(await this._writable.exists(path, cred))) {
490
+ return this.copyToWritable(path, cred);
492
491
  }
493
492
  }
494
493
 
@@ -496,34 +495,34 @@ export class UnlockedOverlayFS extends FileSystem {
496
495
  * Copy from readable to writable storage.
497
496
  * PRECONDITION: File does not exist on writable storage.
498
497
  */
499
- private copyToWritableSync(p: string, cred: Cred): void {
500
- const stats = this.statSync(p, cred);
498
+ private copyToWritableSync(path: string, cred: Cred): void {
499
+ const stats = this.statSync(path, cred);
501
500
  if (stats.isDirectory()) {
502
- this._writable.mkdirSync(p, stats.mode, cred);
501
+ this._writable.mkdirSync(path, stats.mode, cred);
503
502
  return;
504
503
  }
505
504
 
506
505
  const data = new Uint8Array(stats.size);
507
- const readable = this._readable.openFileSync(p, parseFlag('r'), cred);
506
+ const readable = this._readable.openFileSync(path, parseFlag('r'), cred);
508
507
  readable.readSync(data);
509
508
  readable.closeSync();
510
- const writable = this._writable.openFileSync(p, parseFlag('w'), cred);
509
+ const writable = this._writable.openFileSync(path, parseFlag('w'), cred);
511
510
  writable.writeSync(data);
512
511
  writable.closeSync();
513
512
  }
514
513
 
515
- private async copyToWritable(p: string, cred: Cred): Promise<void> {
516
- const stats = await this.stat(p, cred);
514
+ private async copyToWritable(path: string, cred: Cred): Promise<void> {
515
+ const stats = await this.stat(path, cred);
517
516
  if (stats.isDirectory()) {
518
- await this._writable.mkdir(p, stats.mode, cred);
517
+ await this._writable.mkdir(path, stats.mode, cred);
519
518
  return;
520
519
  }
521
520
 
522
521
  const data = new Uint8Array(stats.size);
523
- const readable = await this._readable.openFile(p, parseFlag('r'), cred);
522
+ const readable = await this._readable.openFile(path, parseFlag('r'), cred);
524
523
  await readable.read(data);
525
524
  await readable.close();
526
- const writable = await this._writable.openFile(p, parseFlag('w'), cred);
525
+ const writable = await this._writable.openFile(path, parseFlag('w'), cred);
527
526
  await writable.write(data);
528
527
  await writable.close();
529
528
  }
@@ -536,11 +535,6 @@ export class UnlockedOverlayFS extends FileSystem {
536
535
  * @internal
537
536
  */
538
537
  export class OverlayFS extends LockedFS<UnlockedOverlayFS> {
539
- public async ready() {
540
- await super.ready();
541
- return this;
542
- }
543
-
544
538
  /**
545
539
  * @param options The options to initialize the OverlayFS with
546
540
  */
@@ -1,15 +1,14 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { ErrnoError, Errno } from '../../error.js';
2
+ import type { FileReadResult } from 'node:fs/promises';
3
+ import type { ExtractProperties } from 'utilium';
3
4
  import type { Cred } from '../../cred.js';
4
- import { FileSystem, type FileSystemMetadata, Async } from '../../filesystem.js';
5
+ import { Errno, ErrnoError } from '../../error.js';
5
6
  import { File } from '../../file.js';
7
+ import { Async, FileSystem, type FileSystemMetadata } from '../../filesystem.js';
6
8
  import { Stats, type FileType } from '../../stats.js';
7
- import { InMemory } from '../InMemory.js';
8
- import type { SyncStoreFS } from '../SyncStore.js';
9
+ import { InMemory } from '../memory.js';
9
10
  import type { Backend } from '../backend.js';
10
11
  import * as RPC from './rpc.js';
11
- import type { ExtractProperties } from 'utilium';
12
- import type { FileReadResult } from 'node:fs/promises';
13
12
 
14
13
  type FileMethods = ExtractProperties<File, (...args: any[]) => Promise<any>>;
15
14
  type FileMethod = keyof FileMethods;
@@ -136,7 +135,7 @@ export class PortFS extends Async(FileSystem) {
136
135
  /**
137
136
  * @hidden
138
137
  */
139
- _sync: SyncStoreFS = InMemory.create({ name: 'port-tmpfs' });
138
+ _sync = InMemory.create({ name: 'port-tmpfs' });
140
139
 
141
140
  /**
142
141
  * Constructs a new PortFS instance that connects with ZenFS running on
@@ -166,43 +165,42 @@ export class PortFS extends Async(FileSystem) {
166
165
  );
167
166
  }
168
167
 
169
- public async ready(): Promise<this> {
168
+ public async ready(): Promise<void> {
170
169
  await this.rpc('ready');
171
170
  await super.ready();
172
- return this;
173
171
  }
174
172
 
175
173
  public rename(oldPath: string, newPath: string, cred: Cred): Promise<void> {
176
174
  return this.rpc('rename', oldPath, newPath, cred);
177
175
  }
178
176
 
179
- public async stat(p: string, cred: Cred): Promise<Stats> {
180
- return new Stats(await this.rpc('stat', p, cred));
177
+ public async stat(path: string, cred: Cred): Promise<Stats> {
178
+ return new Stats(await this.rpc('stat', path, cred));
181
179
  }
182
180
 
183
181
  public sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void> {
184
182
  return this.rpc('sync', path, data, stats);
185
183
  }
186
- public openFile(p: string, flag: string, cred: Cred): Promise<File> {
187
- return this.rpc('openFile', p, flag, cred);
184
+ public openFile(path: string, flag: string, cred: Cred): Promise<File> {
185
+ return this.rpc('openFile', path, flag, cred);
188
186
  }
189
- public createFile(p: string, flag: string, mode: number, cred: Cred): Promise<File> {
190
- return this.rpc('createFile', p, flag, mode, cred);
187
+ public createFile(path: string, flag: string, mode: number, cred: Cred): Promise<File> {
188
+ return this.rpc('createFile', path, flag, mode, cred);
191
189
  }
192
- public unlink(p: string, cred: Cred): Promise<void> {
193
- return this.rpc('unlink', p, cred);
190
+ public unlink(path: string, cred: Cred): Promise<void> {
191
+ return this.rpc('unlink', path, cred);
194
192
  }
195
- public rmdir(p: string, cred: Cred): Promise<void> {
196
- return this.rpc('rmdir', p, cred);
193
+ public rmdir(path: string, cred: Cred): Promise<void> {
194
+ return this.rpc('rmdir', path, cred);
197
195
  }
198
- public mkdir(p: string, mode: number, cred: Cred): Promise<void> {
199
- return this.rpc('mkdir', p, mode, cred);
196
+ public mkdir(path: string, mode: number, cred: Cred): Promise<void> {
197
+ return this.rpc('mkdir', path, mode, cred);
200
198
  }
201
- public readdir(p: string, cred: Cred): Promise<string[]> {
202
- return this.rpc('readdir', p, cred);
199
+ public readdir(path: string, cred: Cred): Promise<string[]> {
200
+ return this.rpc('readdir', path, cred);
203
201
  }
204
- public exists(p: string, cred: Cred): Promise<boolean> {
205
- return this.rpc('exists', p, cred);
202
+ public exists(path: string, cred: Cred): Promise<boolean> {
203
+ return this.rpc('exists', path, cred);
206
204
  }
207
205
  public link(srcpath: string, dstpath: string, cred: Cred): Promise<void> {
208
206
  return this.rpc('link', srcpath, dstpath, cred);
@@ -298,7 +296,7 @@ export const Port = {
298
296
  },
299
297
  },
300
298
 
301
- async isAvailable(port?: RPC.Port): Promise<boolean> {
299
+ async isAvailable(): Promise<boolean> {
302
300
  return true;
303
301
  },
304
302