@zenfs/core 0.4.2 → 0.5.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.
@@ -1,5 +1,5 @@
1
1
  import type { Cred } from './cred.js';
2
- import { NoSyncFile, type FileFlag } from './file.js';
2
+ import { NoSyncFile } from './file.js';
3
3
  import { FileSystem } from './filesystem.js';
4
4
  import { Stats } from './stats.js';
5
5
  /**
@@ -157,8 +157,8 @@ declare const FileIndexFS_base: (abstract new (...args: any[]) => {
157
157
  metadata(): import("./filesystem.js").FileSystemMetadata;
158
158
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
159
159
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
160
- createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<import("./file.js").File>;
161
- createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): import("./file.js").File;
160
+ createFile(path: string, flag: string, mode: number, cred: Cred): Promise<import("./file.js").File>;
161
+ createFileSync(path: string, flag: string, mode: number, cred: Cred): import("./file.js").File;
162
162
  unlink(path: string, cred: Cred): Promise<void>;
163
163
  unlinkSync(path: string, cred: Cred): void;
164
164
  rmdir(path: string, cred: Cred): Promise<void>;
@@ -175,14 +175,14 @@ export declare abstract class FileIndexFS<TIndex> extends FileIndexFS_base {
175
175
  constructor(index: ListingTree);
176
176
  stat(path: string): Promise<Stats>;
177
177
  statSync(path: string): Stats;
178
- openFile(path: string, flag: FileFlag, cred: Cred): Promise<NoSyncFile<this>>;
179
- openFileSync(path: string, flag: FileFlag, cred: Cred): NoSyncFile<this>;
178
+ openFile(path: string, flag: string, cred: Cred): Promise<NoSyncFile<this>>;
179
+ openFileSync(path: string, flag: string, cred: Cred): NoSyncFile<this>;
180
180
  readdir(path: string): Promise<string[]>;
181
181
  readdirSync(path: string): string[];
182
182
  protected abstract statFileInode(inode: IndexFileInode<TIndex>, path: string): Promise<Stats>;
183
183
  protected abstract statFileInodeSync(inode: IndexFileInode<TIndex>, path: string): Stats;
184
- protected abstract openFileInode(inode: IndexFileInode<TIndex>, path: string, flag: FileFlag): Promise<NoSyncFile<this>>;
185
- protected abstract openFileInodeSync(inode: IndexFileInode<TIndex>, path: string, flag: FileFlag): NoSyncFile<this>;
184
+ protected abstract openFileInode(inode: IndexFileInode<TIndex>, path: string, flag: string): Promise<NoSyncFile<this>>;
185
+ protected abstract openFileInodeSync(inode: IndexFileInode<TIndex>, path: string, flag: string): NoSyncFile<this>;
186
186
  }
187
187
  declare const SyncFileIndexFS_base: (abstract new (...args: any[]) => {
188
188
  metadata(): import("./filesystem.js").FileSystemMetadata;
@@ -190,8 +190,8 @@ declare const SyncFileIndexFS_base: (abstract new (...args: any[]) => {
190
190
  exists(path: string, cred: Cred): Promise<boolean>;
191
191
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
192
192
  stat(path: string, cred: Cred): Promise<Stats>;
193
- createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<import("./file.js").File>;
194
- openFile(path: string, flag: FileFlag, cred: Cred): Promise<import("./file.js").File>;
193
+ createFile(path: string, flag: string, mode: number, cred: Cred): Promise<import("./file.js").File>;
194
+ openFile(path: string, flag: string, cred: Cred): Promise<import("./file.js").File>;
195
195
  unlink(path: string, cred: Cred): Promise<void>;
196
196
  rmdir(path: string, cred: Cred): Promise<void>;
197
197
  mkdir(path: string, mode: number, cred: Cred): Promise<void>;
@@ -200,8 +200,8 @@ declare const SyncFileIndexFS_base: (abstract new (...args: any[]) => {
200
200
  sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
201
201
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
202
202
  statSync(path: string, cred: Cred): Stats;
203
- openFileSync(path: string, flag: FileFlag, cred: Cred): import("./file.js").File;
204
- createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): import("./file.js").File;
203
+ openFileSync(path: string, flag: string, cred: Cred): import("./file.js").File;
204
+ createFileSync(path: string, flag: string, mode: number, cred: Cred): import("./file.js").File;
205
205
  unlinkSync(path: string, cred: Cred): void;
206
206
  rmdirSync(path: string, cred: Cred): void;
207
207
  mkdirSync(path: string, mode: number, cred: Cred): void;
@@ -213,18 +213,14 @@ declare const SyncFileIndexFS_base: (abstract new (...args: any[]) => {
213
213
  export declare abstract class SyncFileIndexFS<TIndex> extends SyncFileIndexFS_base {
214
214
  _index: FileIndex<TIndex>;
215
215
  protected statFileInode(inode: IndexFileInode<TIndex>, path: string): Promise<Stats>;
216
- protected openFileInode(inode: IndexFileInode<TIndex>, path: string, flag: FileFlag): Promise<NoSyncFile<this>>;
216
+ protected openFileInode(inode: IndexFileInode<TIndex>, path: string, flag: string): Promise<NoSyncFile<this>>;
217
217
  }
218
218
  declare const AsyncFileIndexFS_base: (abstract new (...args: any[]) => {
219
- /**
220
- * Returns the inode for the indicated item, or null if it does not exist.
221
- * @param path Name of item in this directory.
222
- */
223
219
  metadata(): import("./filesystem.js").FileSystemMetadata;
