core-3nweb-client-lib 0.41.3 → 0.41.5
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.
|
@@ -38,6 +38,7 @@ export declare class DeviceFS implements WritableFS, Linkable {
|
|
|
38
38
|
static makeWritable(root: string, create?: boolean, exclusive?: boolean): Promise<WritableFS>;
|
|
39
39
|
private static makeAndWrapWrFS;
|
|
40
40
|
private static makeAndWrapRoFS;
|
|
41
|
+
static pathOf(item: FS | File): string | undefined;
|
|
41
42
|
static makeReadonly(root: string): Promise<ReadonlyFS>;
|
|
42
43
|
readonlySubRoot(folder: string): Promise<ReadonlyFS>;
|
|
43
44
|
writableSubRoot(folder: string, flags?: web3n.files.FileFlags): Promise<WritableFS>;
|
|
@@ -153,6 +153,7 @@ const WRITE_NONEXCL_FLAGS = {
|
|
|
153
153
|
exclusive: false,
|
|
154
154
|
truncate: true
|
|
155
155
|
};
|
|
156
|
+
const itemToPathMap = new WeakMap();
|
|
156
157
|
class DeviceFS {
|
|
157
158
|
constructor(root, writable, name = '') {
|
|
158
159
|
this.root = root;
|
|
@@ -243,12 +244,17 @@ class DeviceFS {
|
|
|
243
244
|
}
|
|
244
245
|
static makeAndWrapWrFS(root, name) {
|
|
245
246
|
const wrFS = (0, files_1.wrapWritableFS)(new DeviceFS(root, true, name));
|
|
247
|
+
itemToPathMap.set(wrFS, root);
|
|
246
248
|
return wrFS;
|
|
247
249
|
}
|
|
248
250
|
static makeAndWrapRoFS(root, name) {
|
|
249
251
|
const roFS = (0, files_1.wrapReadonlyFS)(new DeviceFS(root, false, name));
|
|
252
|
+
itemToPathMap.set(roFS, root);
|
|
250
253
|
return roFS;
|
|
251
254
|
}
|
|
255
|
+
static pathOf(item) {
|
|
256
|
+
return itemToPathMap.get(item);
|
|
257
|
+
}
|
|
252
258
|
static async makeReadonly(root) {
|
|
253
259
|
await checkFolderPresence(root);
|
|
254
260
|
const folderName = pathMod.basename(root);
|
|
@@ -693,7 +699,9 @@ class DeviceFS {
|
|
|
693
699
|
}
|
|
694
700
|
async readonlyFile(path) {
|
|
695
701
|
await this.checkFilePresence(path, true);
|
|
696
|
-
|
|
702
|
+
const roFile = (0, files_1.wrapReadonlyFile)(new FileObject(this, path, true, false));
|
|
703
|
+
itemToPathMap.set(roFile, this.fullPath(path));
|
|
704
|
+
return roFile;
|
|
697
705
|
}
|
|
698
706
|
async writableFile(path, flags = WRITE_NONEXCL_FLAGS) {
|
|
699
707
|
const exists = await this.checkFilePresence(path);
|
|
@@ -703,7 +711,9 @@ class DeviceFS {
|
|
|
703
711
|
if (!exists && !flags.create) {
|
|
704
712
|
throw (0, file_1.makeFileException)('notFound', path);
|
|
705
713
|
}
|
|
706
|
-
|
|
714
|
+
const wrFile = (0, files_1.wrapWritableFile)(new FileObject(this, path, exists, true));
|
|
715
|
+
itemToPathMap.set(wrFile, this.fullPath(path));
|
|
716
|
+
return wrFile;
|
|
707
717
|
}
|
|
708
718
|
watchFolder(path, observer) {
|
|
709
719
|
const fullFolderPath = this.fullPath(path, true);
|