@zenfs/core 0.0.1
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/README.md +293 -0
- package/dist/ApiError.d.ts +86 -0
- package/dist/ApiError.js +135 -0
- package/dist/backends/AsyncMirror.d.ts +102 -0
- package/dist/backends/AsyncMirror.js +252 -0
- package/dist/backends/AsyncStore.d.ts +166 -0
- package/dist/backends/AsyncStore.js +620 -0
- package/dist/backends/FolderAdapter.d.ts +52 -0
- package/dist/backends/FolderAdapter.js +184 -0
- package/dist/backends/InMemory.d.ts +25 -0
- package/dist/backends/InMemory.js +46 -0
- package/dist/backends/Locked.d.ts +64 -0
- package/dist/backends/Locked.js +302 -0
- package/dist/backends/OverlayFS.d.ts +120 -0
- package/dist/backends/OverlayFS.js +749 -0
- package/dist/backends/SyncStore.d.ts +223 -0
- package/dist/backends/SyncStore.js +479 -0
- package/dist/backends/backend.d.ts +73 -0
- package/dist/backends/backend.js +14 -0
- package/dist/backends/index.d.ts +11 -0
- package/dist/backends/index.js +15 -0
- package/dist/browser.min.js +12 -0
- package/dist/browser.min.js.map +7 -0
- package/dist/cred.d.ts +14 -0
- package/dist/cred.js +15 -0
- package/dist/emulation/callbacks.d.ts +382 -0
- package/dist/emulation/callbacks.js +422 -0
- package/dist/emulation/constants.d.ts +101 -0
- package/dist/emulation/constants.js +110 -0
- package/dist/emulation/fs.d.ts +7 -0
- package/dist/emulation/fs.js +5 -0
- package/dist/emulation/index.d.ts +5 -0
- package/dist/emulation/index.js +7 -0
- package/dist/emulation/promises.d.ts +309 -0
- package/dist/emulation/promises.js +521 -0
- package/dist/emulation/shared.d.ts +62 -0
- package/dist/emulation/shared.js +192 -0
- package/dist/emulation/sync.d.ts +278 -0
- package/dist/emulation/sync.js +392 -0
- package/dist/file.d.ts +449 -0
- package/dist/file.js +576 -0
- package/dist/filesystem.d.ts +367 -0
- package/dist/filesystem.js +542 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +113 -0
- package/dist/inode.d.ts +51 -0
- package/dist/inode.js +112 -0
- package/dist/mutex.d.ts +12 -0
- package/dist/mutex.js +48 -0
- package/dist/stats.d.ts +98 -0
- package/dist/stats.js +226 -0
- package/dist/utils.d.ts +52 -0
- package/dist/utils.js +261 -0
- package/license.md +122 -0
- package/package.json +61 -0
|
@@ -0,0 +1,184 @@
|
|
|
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
|
+
var _a;
|
|
11
|
+
import { BaseFileSystem } from '../filesystem';
|
|
12
|
+
import * as path from 'path';
|
|
13
|
+
import { ApiError } from '../ApiError';
|
|
14
|
+
import { Cred } from '../cred';
|
|
15
|
+
import { CreateBackend } from './backend';
|
|
16
|
+
/**
|
|
17
|
+
* The FolderAdapter file system wraps a file system, and scopes all interactions to a subfolder of that file system.
|
|
18
|
+
*
|
|
19
|
+
* Example: Given a file system `foo` with folder `bar` and file `bar/baz`...
|
|
20
|
+
*
|
|
21
|
+
* ```javascript
|
|
22
|
+
* ZenFS.configure({
|
|
23
|
+
* fs: "FolderAdapter",
|
|
24
|
+
* options: {
|
|
25
|
+
* folder: "bar",
|
|
26
|
+
* wrapped: foo
|
|
27
|
+
* }
|
|
28
|
+
* }, function(e) {
|
|
29
|
+
* var fs = ZenFS.BFSRequire('fs');
|
|
30
|
+
* fs.readdirSync('/'); // ['baz']
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export class FolderAdapter extends BaseFileSystem {
|
|
35
|
+
static isAvailable() {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
constructor({ folder, wrapped }) {
|
|
39
|
+
super();
|
|
40
|
+
this._folder = folder;
|
|
41
|
+
this._wrapped = wrapped;
|
|
42
|
+
this._ready = this._initialize();
|
|
43
|
+
}
|
|
44
|
+
get metadata() {
|
|
45
|
+
return Object.assign(Object.assign(Object.assign({}, super.metadata), this._wrapped.metadata), { supportsLinks: false });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Initialize the file system. Ensures that the wrapped file system
|
|
49
|
+
* has the given folder.
|
|
50
|
+
*/
|
|
51
|
+
_initialize() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const exists = yield this._wrapped.exists(this._folder, Cred.Root);
|
|
54
|
+
if (!exists && this._wrapped.metadata.readonly) {
|
|
55
|
+
throw ApiError.ENOENT(this._folder);
|
|
56
|
+
}
|
|
57
|
+
yield this._wrapped.mkdir(this._folder, 0o777, Cred.Root);
|
|
58
|
+
return this;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
_a = FolderAdapter;
|
|
63
|
+
FolderAdapter.Name = 'FolderAdapter';
|
|
64
|
+
FolderAdapter.Create = CreateBackend.bind(_a);
|
|
65
|
+
FolderAdapter.Options = {
|
|
66
|
+
folder: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
description: 'The folder to use as the root directory',
|
|
69
|
+
},
|
|
70
|
+
wrapped: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
description: 'The file system to wrap',
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
function translateError(folder, e) {
|
|
79
|
+
if (e !== null && typeof e === 'object') {
|
|
80
|
+
const err = e;
|
|
81
|
+
let p = err.path;
|
|
82
|
+
if (p) {
|
|
83
|
+
p = '/' + path.relative(folder, p);
|
|
84
|
+
err.message = err.message.replace(err.path, p);
|
|
85
|
+
err.path = p;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return e;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
function wrapCallback(folder, cb) {
|
|
94
|
+
if (typeof cb === 'function') {
|
|
95
|
+
return function (err) {
|
|
96
|
+
if (arguments.length > 0) {
|
|
97
|
+
arguments[0] = translateError(folder, err);
|
|
98
|
+
}
|
|
99
|
+
cb.apply(null, arguments);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return cb;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
function wrapFunction(name, wrapFirst, wrapSecond) {
|
|
110
|
+
if (name.slice(name.length - 4) !== 'Sync') {
|
|
111
|
+
// Async function. Translate error in callback.
|
|
112
|
+
return function () {
|
|
113
|
+
if (arguments.length > 0) {
|
|
114
|
+
if (wrapFirst) {
|
|
115
|
+
arguments[0] = path.join(this._folder, arguments[0]);
|
|
116
|
+
}
|
|
117
|
+
if (wrapSecond) {
|
|
118
|
+
arguments[1] = path.join(this._folder, arguments[1]);
|
|
119
|
+
}
|
|
120
|
+
arguments[arguments.length - 1] = wrapCallback(this._folder, arguments[arguments.length - 1]);
|
|
121
|
+
}
|
|
122
|
+
return this._wrapped[name].apply(this._wrapped, arguments);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Sync function. Translate error in catch.
|
|
127
|
+
return function () {
|
|
128
|
+
try {
|
|
129
|
+
if (wrapFirst) {
|
|
130
|
+
arguments[0] = path.join(this._folder, arguments[0]);
|
|
131
|
+
}
|
|
132
|
+
if (wrapSecond) {
|
|
133
|
+
arguments[1] = path.join(this._folder, arguments[1]);
|
|
134
|
+
}
|
|
135
|
+
return this._wrapped[name].apply(this._wrapped, arguments);
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
throw translateError(this._folder, e);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// First argument is a path.
|
|
144
|
+
[
|
|
145
|
+
'diskSpace',
|
|
146
|
+
'stat',
|
|
147
|
+
'statSync',
|
|
148
|
+
'open',
|
|
149
|
+
'openSync',
|
|
150
|
+
'unlink',
|
|
151
|
+
'unlinkSync',
|
|
152
|
+
'rmdir',
|
|
153
|
+
'rmdirSync',
|
|
154
|
+
'mkdir',
|
|
155
|
+
'mkdirSync',
|
|
156
|
+
'readdir',
|
|
157
|
+
'readdirSync',
|
|
158
|
+
'exists',
|
|
159
|
+
'existsSync',
|
|
160
|
+
'realpath',
|
|
161
|
+
'realpathSync',
|
|
162
|
+
'truncate',
|
|
163
|
+
'truncateSync',
|
|
164
|
+
'readFile',
|
|
165
|
+
'readFileSync',
|
|
166
|
+
'writeFile',
|
|
167
|
+
'writeFileSync',
|
|
168
|
+
'appendFile',
|
|
169
|
+
'appendFileSync',
|
|
170
|
+
'chmod',
|
|
171
|
+
'chmodSync',
|
|
172
|
+
'chown',
|
|
173
|
+
'chownSync',
|
|
174
|
+
'utimes',
|
|
175
|
+
'utimesSync',
|
|
176
|
+
'readlink',
|
|
177
|
+
'readlinkSync',
|
|
178
|
+
].forEach((name) => {
|
|
179
|
+
FolderAdapter.prototype[name] = wrapFunction(name, true, false);
|
|
180
|
+
});
|
|
181
|
+
// First and second arguments are paths.
|
|
182
|
+
['rename', 'renameSync', 'link', 'linkSync', 'symlink', 'symlinkSync'].forEach((name) => {
|
|
183
|
+
FolderAdapter.prototype[name] = wrapFunction(name, true, true);
|
|
184
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SyncKeyValueStore, SimpleSyncStore, SyncKeyValueRWTransaction, SyncKeyValueFileSystem } from './SyncStore';
|
|
3
|
+
import { type BackendOptions } from './backend';
|
|
4
|
+
/**
|
|
5
|
+
* A simple in-memory key-value store backed by a JavaScript object.
|
|
6
|
+
*/
|
|
7
|
+
export declare class InMemoryStore implements SyncKeyValueStore, SimpleSyncStore {
|
|
8
|
+
private store;
|
|
9
|
+
name(): string;
|
|
10
|
+
clear(): void;
|
|
11
|
+
beginTransaction(type: string): SyncKeyValueRWTransaction;
|
|
12
|
+
get(key: string): Buffer;
|
|
13
|
+
put(key: string, data: Buffer, overwrite: boolean): boolean;
|
|
14
|
+
del(key: string): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A simple in-memory file system backed by an InMemoryStore.
|
|
18
|
+
* Files are not persisted across page loads.
|
|
19
|
+
*/
|
|
20
|
+
export declare class InMemoryFileSystem extends SyncKeyValueFileSystem {
|
|
21
|
+
static readonly Name = "InMemory";
|
|
22
|
+
static Create: any;
|
|
23
|
+
static readonly Options: BackendOptions;
|
|
24
|
+
constructor();
|
|
25
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { SimpleSyncRWTransaction, SyncKeyValueFileSystem } from './SyncStore';
|
|
3
|
+
import { CreateBackend } from './backend';
|
|
4
|
+
/**
|
|
5
|
+
* A simple in-memory key-value store backed by a JavaScript object.
|
|
6
|
+
*/
|
|
7
|
+
export class InMemoryStore {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.store = new Map();
|
|
10
|
+
}
|
|
11
|
+
name() {
|
|
12
|
+
return InMemoryFileSystem.Name;
|
|
13
|
+
}
|
|
14
|
+
clear() {
|
|
15
|
+
this.store.clear();
|
|
16
|
+
}
|
|
17
|
+
beginTransaction(type) {
|
|
18
|
+
return new SimpleSyncRWTransaction(this);
|
|
19
|
+
}
|
|
20
|
+
get(key) {
|
|
21
|
+
return this.store.get(key);
|
|
22
|
+
}
|
|
23
|
+
put(key, data, overwrite) {
|
|
24
|
+
if (!overwrite && this.store.has(key)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
this.store.set(key, data);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
del(key) {
|
|
31
|
+
this.store.delete(key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A simple in-memory file system backed by an InMemoryStore.
|
|
36
|
+
* Files are not persisted across page loads.
|
|
37
|
+
*/
|
|
38
|
+
export class InMemoryFileSystem extends SyncKeyValueFileSystem {
|
|
39
|
+
constructor() {
|
|
40
|
+
super({ store: new InMemoryStore() });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
_a = InMemoryFileSystem;
|
|
44
|
+
InMemoryFileSystem.Name = 'InMemory';
|
|
45
|
+
InMemoryFileSystem.Create = CreateBackend.bind(_a);
|
|
46
|
+
InMemoryFileSystem.Options = {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { FileContents, FileSystem, FileSystemMetadata } from '../filesystem';
|
|
3
|
+
import { FileFlag } from '../file';
|
|
4
|
+
import { Stats } from '../stats';
|
|
5
|
+
import { File } from '../file';
|
|
6
|
+
import { Cred } from '../cred';
|
|
7
|
+
/**
|
|
8
|
+
* This class serializes access to an underlying async filesystem.
|
|
9
|
+
* For example, on an OverlayFS instance with an async lower
|
|
10
|
+
* directory operations like rename and rmdir may involve multiple
|
|
11
|
+
* requests involving both the upper and lower filesystems -- they
|
|
12
|
+
* are not executed in a single atomic step. OverlayFS uses this
|
|
13
|
+
* LockedFS to avoid having to reason about the correctness of
|
|
14
|
+
* multiple requests interleaving.
|
|
15
|
+
*/
|
|
16
|
+
export default class LockedFS<T extends FileSystem> implements FileSystem {
|
|
17
|
+
private _fs;
|
|
18
|
+
private _mu;
|
|
19
|
+
protected _ready: Promise<this>;
|
|
20
|
+
constructor(fs: T);
|
|
21
|
+
whenReady(): Promise<this>;
|
|
22
|
+
get metadata(): FileSystemMetadata;
|
|
23
|
+
get fs(): T;
|
|
24
|
+
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
25
|
+
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
26
|
+
stat(p: string, cred: Cred): Promise<Stats>;
|
|
27
|
+
statSync(p: string, cred: Cred): Stats;
|
|
28
|
+
access(p: string, mode: number, cred: Cred): Promise<void>;
|
|
29
|
+
accessSync(p: string, mode: number, cred: Cred): void;
|
|
30
|
+
open(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
|
|
31
|
+
openSync(p: string, flag: FileFlag, mode: number, cred: Cred): File;
|
|
32
|
+
unlink(p: string, cred: Cred): Promise<void>;
|
|
33
|
+
unlinkSync(p: string, cred: Cred): void;
|
|
34
|
+
rmdir(p: string, cred: Cred): Promise<void>;
|
|
35
|
+
rmdirSync(p: string, cred: Cred): void;
|
|
36
|
+
mkdir(p: string, mode: number, cred: Cred): Promise<void>;
|
|
37
|
+
mkdirSync(p: string, mode: number, cred: Cred): void;
|
|
38
|
+
readdir(p: string, cred: Cred): Promise<string[]>;
|
|
39
|
+
readdirSync(p: string, cred: Cred): string[];
|
|
40
|
+
exists(p: string, cred: Cred): Promise<boolean>;
|
|
41
|
+
existsSync(p: string, cred: Cred): boolean;
|
|
42
|
+
realpath(p: string, cred: Cred): Promise<string>;
|
|
43
|
+
realpathSync(p: string, cred: Cred): string;
|
|
44
|
+
truncate(p: string, len: number, cred: Cred): Promise<void>;
|
|
45
|
+
truncateSync(p: string, len: number, cred: Cred): void;
|
|
46
|
+
readFile(fname: string, encoding: BufferEncoding, flag: FileFlag, cred: Cred): Promise<FileContents>;
|
|
47
|
+
readFileSync(fname: string, encoding: BufferEncoding, flag: FileFlag, cred: Cred): FileContents;
|
|
48
|
+
writeFile(fname: string, data: FileContents, encoding: BufferEncoding, flag: FileFlag, mode: number, cred: Cred): Promise<void>;
|
|
49
|
+
writeFileSync(fname: string, data: FileContents, encoding: BufferEncoding, flag: FileFlag, mode: number, cred: Cred): void;
|
|
50
|
+
appendFile(fname: string, data: FileContents, encoding: BufferEncoding, flag: FileFlag, mode: number, cred: Cred): Promise<void>;
|
|
51
|
+
appendFileSync(fname: string, data: FileContents, encoding: BufferEncoding, flag: FileFlag, mode: number, cred: Cred): void;
|
|
52
|
+
chmod(p: string, mode: number, cred: Cred): Promise<void>;
|
|
53
|
+
chmodSync(p: string, mode: number, cred: Cred): void;
|
|
54
|
+
chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void>;
|
|
55
|
+
chownSync(p: string, new_uid: number, new_gid: number, cred: Cred): void;
|
|
56
|
+
utimes(p: string, atime: Date, mtime: Date, cred: Cred): Promise<void>;
|
|
57
|
+
utimesSync(p: string, atime: Date, mtime: Date, cred: Cred): void;
|
|
58
|
+
link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
|
|
59
|
+
linkSync(srcpath: string, dstpath: string, cred: Cred): void;
|
|
60
|
+
symlink(srcpath: string, dstpath: string, type: string, cred: Cred): Promise<void>;
|
|
61
|
+
symlinkSync(srcpath: string, dstpath: string, type: string, cred: Cred): void;
|
|
62
|
+
readlink(p: string, cred: Cred): Promise<string>;
|
|
63
|
+
readlinkSync(p: string, cred: Cred): string;
|
|
64
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
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
|
+
import Mutex from '../mutex';
|
|
11
|
+
/**
|
|
12
|
+
* This class serializes access to an underlying async filesystem.
|
|
13
|
+
* For example, on an OverlayFS instance with an async lower
|
|
14
|
+
* directory operations like rename and rmdir may involve multiple
|
|
15
|
+
* requests involving both the upper and lower filesystems -- they
|
|
16
|
+
* are not executed in a single atomic step. OverlayFS uses this
|
|
17
|
+
* LockedFS to avoid having to reason about the correctness of
|
|
18
|
+
* multiple requests interleaving.
|
|
19
|
+
*/
|
|
20
|
+
export default class LockedFS {
|
|
21
|
+
constructor(fs) {
|
|
22
|
+
this._ready = Promise.resolve(this);
|
|
23
|
+
this._fs = fs;
|
|
24
|
+
this._mu = new Mutex();
|
|
25
|
+
}
|
|
26
|
+
whenReady() {
|
|
27
|
+
return this._ready;
|
|
28
|
+
}
|
|
29
|
+
get metadata() {
|
|
30
|
+
return Object.assign(Object.assign({}, this._fs.metadata), { name: 'LockedFS<' + this._fs.metadata.name + '>' });
|
|
31
|
+
}
|
|
32
|
+
get fs() {
|
|
33
|
+
return this._fs;
|
|
34
|
+
}
|
|
35
|
+
rename(oldPath, newPath, cred) {
|
|
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
|
+
});
|
|
41
|
+
}
|
|
42
|
+
renameSync(oldPath, newPath, cred) {
|
|
43
|
+
if (this._mu.isLocked(oldPath)) {
|
|
44
|
+
throw new Error('invalid sync call');
|
|
45
|
+
}
|
|
46
|
+
return this._fs.renameSync(oldPath, newPath, cred);
|
|
47
|
+
}
|
|
48
|
+
stat(p, cred) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
yield this._mu.lock(p);
|
|
51
|
+
const stats = yield this._fs.stat(p, cred);
|
|
52
|
+
this._mu.unlock(p);
|
|
53
|
+
return stats;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
statSync(p, cred) {
|
|
57
|
+
if (this._mu.isLocked(p)) {
|
|
58
|
+
throw new Error('invalid sync call');
|
|
59
|
+
}
|
|
60
|
+
return this._fs.statSync(p, cred);
|
|
61
|
+
}
|
|
62
|
+
access(p, mode, cred) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
yield this._mu.lock(p);
|
|
65
|
+
yield this._fs.access(p, mode, cred);
|
|
66
|
+
this._mu.unlock(p);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
accessSync(p, mode, cred) {
|
|
70
|
+
if (this._mu.isLocked(p)) {
|
|
71
|
+
throw new Error('invalid sync call');
|
|
72
|
+
}
|
|
73
|
+
return this._fs.accessSync(p, mode, cred);
|
|
74
|
+
}
|
|
75
|
+
open(p, flag, mode, cred) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
yield this._mu.lock(p);
|
|
78
|
+
const fd = yield this._fs.open(p, flag, mode, cred);
|
|
79
|
+
this._mu.unlock(p);
|
|
80
|
+
return fd;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
openSync(p, flag, mode, cred) {
|
|
84
|
+
if (this._mu.isLocked(p)) {
|
|
85
|
+
throw new Error('invalid sync call');
|
|
86
|
+
}
|
|
87
|
+
return this._fs.openSync(p, flag, mode, cred);
|
|
88
|
+
}
|
|
89
|
+
unlink(p, cred) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
yield this._mu.lock(p);
|
|
92
|
+
yield this._fs.unlink(p, cred);
|
|
93
|
+
this._mu.unlock(p);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
unlinkSync(p, cred) {
|
|
97
|
+
if (this._mu.isLocked(p)) {
|
|
98
|
+
throw new Error('invalid sync call');
|
|
99
|
+
}
|
|
100
|
+
return this._fs.unlinkSync(p, cred);
|
|
101
|
+
}
|
|
102
|
+
rmdir(p, cred) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
yield this._mu.lock(p);
|
|
105
|
+
yield this._fs.rmdir(p, cred);
|
|
106
|
+
this._mu.unlock(p);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
rmdirSync(p, cred) {
|
|
110
|
+
if (this._mu.isLocked(p)) {
|
|
111
|
+
throw new Error('invalid sync call');
|
|
112
|
+
}
|
|
113
|
+
return this._fs.rmdirSync(p, cred);
|
|
114
|
+
}
|
|
115
|
+
mkdir(p, mode, cred) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
yield this._mu.lock(p);
|
|
118
|
+
yield this._fs.mkdir(p, mode, cred);
|
|
119
|
+
this._mu.unlock(p);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
mkdirSync(p, mode, cred) {
|
|
123
|
+
if (this._mu.isLocked(p)) {
|
|
124
|
+
throw new Error('invalid sync call');
|
|
125
|
+
}
|
|
126
|
+
return this._fs.mkdirSync(p, mode, cred);
|
|
127
|
+
}
|
|
128
|
+
readdir(p, cred) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
yield this._mu.lock(p);
|
|
131
|
+
const files = yield this._fs.readdir(p, cred);
|
|
132
|
+
this._mu.unlock(p);
|
|
133
|
+
return files;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
readdirSync(p, cred) {
|
|
137
|
+
if (this._mu.isLocked(p)) {
|
|
138
|
+
throw new Error('invalid sync call');
|
|
139
|
+
}
|
|
140
|
+
return this._fs.readdirSync(p, cred);
|
|
141
|
+
}
|
|
142
|
+
exists(p, cred) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
yield this._mu.lock(p);
|
|
145
|
+
const exists = yield this._fs.exists(p, cred);
|
|
146
|
+
this._mu.unlock(p);
|
|
147
|
+
return exists;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
existsSync(p, cred) {
|
|
151
|
+
if (this._mu.isLocked(p)) {
|
|
152
|
+
throw new Error('invalid sync call');
|
|
153
|
+
}
|
|
154
|
+
return this._fs.existsSync(p, cred);
|
|
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, encoding, 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, encoding, flag, cred);
|
|
187
|
+
this._mu.unlock(fname);
|
|
188
|
+
return data;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
readFileSync(fname, encoding, flag, cred) {
|
|
192
|
+
if (this._mu.isLocked(fname)) {
|
|
193
|
+
throw new Error('invalid sync call');
|
|
194
|
+
}
|
|
195
|
+
return this._fs.readFileSync(fname, encoding, flag, cred);
|
|
196
|
+
}
|
|
197
|
+
writeFile(fname, data, encoding, 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, encoding, flag, mode, cred);
|
|
201
|
+
this._mu.unlock(fname);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
writeFileSync(fname, data, encoding, flag, mode, cred) {
|
|
205
|
+
if (this._mu.isLocked(fname)) {
|
|
206
|
+
throw new Error('invalid sync call');
|
|
207
|
+
}
|
|
208
|
+
return this._fs.writeFileSync(fname, data, encoding, flag, mode, cred);
|
|
209
|
+
}
|
|
210
|
+
appendFile(fname, data, encoding, 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, encoding, flag, mode, cred);
|
|
214
|
+
this._mu.unlock(fname);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
appendFileSync(fname, data, encoding, flag, mode, cred) {
|
|
218
|
+
if (this._mu.isLocked(fname)) {
|
|
219
|
+
throw new Error('invalid sync call');
|
|
220
|
+
}
|
|
221
|
+
return this._fs.appendFileSync(fname, data, encoding, 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);
|
|
248
|
+
}
|
|
249
|
+
utimes(p, atime, mtime, cred) {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
+
yield this._mu.lock(p);
|
|
252
|
+
yield this._fs.utimes(p, atime, mtime, cred);
|
|
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
|
+
});
|
|
268
|
+
}
|
|
269
|
+
linkSync(srcpath, dstpath, cred) {
|
|
270
|
+
if (this._mu.isLocked(srcpath)) {
|
|
271
|
+
throw new Error('invalid sync call');
|
|
272
|
+
}
|
|
273
|
+
return this._fs.linkSync(srcpath, dstpath, cred);
|
|
274
|
+
}
|
|
275
|
+
symlink(srcpath, dstpath, type, cred) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
+
yield this._mu.lock(srcpath);
|
|
278
|
+
yield this._fs.symlink(srcpath, dstpath, type, cred);
|
|
279
|
+
this._mu.unlock(srcpath);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
symlinkSync(srcpath, dstpath, type, cred) {
|
|
283
|
+
if (this._mu.isLocked(srcpath)) {
|
|
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)) {
|
|
298
|
+
throw new Error('invalid sync call');
|
|
299
|
+
}
|
|
300
|
+
return this._fs.readlinkSync(p, cred);
|
|
301
|
+
}
|
|
302
|
+
}
|