224
220
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
225
221
  statSync(path: string, cred: Cred): Stats;
226
- createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): import("./file.js").File;
227
- openFileSync(path: string, flag: FileFlag, cred: Cred): import("./file.js").File;
222
+ createFileSync(path: string, flag: string, mode: number, cred: Cred): import("./file.js").File;
223
+ openFileSync(path: string, flag: string, cred: Cred): import("./file.js").File;
228
224
  unlinkSync(path: string, cred: Cred): void;
229
225
  rmdirSync(path: string, cred: Cred): void;
230
226
  mkdirSync(path: string, mode: number, cred: Cred): void;
package/dist/FileIndex.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ApiError, ErrorCode } from './ApiError.js';
2
2
  import { basename, dirname, join } from './emulation/path.js';
3
- import { NoSyncFile } from './file.js';
3
+ import { NoSyncFile, flagToMode, isWriteable } from './file.js';
4
4
  import { FileSystem, Sync, Async, Readonly } from './filesystem.js';
5
5
  import { FileType, Stats } from './stats.js';
6
6
  /**
@@ -330,7 +330,7 @@ export class FileIndexFS extends Readonly(FileSystem) {
330
330
  throw new ApiError(ErrorCode.EINVAL, 'Invalid inode.');
331
331
  }
332
332
  async openFile(path, flag, cred) {
333
- if (flag.isWriteable()) {
333
+ if (isWriteable(flag)) {
334
334
  // You can't write to files on this file system.
335
335
  throw new ApiError(ErrorCode.EPERM, path);
336
336
  }
@@ -339,7 +339,7 @@ export class FileIndexFS extends Readonly(FileSystem) {
339
339
  if (!inode) {
340
340
  throw ApiError.ENOENT(path);
341
341
  }
342
- if (!inode.toStats().hasAccess(flag.mode, cred)) {
342
+ if (!inode.toStats().hasAccess(flagToMode(flag), cred)) {
343
343
  throw ApiError.EACCES(path);
344
344
  }
345
345
  if (inode.isDirectory()) {
@@ -349,7 +349,7 @@ export class FileIndexFS extends Readonly(FileSystem) {
349
349
  return this.openFileInode(inode, path, flag);
350
350
  }
351
351
  openFileSync(path, flag, cred) {
352
- if (flag.isWriteable()) {
352
+ if (isWriteable(flag)) {
353
353
  // You can't write to files on this file system.
354
354
  throw new ApiError(ErrorCode.EPERM, path);
355
355
  }
@@ -358,7 +358,7 @@ export class FileIndexFS extends Readonly(FileSystem) {
358
358
  if (!inode) {
359
359
  throw ApiError.ENOENT(path);
360
360
  }
361
- if (!inode.toStats().hasAccess(flag.mode, cred)) {
361
+ if (!inode.toStats().hasAccess(flagToMode(flag), cred)) {
362
362
  throw ApiError.EACCES(path);
363
363
  }
364
364
  if (inode.isDirectory()) {
@@ -1,5 +1,5 @@
1
1
  import { FileSystem, FileSystemMetadata } from '../filesystem.js';
2
- import { File, FileFlag, PreloadFile } from '../file.js';
2
+ import { File, PreloadFile } from '../file.js';
3
3
  import type { Stats } from '../stats.js';
4
4
  import { Cred } from '../cred.js';
5
5
  import type { Backend } from './backend.js';
@@ -8,7 +8,7 @@ import type { Backend } from './backend.js';
8
8
  * @internal
9
9
  */
