@zenfs/core 0.0.12 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ApiError.d.ts +52 -15
- package/dist/ApiError.js +77 -50
- package/dist/FileIndex.d.ts +32 -35
- package/dist/FileIndex.js +93 -109
- package/dist/backends/AsyncMirror.d.ts +42 -43
- package/dist/backends/AsyncMirror.js +154 -147
- package/dist/backends/AsyncStore.d.ts +29 -28
- package/dist/backends/AsyncStore.js +375 -482
- package/dist/backends/FolderAdapter.js +8 -19
- package/dist/backends/InMemory.d.ts +16 -13
- package/dist/backends/InMemory.js +29 -14
- package/dist/backends/Locked.d.ts +8 -28
- package/dist/backends/Locked.js +74 -224
- package/dist/backends/OverlayFS.d.ts +26 -34
- package/dist/backends/OverlayFS.js +303 -511
- package/dist/backends/SyncStore.d.ts +54 -72
- package/dist/backends/SyncStore.js +159 -161
- package/dist/backends/backend.d.ts +45 -29
- package/dist/backends/backend.js +83 -13
- package/dist/backends/index.d.ts +6 -7
- package/dist/backends/index.js +5 -6
- package/dist/browser.min.js +21 -6
- package/dist/browser.min.js.map +4 -4
- package/dist/emulation/callbacks.d.ts +119 -113
- package/dist/emulation/callbacks.js +129 -92
- package/dist/emulation/constants.js +1 -1
- package/dist/emulation/dir.d.ts +55 -0
- package/dist/emulation/dir.js +104 -0
- package/dist/emulation/fs.d.ts +1 -2
- package/dist/emulation/fs.js +0 -1
- package/dist/emulation/index.d.ts +3 -0
- package/dist/emulation/index.js +3 -0
- package/dist/emulation/promises.d.ts +265 -145
- package/dist/emulation/promises.js +526 -383
- package/dist/emulation/shared.d.ts +20 -6
- package/dist/emulation/shared.js +22 -23
- package/dist/emulation/streams.d.ts +102 -0
- package/dist/emulation/streams.js +55 -0
- package/dist/emulation/sync.d.ts +98 -69
- package/dist/emulation/sync.js +280 -133
- package/dist/file.d.ts +175 -173
- package/dist/file.js +257 -273
- package/dist/filesystem.d.ts +71 -244
- package/dist/filesystem.js +67 -472
- package/dist/index.d.ts +7 -44
- package/dist/index.js +22 -75
- package/dist/inode.d.ts +37 -28
- package/dist/inode.js +123 -65
- package/dist/stats.d.ts +91 -36
- package/dist/stats.js +138 -110
- package/dist/utils.d.ts +26 -13
- package/dist/utils.js +79 -107
- package/package.json +7 -4
- package/readme.md +2 -40
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
var _a;
|
|
11
2
|
import { BaseFileSystem } from '../filesystem.js';
|
|
12
3
|
import { relative, join } from '../emulation/path.js';
|
|
@@ -42,21 +33,19 @@ export class FolderAdapter extends BaseFileSystem {
|
|
|
42
33
|
this._ready = this._initialize();
|
|
43
34
|
}
|
|
44
35
|
get metadata() {
|
|
45
|
-
return
|
|
36
|
+
return { ...super.metadata, ...this._wrapped.metadata, supportsLinks: false };
|
|
46
37
|
}
|
|
47
38
|
/**
|
|
48
39
|
* Initialize the file system. Ensures that the wrapped file system
|
|
49
40
|
* has the given folder.
|
|
50
41
|
*/
|
|
51
|
-
_initialize() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return this;
|
|
59
|
-
});
|
|
42
|
+
async _initialize() {
|
|
43
|
+
const exists = await this._wrapped.exists(this._folder, Cred.Root);
|
|
44
|
+
if (!exists && this._wrapped.metadata.readonly) {
|
|
45
|
+
throw ApiError.ENOENT(this._folder);
|
|
46
|
+
}
|
|
47
|
+
await this._wrapped.mkdir(this._folder, 0o777, Cred.Root);
|
|
48
|
+
return this;
|
|
60
49
|
}
|
|
61
50
|
}
|
|
62
51
|
_a = FolderAdapter;
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Ino } from '../inode.js';
|
|
2
|
+
import { SyncStore, SimpleSyncStore, SyncRWTransaction, SyncStoreFileSystem } from './SyncStore.js';
|
|
3
|
+
import { type Backend } from './backend.js';
|
|
3
4
|
/**
|
|
4
|
-
* A simple in-memory
|
|
5
|
+
* A simple in-memory store
|
|
5
6
|
*/
|
|
6
|
-
export declare class InMemoryStore implements
|
|
7
|
+
export declare class InMemoryStore implements SyncStore, SimpleSyncStore {
|
|
8
|
+
name: string;
|
|
7
9
|
private store;
|
|
8
|
-
name
|
|
10
|
+
constructor(name?: string);
|
|
9
11
|
clear(): void;
|
|
10
|
-
beginTransaction(
|
|
11
|
-
get(key:
|
|
12
|
-
put(key:
|
|
13
|
-
|
|
12
|
+
beginTransaction(): SyncRWTransaction;
|
|
13
|
+
get(key: Ino): Uint8Array;
|
|
14
|
+
put(key: Ino, data: Uint8Array, overwrite: boolean): boolean;
|
|
15
|
+
remove(key: Ino): void;
|
|
14
16
|
}
|
|
17
|
+
export declare const InMemory: Backend;
|
|
15
18
|
/**
|
|
16
19
|
* A simple in-memory file system backed by an InMemoryStore.
|
|
17
20
|
* Files are not persisted across page loads.
|
|
18
21
|
*/
|
|
19
|
-
export declare class
|
|
20
|
-
static
|
|
21
|
-
static
|
|
22
|
-
static readonly
|
|
22
|
+
export declare class _InMemory extends SyncStoreFileSystem {
|
|
23
|
+
static isAvailable(): boolean;
|
|
24
|
+
static create: any;
|
|
25
|
+
static readonly options: {};
|
|
23
26
|
constructor();
|
|
24
27
|
}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
var _a;
|
|
2
|
-
import { SimpleSyncRWTransaction,
|
|
3
|
-
import {
|
|
2
|
+
import { SimpleSyncRWTransaction, SyncStoreFileSystem } from './SyncStore.js';
|
|
3
|
+
import { createBackend } from './backend.js';
|
|
4
4
|
/**
|
|
5
|
-
* A simple in-memory
|
|
5
|
+
* A simple in-memory store
|
|
6
6
|
*/
|
|
7
7
|
export class InMemoryStore {
|
|
8
|
-
constructor() {
|
|
8
|
+
constructor(name = 'tmp') {
|
|
9
|
+
this.name = name;
|
|
9
10
|
this.store = new Map();
|
|
10
11
|
}
|
|
11
|
-
name() {
|
|
12
|
-
return InMemoryFileSystem.Name;
|
|
13
|
-
}
|
|
14
12
|
clear() {
|
|
15
13
|
this.store.clear();
|
|
16
14
|
}
|
|
17
|
-
beginTransaction(
|
|
15
|
+
beginTransaction() {
|
|
18
16
|
return new SimpleSyncRWTransaction(this);
|
|
19
17
|
}
|
|
20
18
|
get(key) {
|
|
@@ -27,20 +25,37 @@ export class InMemoryStore {
|
|
|
27
25
|
this.store.set(key, data);
|
|
28
26
|
return true;
|
|
29
27
|
}
|
|
30
|
-
|
|
28
|
+
remove(key) {
|
|
31
29
|
this.store.delete(key);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
32
|
+
export const InMemory = {
|
|
33
|
+
name: 'InMemory',
|
|
34
|
+
isAvailable() {
|
|
35
|
+
return true;
|
|
36
|
+
},
|
|
37
|
+
options: {
|
|
38
|
+
name: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'The name of the store',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
create({ name }) {
|
|
44
|
+
return new SyncStoreFileSystem({ store: new InMemoryStore(name) });
|
|
45
|
+
},
|
|
46
|
+
};
|
|
34
47
|
/**
|
|
35
48
|
* A simple in-memory file system backed by an InMemoryStore.
|
|
36
49
|
* Files are not persisted across page loads.
|
|
37
50
|
*/
|
|
38
|
-
export class
|
|
51
|
+
export class _InMemory extends SyncStoreFileSystem {
|
|
52
|
+
static isAvailable() {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
39
55
|
constructor() {
|
|
40
56
|
super({ store: new InMemoryStore() });
|
|
41
57
|
}
|
|
42
58
|
}
|
|
43
|
-
_a =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
InMemoryFileSystem.Options = {};
|
|
59
|
+
_a = _InMemory;
|
|
60
|
+
_InMemory.create = createBackend.bind(_a);
|
|
61
|
+
_InMemory.options = {};
|
|
@@ -13,21 +13,19 @@ import { Cred } from '../cred.js';
|
|
|
13
13
|
* multiple requests interleaving.
|
|
14
14
|
*/
|
|
15
15
|
export default class LockedFS<T extends FileSystem> implements FileSystem {
|
|
16
|
-
|
|
16
|
+
readonly fs: T;
|
|
17
17
|
private _mu;
|
|
18
|
-
protected _ready: Promise<this>;
|
|
19
18
|
constructor(fs: T);
|
|
20
|
-
|
|
19
|
+
ready(): Promise<this>;
|
|
21
20
|
get metadata(): FileSystemMetadata;
|
|
22
|
-
get fs(): T;
|
|
23
21
|
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
24
22
|
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
25
23
|
stat(p: string, cred: Cred): Promise<Stats>;
|
|
26
24
|
statSync(p: string, cred: Cred): Stats;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
|
31
29
|
unlink(p: string, cred: Cred): Promise<void>;
|
|
32
30
|
unlinkSync(p: string, cred: Cred): void;
|
|
33
31
|
rmdir(p: string, cred: Cred): Promise<void>;
|
|
@@ -38,26 +36,8 @@ export default class LockedFS<T extends FileSystem> implements FileSystem {
|
|
|
38
36
|
readdirSync(p: string, cred: Cred): string[];
|
|
39
37
|
exists(p: string, cred: Cred): Promise<boolean>;
|
|
40
38
|
existsSync(p: string, cred: Cred): boolean;
|
|
41
|
-
realpath(p: string, cred: Cred): Promise<string>;
|
|
42
|
-
realpathSync(p: string, cred: Cred): string;
|
|
43
|
-
truncate(p: string, len: number, cred: Cred): Promise<void>;
|
|
44
|
-
truncateSync(p: string, len: number, cred: Cred): void;
|
|
45
|
-
readFile(fname: string, flag: FileFlag, cred: Cred): Promise<Uint8Array>;
|
|
46
|
-
readFileSync(fname: string, flag: FileFlag, cred: Cred): Uint8Array;
|
|
47
|
-
writeFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void>;
|
|
48
|
-
writeFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void;
|
|
49
|
-
appendFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void>;
|
|
50
|
-
appendFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void;
|
|
51
|
-
chmod(p: string, mode: number, cred: Cred): Promise<void>;
|
|
52
|
-
chmodSync(p: string, mode: number, cred: Cred): void;
|
|
53
|
-
chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void>;
|
|
54
|
-
chownSync(p: string, new_uid: number, new_gid: number, cred: Cred): void;
|
|
55
|
-
utimes(p: string, atime: Date, mtime: Date, cred: Cred): Promise<void>;
|
|
56
|
-
utimesSync(p: string, atime: Date, mtime: Date, cred: Cred): void;
|
|
57
39
|
link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
|
|
58
40
|
linkSync(srcpath: string, dstpath: string, cred: Cred): void;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
readlink(p: string, cred: Cred): Promise<string>;
|
|
62
|
-
readlinkSync(p: string, cred: Cred): string;
|
|
41
|
+
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
42
|
+
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
63
43
|
}
|
package/dist/backends/Locked.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import Mutex from '../mutex.js';
|
|
11
2
|
/**
|
|
12
3
|
* This class serializes access to an underlying async filesystem.
|
|
@@ -19,284 +10,143 @@ import Mutex from '../mutex.js';
|
|
|
19
10
|
*/
|
|
20
11
|
export default class LockedFS {
|
|
21
12
|
constructor(fs) {
|
|
22
|
-
this.
|
|
23
|
-
this._fs = fs;
|
|
13
|
+
this.fs = fs;
|
|
24
14
|
this._mu = new Mutex();
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
async ready() {
|
|
17
|
+
await this.fs.ready();
|
|
18
|
+
return this;
|
|
28
19
|
}
|
|
29
20
|
get metadata() {
|
|
30
|
-
return
|
|
21
|
+
return {
|
|
22
|
+
...this.fs.metadata,
|
|
23
|
+
name: 'Locked<' + this.fs.metadata.name + '>',
|
|
24
|
+
};
|
|
31
25
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
yield this._mu.lock(oldPath);
|
|
38
|
-
yield this._fs.rename(oldPath, newPath, cred);
|
|
39
|
-
this._mu.unlock(oldPath);
|
|
40
|
-
});
|
|
26
|
+
async rename(oldPath, newPath, cred) {
|
|
27
|
+
await this._mu.lock(oldPath);
|
|
28
|
+
await this.fs.rename(oldPath, newPath, cred);
|
|
29
|
+
this._mu.unlock(oldPath);
|
|
41
30
|
}
|
|
42
31
|
renameSync(oldPath, newPath, cred) {
|
|
43
32
|
if (this._mu.isLocked(oldPath)) {
|
|
44
33
|
throw new Error('invalid sync call');
|
|
45
34
|
}
|
|
46
|
-
return this.
|
|
35
|
+
return this.fs.renameSync(oldPath, newPath, cred);
|
|
47
36
|
}
|
|
48
|
-
stat(p, cred) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return stats;
|
|
54
|
-
});
|
|
37
|
+
async stat(p, cred) {
|
|
38
|
+
await this._mu.lock(p);
|
|
39
|
+
const stats = await this.fs.stat(p, cred);
|
|
40
|
+
this._mu.unlock(p);
|
|
41
|
+
return stats;
|
|
55
42
|
}
|
|
56
43
|
statSync(p, cred) {
|
|
57
44
|
if (this._mu.isLocked(p)) {
|
|
58
45
|
throw new Error('invalid sync call');
|
|
59
46
|
}
|
|
60
|
-
return this.
|
|
47
|
+
return this.fs.statSync(p, cred);
|
|
61
48
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
49
|
+
async openFile(path, flag, cred) {
|
|
50
|
+
await this._mu.lock(path);
|
|
51
|
+
const fd = await this.fs.openFile(path, flag, cred);
|
|
52
|
+
this._mu.unlock(path);
|
|
53
|
+
return fd;
|
|
68
54
|
}
|
|
69
|
-
|
|
70
|
-
if (this._mu.isLocked(
|
|
55
|
+
openFileSync(path, flag, cred) {
|
|
56
|
+
if (this._mu.isLocked(path)) {
|
|
71
57
|
throw new Error('invalid sync call');
|
|
72
58
|
}
|
|
73
|
-
return this.
|
|
59
|
+
return this.fs.openFileSync(path, flag, cred);
|
|
74
60
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return fd;
|
|
81
|
-
});
|
|
61
|
+
async createFile(path, flag, mode, cred) {
|
|
62
|
+
await this._mu.lock(path);
|
|
63
|
+
const fd = await this.fs.createFile(path, flag, mode, cred);
|
|
64
|
+
this._mu.unlock(path);
|
|
65
|
+
return fd;
|
|
82
66
|
}
|
|
83
|
-
|
|
84
|
-
if (this._mu.isLocked(
|
|
67
|
+
createFileSync(path, flag, mode, cred) {
|
|
68
|
+
if (this._mu.isLocked(path)) {
|
|
85
69
|
throw new Error('invalid sync call');
|
|
86
70
|
}
|
|
87
|
-
return this.
|
|
71
|
+
return this.fs.createFileSync(path, flag, mode, cred);
|
|
88
72
|
}
|
|
89
|
-
unlink(p, cred) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this._mu.unlock(p);
|
|
94
|
-
});
|
|
73
|
+
async unlink(p, cred) {
|
|
74
|
+
await this._mu.lock(p);
|
|
75
|
+
await this.fs.unlink(p, cred);
|
|
76
|
+
this._mu.unlock(p);
|
|
95
77
|
}
|
|
96
78
|
unlinkSync(p, cred) {
|
|
97
79
|
if (this._mu.isLocked(p)) {
|
|
98
80
|
throw new Error('invalid sync call');
|
|
99
81
|
}
|
|
100
|
-
return this.
|
|
82
|
+
return this.fs.unlinkSync(p, cred);
|
|
101
83
|
}
|
|
102
|
-
rmdir(p, cred) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this._mu.unlock(p);
|
|
107
|
-
});
|
|
84
|
+
async rmdir(p, cred) {
|
|
85
|
+
await this._mu.lock(p);
|
|
86
|
+
await this.fs.rmdir(p, cred);
|
|
87
|
+
this._mu.unlock(p);
|
|
108
88
|
}
|
|
109
89
|
rmdirSync(p, cred) {
|
|
110
90
|
if (this._mu.isLocked(p)) {
|
|
111
91
|
throw new Error('invalid sync call');
|
|
112
92
|
}
|
|
113
|
-
return this.
|
|
93
|
+
return this.fs.rmdirSync(p, cred);
|
|
114
94
|
}
|
|
115
|
-
mkdir(p, mode, cred) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this._mu.unlock(p);
|
|
120
|
-
});
|
|
95
|
+
async mkdir(p, mode, cred) {
|
|
96
|
+
await this._mu.lock(p);
|
|
97
|
+
await this.fs.mkdir(p, mode, cred);
|
|
98
|
+
this._mu.unlock(p);
|
|
121
99
|
}
|
|
122
100
|
mkdirSync(p, mode, cred) {
|
|
123
101
|
if (this._mu.isLocked(p)) {
|
|
124
102
|
throw new Error('invalid sync call');
|
|
125
103
|
}
|
|
126
|
-
return this.
|
|
104
|
+
return this.fs.mkdirSync(p, mode, cred);
|
|
127
105
|
}
|
|
128
|
-
readdir(p, cred) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return files;
|
|
134
|
-
});
|
|
106
|
+
async readdir(p, cred) {
|
|
107
|
+
await this._mu.lock(p);
|
|
108
|
+
const files = await this.fs.readdir(p, cred);
|
|
109
|
+
this._mu.unlock(p);
|
|
110
|
+
return files;
|
|
135
111
|
}
|
|
136
112
|
readdirSync(p, cred) {
|
|
137
113
|
if (this._mu.isLocked(p)) {
|
|
138
114
|
throw new Error('invalid sync call');
|
|
139
115
|
}
|
|
140
|
-
return this.
|
|
116
|
+
return this.fs.readdirSync(p, cred);
|
|
141
117
|
}
|
|
142
|
-
exists(p, cred) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return exists;
|
|
148
|
-
});
|
|
118
|
+
async exists(p, cred) {
|
|
119
|
+
await this._mu.lock(p);
|
|
120
|
+
const exists = await this.fs.exists(p, cred);
|
|
121
|
+
this._mu.unlock(p);
|
|
122
|
+
return exists;
|
|
149
123
|
}
|
|
150
124
|
existsSync(p, cred) {
|
|
151
125
|
if (this._mu.isLocked(p)) {
|
|
152
126
|
throw new Error('invalid sync call');
|
|
153
127
|
}
|
|
154
|
-
return this.
|
|
155
|
-
}
|
|
156
|
-
realpath(p, cred) {
|
|
157
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
yield this._mu.lock(p);
|
|
159
|
-
const resolvedPath = yield this._fs.realpath(p, cred);
|
|
160
|
-
this._mu.unlock(p);
|
|
161
|
-
return resolvedPath;
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
realpathSync(p, cred) {
|
|
165
|
-
if (this._mu.isLocked(p)) {
|
|
166
|
-
throw new Error('invalid sync call');
|
|
167
|
-
}
|
|
168
|
-
return this._fs.realpathSync(p, cred);
|
|
169
|
-
}
|
|
170
|
-
truncate(p, len, cred) {
|
|
171
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
yield this._mu.lock(p);
|
|
173
|
-
yield this._fs.truncate(p, len, cred);
|
|
174
|
-
this._mu.unlock(p);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
truncateSync(p, len, cred) {
|
|
178
|
-
if (this._mu.isLocked(p)) {
|
|
179
|
-
throw new Error('invalid sync call');
|
|
180
|
-
}
|
|
181
|
-
return this._fs.truncateSync(p, len, cred);
|
|
182
|
-
}
|
|
183
|
-
readFile(fname, flag, cred) {
|
|
184
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
yield this._mu.lock(fname);
|
|
186
|
-
const data = yield this._fs.readFile(fname, flag, cred);
|
|
187
|
-
this._mu.unlock(fname);
|
|
188
|
-
return data;
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
readFileSync(fname, flag, cred) {
|
|
192
|
-
if (this._mu.isLocked(fname)) {
|
|
193
|
-
throw new Error('invalid sync call');
|
|
194
|
-
}
|
|
195
|
-
return this._fs.readFileSync(fname, flag, cred);
|
|
196
|
-
}
|
|
197
|
-
writeFile(fname, data, flag, mode, cred) {
|
|
198
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
-
yield this._mu.lock(fname);
|
|
200
|
-
yield this._fs.writeFile(fname, data, flag, mode, cred);
|
|
201
|
-
this._mu.unlock(fname);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
writeFileSync(fname, data, flag, mode, cred) {
|
|
205
|
-
if (this._mu.isLocked(fname)) {
|
|
206
|
-
throw new Error('invalid sync call');
|
|
207
|
-
}
|
|
208
|
-
return this._fs.writeFileSync(fname, data, flag, mode, cred);
|
|
209
|
-
}
|
|
210
|
-
appendFile(fname, data, flag, mode, cred) {
|
|
211
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
-
yield this._mu.lock(fname);
|
|
213
|
-
yield this._fs.appendFile(fname, data, flag, mode, cred);
|
|
214
|
-
this._mu.unlock(fname);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
appendFileSync(fname, data, flag, mode, cred) {
|
|
218
|
-
if (this._mu.isLocked(fname)) {
|
|
219
|
-
throw new Error('invalid sync call');
|
|
220
|
-
}
|
|
221
|
-
return this._fs.appendFileSync(fname, data, flag, mode, cred);
|
|
222
|
-
}
|
|
223
|
-
chmod(p, mode, cred) {
|
|
224
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
-
yield this._mu.lock(p);
|
|
226
|
-
yield this._fs.chmod(p, mode, cred);
|
|
227
|
-
this._mu.unlock(p);
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
chmodSync(p, mode, cred) {
|
|
231
|
-
if (this._mu.isLocked(p)) {
|
|
232
|
-
throw new Error('invalid sync call');
|
|
233
|
-
}
|
|
234
|
-
return this._fs.chmodSync(p, mode, cred);
|
|
235
|
-
}
|
|
236
|
-
chown(p, new_uid, new_gid, cred) {
|
|
237
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
-
yield this._mu.lock(p);
|
|
239
|
-
yield this._fs.chown(p, new_uid, new_gid, cred);
|
|
240
|
-
this._mu.unlock(p);
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
chownSync(p, new_uid, new_gid, cred) {
|
|
244
|
-
if (this._mu.isLocked(p)) {
|
|
245
|
-
throw new Error('invalid sync call');
|
|
246
|
-
}
|
|
247
|
-
return this._fs.chownSync(p, new_uid, new_gid, cred);
|
|
128
|
+
return this.fs.existsSync(p, cred);
|
|
248
129
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
this._mu.unlock(p);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
utimesSync(p, atime, mtime, cred) {
|
|
257
|
-
if (this._mu.isLocked(p)) {
|
|
258
|
-
throw new Error('invalid sync call');
|
|
259
|
-
}
|
|
260
|
-
return this._fs.utimesSync(p, atime, mtime, cred);
|
|
261
|
-
}
|
|
262
|
-
link(srcpath, dstpath, cred) {
|
|
263
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
264
|
-
yield this._mu.lock(srcpath);
|
|
265
|
-
yield this._fs.link(srcpath, dstpath, cred);
|
|
266
|
-
this._mu.unlock(srcpath);
|
|
267
|
-
});
|
|
130
|
+
async link(srcpath, dstpath, cred) {
|
|
131
|
+
await this._mu.lock(srcpath);
|
|
132
|
+
await this.fs.link(srcpath, dstpath, cred);
|
|
133
|
+
this._mu.unlock(srcpath);
|
|
268
134
|
}
|
|
269
135
|
linkSync(srcpath, dstpath, cred) {
|
|
270
136
|
if (this._mu.isLocked(srcpath)) {
|
|
271
137
|
throw new Error('invalid sync call');
|
|
272
138
|
}
|
|
273
|
-
return this.
|
|
139
|
+
return this.fs.linkSync(srcpath, dstpath, cred);
|
|
274
140
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
this._mu.unlock(srcpath);
|
|
280
|
-
});
|
|
141
|
+
async sync(path, data, stats) {
|
|
142
|
+
await this._mu.lock(path);
|
|
143
|
+
await this.fs.sync(path, data, stats);
|
|
144
|
+
this._mu.unlock(path);
|
|
281
145
|
}
|
|
282
|
-
|
|
283
|
-
if (this._mu.isLocked(
|
|
284
|
-
throw new Error('invalid sync call');
|
|
285
|
-
}
|
|
286
|
-
return this._fs.symlinkSync(srcpath, dstpath, type, cred);
|
|
287
|
-
}
|
|
288
|
-
readlink(p, cred) {
|
|
289
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
290
|
-
yield this._mu.lock(p);
|
|
291
|
-
const linkString = yield this._fs.readlink(p, cred);
|
|
292
|
-
this._mu.unlock(p);
|
|
293
|
-
return linkString;
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
readlinkSync(p, cred) {
|
|
297
|
-
if (this._mu.isLocked(p)) {
|
|
146
|
+
syncSync(path, data, stats) {
|
|
147
|
+
if (this._mu.isLocked(path)) {
|
|
298
148
|
throw new Error('invalid sync call');
|
|
299
149
|
}
|
|
300
|
-
return this.
|
|
150
|
+
return this.fs.syncSync(path, data, stats);
|
|
301
151
|
}
|
|
302
152
|
}
|