10
10
  export declare class MirrorFile extends PreloadFile<AsyncMirrorFS> {
11
- constructor(fs: AsyncMirrorFS, path: string, flag: FileFlag, stat: Stats, data: Uint8Array);
11
+ constructor(fs: AsyncMirrorFS, path: string, flag: string, stat: Stats, data: Uint8Array);
12
12
  sync(): Promise<void>;
13
13
  syncSync(): void;
14
14
  close(): Promise<void>;
@@ -33,8 +33,8 @@ declare const AsyncMirrorFS_base: (abstract new (...args: any[]) => {
33
33
  exists(path: string, cred: Cred): Promise<boolean>;
34
34
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
35
35
  stat(path: string, cred: Cred): Promise<Stats>;
36
- createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
37
- openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
36
+ createFile(path: string, flag: string, mode: number, cred: Cred): Promise<File>;
37
+ openFile(path: string, flag: string, cred: Cred): Promise<File>;
38
38
  unlink(path: string, cred: Cred): Promise<void>;
39
39
  rmdir(path: string, cred: Cred): Promise<void>;
40
40
  mkdir(path: string, mode: number, cred: Cred): Promise<void>;
@@ -43,8 +43,8 @@ declare const AsyncMirrorFS_base: (abstract new (...args: any[]) => {
43
43
  sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
44
44
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
45
45
  statSync(path: string, cred: Cred): Stats;
46
- openFileSync(path: string, flag: FileFlag, cred: Cred): File;
47
- createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
46
+ openFileSync(path: string, flag: string, cred: Cred): File;
47
+ createFileSync(path: string, flag: string, mode: number, cred: Cred): File;
48
48
  unlinkSync(path: string, cred: Cred): void;
49
49
  rmdirSync(path: string, cred: Cred): void;
50
50
  mkdirSync(path: string, mode: number, cred: Cred): void;
@@ -87,8 +87,8 @@ export declare class AsyncMirrorFS extends AsyncMirrorFS_base {
87
87
  constructor({ sync, async }: AsyncMirrorOptions);
88
88
  metadata(): FileSystemMetadata;
89
89
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
90
- openFileSync(path: string, flag: FileFlag, cred: Cred): File;
91
- createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): MirrorFile;
90
+ openFileSync(path: string, flag: string, cred: Cred): File;
91
+ createFileSync(path: string, flag: string, mode: number, cred: Cred): MirrorFile;
92
92
  linkSync(srcpath: string, dstpath: string, cred: Cred): void;
93
93
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
94
94
  statSync(p: string, cred: Cred): Stats;
@@ -1,8 +1,8 @@
1
1
  import { FileSystem, Sync } from '../filesystem.js';
2
2
  import { ApiError, ErrorCode } from '../ApiError.js';
3
- import { FileFlag, PreloadFile } from '../file.js';
3
+ import { PreloadFile, parseFlag } from '../file.js';
4
4
  import { join } from '../emulation/path.js';
5
- import { Cred } from '../cred.js';
5
+ import { rootCred } from '../cred.js';
6
6
  /**
7
7
  * We define our own file to interpose on syncSync() for mirroring purposes.
8
8
  * @internal
@@ -142,10 +142,10 @@ export class AsyncMirrorFS extends Sync(FileSystem) {
142
142
  */
143
143
  async crossCopyDirectory(p, mode) {
144
144
  if (p !== '/') {
145
- const stats = await this._async.stat(p, Cred.Root);
146
- this._sync.mkdirSync(p, mode, stats.getCred());
145
+ const stats = await this._async.stat(p, rootCred);
146
+ this._sync.mkdirSync(p, mode, stats.cred());
147
147
  }
148
- const files = await this._async.readdir(p, Cred.Root);
148
+ const files = await this._async.readdir(p, rootCred);
149
149
  for (const file of files) {
150
150
  await this.crossCopy(join(p, file));
151
151
  }
@@ -154,8 +154,8 @@ export class AsyncMirrorFS extends Sync(FileSystem) {
154
154
  * @internal
155
155
  */
156
156
  async crossCopyFile(p, mode) {
157
- const asyncFile = await this._async.openFile(p, FileFlag.Get('r'), Cred.Root);
158
- const syncFile = this._sync.createFileSync(p, FileFlag.Get('w'), mode, Cred.Root);
157
+ const asyncFile = await this._async.openFile(p, parseFlag('r'), rootCred);
158
+ const syncFile = this._sync.createFileSync(p, parseFlag('w'), mode, rootCred);
159
159
  try {
160
160
  const { size } = await asyncFile.stat();
161
161
  const buffer = new Uint8Array(size);
@@ -171,7 +171,7 @@ export class AsyncMirrorFS extends Sync(FileSystem) {
171
171
  * @internal
172
172
  */
173
173
  async crossCopy(p) {
174
- const stats = await this._async.stat(p, Cred.Root);
174
+ const stats = await this._async.stat(p, rootCred);
175
175
  if (stats.isDirectory()) {
176
176
  await this.crossCopyDirectory(p, stats.mode);
177
177
  }
@@ -1,5 +1,5 @@
1
1
  import type { Cred } from '../cred.js';
2
- import { PreloadFile, File, FileFlag } from '../file.js';
2
+ import { PreloadFile, File } from '../file.js';
3
3
  import { FileSystem, type FileSystemMetadata } from '../filesystem.js';
4
4
  import { type Ino } from '../inode.js';
5
5
  import { type Stats } from '../stats.js';
@@ -67,7 +67,7 @@ export interface AsyncRWTransaction extends AsyncROTransaction {
67
67
  * @internal
68
68
  */
69
69
  export declare class AsyncFile extends PreloadFile<AsyncStoreFS> {
70
- constructor(_fs: AsyncStoreFS, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array);
70
+ constructor(_fs: AsyncStoreFS, _path: string, _flag: string, _stat: Stats, contents?: Uint8Array);
71
71
  sync(): Promise<void>;
72
72
  syncSync(): void;
73
73
  close(): Promise<void>;
@@ -87,8 +87,8 @@ declare const AsyncStoreFS_base: (abstract new (...args: any[]) => {
87
87
  metadata(): FileSystemMetadata;
88
88
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
89
89
  statSync(path: string, cred: Cred): Stats;
90
- createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
91
- openFileSync(path: string, flag: FileFlag, cred: Cred): File;
90
+ createFileSync(path: string, flag: string, mode: number, cred: Cred): File;
91
+ openFileSync(path: string, flag: string, cred: Cred): File;
92
92
  unlinkSync(path: string, cred: Cred): void;
93
93
  rmdirSync(path: string, cred: Cred): void;
94
94
  mkdirSync(path: string, mode: number, cred: Cred): void;
@@ -122,8 +122,8 @@ export declare class AsyncStoreFS extends AsyncStoreFS_base {
122
122
  */
123
123
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
124
124
  stat(p: string, cred: Cred): Promise<Stats>;
125
- createFile(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
126
- openFile(p: string, flag: FileFlag, cred: Cred): Promise<File>;
125
+ createFile(p: string, flag: string, mode: number, cred: Cred): Promise<File>;
126
+ openFile(p: string, flag: string, cred: Cred): Promise<File>;
127
127
  unlink(p: string, cred: Cred): Promise<void>;
128
128
  rmdir(p: string, cred: Cred): Promise<void>;
129
129
  mkdir(p: string, mode: number, cred: Cred): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { dirname, basename, join, resolve } from '../emulation/path.js';
2
2
  import { ApiError, ErrorCode } from '../ApiError.js';
3
3
  import { W_OK, R_OK } from '../emulation/constants.js';
4
- import { PreloadFile } from '../file.js';
4
+ import { PreloadFile, flagToMode } from '../file.js';
5
5
  import { Async, FileSystem } from '../filesystem.js';
6
6
  import { randomIno, Inode } from '../inode.js';
7
7
  import { FileType } from '../stats.js';
@@ -208,7 +208,7 @@ export class AsyncStoreFS extends Async(FileSystem) {
208
208
  }
209
209
  async openFile(p, flag, cred) {
210
210
  const tx = this.store.beginTransaction('readonly'), node = await this.findINode(tx, p), data = await tx.get(node.ino);
211
- if (!node.toStats().hasAccess(flag.mode, cred)) {
211
+ if (!node.toStats().hasAccess(flagToMode(flag), cred)) {
212
212
  throw ApiError.EACCES(p);
213
213
  }
214
214
  if (!data) {
@@ -1,5 +1,5 @@
1
1
  import type { Cred } from '../cred.js';
2
- import type { File, FileFlag } from '../file.js';
2
+ import type { File } from '../file.js';
3
3
  import type { FileSystem, FileSystemMetadata } from '../filesystem.js';
4
4
  import type { Stats } from '../stats.js';
5
5
  /**
@@ -22,10 +22,10 @@ export declare class LockedFS<FS extends FileSystem> implements FileSystem {
22
22
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
23
23
  stat(p: string, cred: Cred): Promise<Stats>;
24
24
  statSync(p: string, cred: Cred): Stats;
25
- openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
26
- openFileSync(path: string, flag: FileFlag, cred: Cred): File;
27
- createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
28
- createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
25
+ openFile(path: string, flag: string, cred: Cred): Promise<File>;
26
+ openFileSync(path: string, flag: string, cred: Cred): File;
27
+ createFile(path: string, flag: string, mode: number, cred: Cred): Promise<File>;
28
+ createFileSync(path: string, flag: string, mode: number, cred: Cred): File;
29
29
  unlink(p: string, cred: Cred): Promise<void>;
30
30
  unlinkSync(p: string, cred: Cred): void;
31
31
  rmdir(p: string, cred: Cred): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { FileSystem, FileSystemMetadata } from '../filesystem.js';
2
- import { File, FileFlag, PreloadFile } from '../file.js';
2
+ import { File, PreloadFile } from '../file.js';
3
3
  import { Stats } from '../stats.js';
4
4
  import { LockedFS } from './Locked.js';
5
5
  import { Cred } from '../cred.js';
@@ -9,7 +9,7 @@ import type { Backend } from './backend.js';
9
9
  * @internal
10
10
  */
11
11
  export declare class OverlayFile extends PreloadFile<UnlockedOverlayFS> implements File {
12
- constructor(fs: UnlockedOverlayFS, path: string, flag: FileFlag, stats: Stats, data: Uint8Array);
12
+ constructor(fs: UnlockedOverlayFS, path: string, flag: string, stats: Stats, data: Uint8Array);
13
13
  sync(): Promise<void>;
14
14
  syncSync(): void;
15
15
  close(): Promise<void>;
@@ -63,10 +63,10 @@ export declare class UnlockedOverlayFS extends FileSystem {
63
63
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
64
64
  stat(p: string, cred: Cred): Promise<Stats>;
65
65
  statSync(p: string, cred: Cred): Stats;
66
- openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
67
- openFileSync(path: string, flag: FileFlag, cred: Cred): File;
68
- createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
69
- createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
66
+ openFile(path: string, flag: string, cred: Cred): Promise<File>;
67
+ openFileSync(path: string, flag: string, cred: Cred): File;
68
+ createFile(path: string, flag: string, mode: number, cred: Cred): Promise<File>;
69
+ createFileSync(path: string, flag: string, mode: number, cred: Cred): File;
70
70
  link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
71
71
  linkSync(srcpath: string, dstpath: string, cred: Cred): void;
72
72
  unlink(p: string, cred: Cred): Promise<void>;
@@ -1,10 +1,10 @@
1
1
  import { FileSystem } from '../filesystem.js';
2
2
  import { ApiError, ErrorCode } from '../ApiError.js';
3
- import { FileFlag, PreloadFile } from '../file.js';
3
+ import { PreloadFile, parseFlag } from '../file.js';
4
4
  import { Stats } from '../stats.js';
5
5
  import { LockedFS } from './Locked.js';
6
6
  import { dirname } from '../emulation/path.js';
7
- import { Cred } from '../cred.js';
7
+ import { rootCred } from '../cred.js';
8
8
  import { decode, encode } from '../utils.js';
9
9
  /**
10
10
  * @internal
@@ -85,12 +85,12 @@ export class UnlockedOverlayFS extends FileSystem {
85
85
  };
86
86
  }
87
87
  async sync(path, data, stats) {
88
- const cred = stats.getCred(0, 0);
88
+ const cred = stats.cred(0, 0);
89
89
  await this.createParentDirectories(path, cred);
90
90
  await this._writable.sync(path, data, stats);
91
91
  }
92
92
  syncSync(path, data, stats) {
93
- const cred = stats.getCred(0, 0);
93
+ const cred = stats.cred(0, 0);
94
94
  this.createParentDirectoriesSync(path, cred);
95
95
  this._writable.syncSync(path, data, stats);
96
96
  }
@@ -104,7 +104,7 @@ export class UnlockedOverlayFS extends FileSystem {
104
104
  }
105
105
  // Read deletion log, process into metadata.
106
106
  try {
107
- const file = await this._writable.openFile(deletionLogPath, FileFlag.Get('r'), Cred.Root);
107
+ const file = await this._writable.openFile(deletionLogPath, parseFlag('r'), rootCred);
108
108
  const { size } = await file.stat();
109
109
  const { buffer } = await file.read(new Uint8Array(size));
110
110
  this._deleteLog = decode(buffer);
@@ -186,7 +186,7 @@ export class UnlockedOverlayFS extends FileSystem {
186
186
  return this._writable.openFile(path, flag, cred);
187
187
  }
188
188
  // Create an OverlayFile.
189
- const file = await this._readable.openFile(path, FileFlag.Get('r'), cred);
189
+ const file = await this._readable.openFile(path, parseFlag('r'), cred);
190
190
  const stats = new Stats(await file.stat());
191
191
  const { buffer } = await file.read(new Uint8Array(stats.size));
192
192
  return new OverlayFile(this, path, flag, stats, buffer);
@@ -196,7 +196,7 @@ export class UnlockedOverlayFS extends FileSystem {
196
196
  return this._writable.openFileSync(path, flag, cred);
197
197
  }
198
198
  // Create an OverlayFile.
199
- const file = this._readable.openFileSync(path, FileFlag.Get('r'), cred);
199
+ const file = this._readable.openFileSync(path, parseFlag('r'), cred);
200
200
  const stats = Stats.clone(file.statSync());
201
201
  const data = new Uint8Array(stats.size);
202
202
  file.readSync(data);
@@ -367,7 +367,7 @@ export class UnlockedOverlayFS extends FileSystem {
367
367
  return;
368
368
  }
369
369
  this._deleteLogUpdatePending = true;
370
- const log = await this._writable.openFile(deletionLogPath, FileFlag.Get('w'), cred);
370
+ const log = await this._writable.openFile(deletionLogPath, parseFlag('w'), cred);
371
371
  try {
372
372
  await log.write(encode(this._deleteLog));
373
373
  if (this._deleteLogUpdateNeeded) {
@@ -469,10 +469,10 @@ export class UnlockedOverlayFS extends FileSystem {
469
469
  return;
470
470
  }
471
471
  const data = new Uint8Array(stats.size);
472
- const readable = this._readable.openFileSync(p, FileFlag.Get('r'), cred);
472
+ const readable = this._readable.openFileSync(p, parseFlag('r'), cred);
473
473
  readable.readSync(data);
474
474
  readable.closeSync();
475
- const writable = this._writable.openFileSync(p, FileFlag.Get('w'), cred);
475
+ const writable = this._writable.openFileSync(p, parseFlag('w'), cred);
476
476
  writable.writeSync(data);
477
477
  writable.closeSync();
478
478
  }
@@ -483,10 +483,10 @@ export class UnlockedOverlayFS extends FileSystem {
483
483
  return;
484
484
  }
485
485
  const data = new Uint8Array(stats.size);
486
- const readable = await this._readable.openFile(p, FileFlag.Get('r'), cred);
486
+ const readable = await this._readable.openFile(p, parseFlag('r'), cred);
487
487
  await readable.read(data);
488
488
  await readable.close();
489
- const writable = await this._writable.openFile(p, FileFlag.Get('w'), cred);
489
+ const writable = await this._writable.openFile(p, parseFlag('w'), cred);
490
490
  await writable.write(data);
491
491
  await writable.close();
492
492
  }
@@ -1,5 +1,5 @@
1
1
  import { Cred } from '../cred.js';
2
- import { FileFlag, PreloadFile } from '../file.js';
2
+ import { PreloadFile } from '../file.js';
3
3
  import { type FileSystemMetadata, FileSystem } from '../filesystem.js';
4
4
  import { type Ino, Inode } from '../inode.js';
5
5
  import { type Stats, FileType } from '../stats.js';
@@ -117,7 +117,7 @@ export interface SyncStoreOptions {
117
117
  * @internal
118
118
  */
119
119
  export declare class SyncStoreFile extends PreloadFile<SyncStoreFS> {
120
- constructor(_fs: SyncStoreFS, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array);
120
+ constructor(_fs: SyncStoreFS, _path: string, _flag: string, _stat: Stats, contents?: Uint8Array);
121
121
  sync(): Promise<void>;
122
122
  syncSync(): void;
123
123
  close(): Promise<void>;
@@ -129,8 +129,8 @@ declare const SyncStoreFS_base: (abstract new (...args: any[]) => {
129
129
  exists(path: string, cred: Cred): Promise<boolean>;
130
130
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
131
131
  stat(path: string, cred: Cred): Promise<Stats>;
132
- createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<import("../file.js").File>;
133
- openFile(path: string, flag: FileFlag, cred: Cred): Promise<import("../file.js").File>;
132
+ createFile(path: string, flag: string, mode: number, cred: Cred): Promise<import("../file.js").File>;
133
+ openFile(path: string, flag: string, cred: Cred): Promise<import("../file.js").File>;
134
134
  unlink(path: string, cred: Cred): Promise<void>;
135
135
  rmdir(path: string, cred: Cred): Promise<void>;
136
136
  mkdir(path: string, mode: number, cred: Cred): Promise<void>;
@@ -139,8 +139,8 @@ declare const SyncStoreFS_base: (abstract new (...args: any[]) => {
139
139
  sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
140
140
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
141
141
  statSync(path: string, cred: Cred): Stats;
142
- openFileSync(path: string, flag: FileFlag, cred: Cred): import("../file.js").File;
143
- createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): import("../file.js").File;
142
+ openFileSync(path: string, flag: string, cred: Cred): import("../file.js").File;
143
+ createFileSync(path: string, flag: string, mode: number, cred: Cred): import("../file.js").File;
144
144
  unlinkSync(path: string, cred: Cred): void;
145
145
  rmdirSync(path: string, cred: Cred): void;
146
146
  mkdirSync(path: string, mode: number, cred: Cred): void;
@@ -167,8 +167,8 @@ export declare class SyncStoreFS extends SyncStoreFS_base {
167
167
  empty(): void;
168
168
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
169
169
  statSync(p: string, cred: Cred): Stats;
170
- createFileSync(p: string, flag: FileFlag, mode: number, cred: Cred): SyncStoreFile;
171
- openFileSync(p: string, flag: FileFlag, cred: Cred): SyncStoreFile;
170
+ createFileSync(p: string, flag: string, mode: number, cred: Cred): SyncStoreFile;
171
+ openFileSync(p: string, flag: string, cred: Cred): SyncStoreFile;
172
172
  unlinkSync(p: string, cred: Cred): void;
173
173
  rmdirSync(p: string, cred: Cred): void;
174
174
  mkdirSync(p: string, mode: number, cred: Cred): void;
@@ -1,7 +1,7 @@
1
1
  import { dirname, basename, join, resolve, sep } from '../emulation/path.js';
2
2
  import { ApiError, ErrorCode } from '../ApiError.js';
3
3
  import { W_OK, R_OK } from '../emulation/constants.js';
4
- import { PreloadFile } from '../file.js';
4
+ import { PreloadFile, flagToMode } from '../file.js';
5
5
  import { FileSystem, Sync } from '../filesystem.js';
6
6
  import { randomIno, Inode } from '../inode.js';
7
7
  import { FileType } from '../stats.js';
@@ -204,7 +204,7 @@ export class SyncStoreFS extends Sync(FileSystem) {
204
204
  }
205
205
  openFileSync(p, flag, cred) {
206
206
  const tx = this.store.beginTransaction('readonly'), node = this.findINode(tx, p), data = tx.get(node.ino);
207
- if (!node.toStats().hasAccess(flag.mode, cred)) {
207
+ if (!node.toStats().hasAccess(flagToMode(flag), cred)) {
208
208
  throw ApiError.EACCES(p);
209
209
  }
210
210
  if (data === null) {