@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
package/dist/index.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ZenFS's main module. This is exposed in the browser via the ZenFS global.
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
import fs from './emulation/fs.js';
|
|
4
|
+
import * as fs from './emulation/index.js';
|
|
14
5
|
import { FileSystem } from './filesystem.js';
|
|
15
6
|
import { backends } from './backends/index.js';
|
|
16
|
-
import { ErrorCode, ApiError } from './ApiError.js';
|
|
17
7
|
import { Cred } from './cred.js';
|
|
8
|
+
import { isBackend, resolveBackendConfig } from './backends/backend.js';
|
|
18
9
|
import { setCred } from './emulation/shared.js';
|
|
19
10
|
/**
|
|
20
11
|
* Initializes ZenFS with the given file systems.
|
|
@@ -23,76 +14,32 @@ export function initialize(mounts, uid = 0, gid = 0) {
|
|
|
23
14
|
setCred(new Cred(uid, gid, uid, gid, uid, gid));
|
|
24
15
|
return fs.initialize(mounts);
|
|
25
16
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//should never happen
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
point = point.toString(); // so linting stops complaining that point should be declared with const, which can't be done since value is assigned to
|
|
38
|
-
if (value instanceof FileSystem) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (typeof value == 'string') {
|
|
42
|
-
value = { fs: value };
|
|
43
|
-
}
|
|
44
|
-
config[point] = yield getFileSystem(value);
|
|
45
|
-
}
|
|
46
|
-
return initialize(config);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
export function configure(config, cb) {
|
|
50
|
-
// Promise version
|
|
51
|
-
if (typeof cb != 'function') {
|
|
52
|
-
return _configure(config);
|
|
17
|
+
/**
|
|
18
|
+
* Creates filesystems with the given configuration, and initializes ZenFS with it.
|
|
19
|
+
* See the Configuration type for more info on the configuration object.
|
|
20
|
+
*/
|
|
21
|
+
export async function configure(config) {
|
|
22
|
+
if ('backend' in config || config instanceof FileSystem) {
|
|
23
|
+
// single FS
|
|
24
|
+
config = { '/': config };
|
|
53
25
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
function _getFileSystem({ fs: fsName, options = {} }) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
if (!fsName) {
|
|
63
|
-
throw new ApiError(ErrorCode.EPERM, 'Missing "fs" property on configuration object.');
|
|
26
|
+
for (let [point, value] of Object.entries(config)) {
|
|
27
|
+
if (typeof value == 'number') {
|
|
28
|
+
//should never happen
|
|
29
|
+
continue;
|
|
64
30
|
}
|
|
65
|
-
if (
|
|
66
|
-
|
|
31
|
+
if (value instanceof FileSystem) {
|
|
32
|
+
continue;
|
|
67
33
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const opt = options[prop];
|
|
71
|
-
if (opt === null || typeof opt !== 'object' || !('fs' in opt)) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const fs = yield _getFileSystem(opt);
|
|
75
|
-
options[prop] = fs;
|
|
34
|
+
if (typeof value == 'string') {
|
|
35
|
+
value = { backend: backends[value] };
|
|
76
36
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
throw new ApiError(ErrorCode.EPERM, `File system ${fsName} is not available in ZenFS.`);
|
|
37
|
+
if (isBackend(value)) {
|
|
38
|
+
value = { backend: value };
|
|
80
39
|
}
|
|
81
|
-
|
|
82
|
-
return fsc.Create(options);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
export function getFileSystem(config, cb) {
|
|
87
|
-
// Promise version
|
|
88
|
-
if (typeof cb != 'function') {
|
|
89
|
-
return _getFileSystem(config);
|
|
40
|
+
config[point] = await resolveBackendConfig(value);
|
|
90
41
|
}
|
|
91
|
-
|
|
92
|
-
_getFileSystem(config)
|
|
93
|
-
.then(fs => cb(null, fs))
|
|
94
|
-
.catch(err => cb(err));
|
|
95
|
-
return;
|
|
42
|
+
return initialize(config);
|
|
96
43
|
}
|
|
97
44
|
export * from './backends/index.js';
|
|
98
45
|
export * from './backends/AsyncStore.js';
|
package/dist/inode.d.ts
CHANGED
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
import { Stats } from './stats.js';
|
|
2
|
+
export type Ino = bigint;
|
|
3
|
+
export declare const size_max: number;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const rootIno: Ino;
|
|
8
|
+
/**
|
|
9
|
+
* Generate 4 random bits at a time
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function randomIno(): Ino;
|
|
2
14
|
/**
|
|
3
15
|
* Generic inode definition that can easily be serialized.
|
|
4
16
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
export declare class Inode {
|
|
18
|
+
readonly buffer: ArrayBufferLike;
|
|
19
|
+
get data(): Uint8Array;
|
|
20
|
+
protected view: DataView;
|
|
21
|
+
constructor(buffer?: ArrayBufferLike);
|
|
22
|
+
get ino(): Ino;
|
|
23
|
+
set ino(value: Ino);
|
|
24
|
+
get size(): number;
|
|
25
|
+
set size(value: number);
|
|
26
|
+
get mode(): number;
|
|
27
|
+
set mode(value: number);
|
|
28
|
+
get nlink(): number;
|
|
29
|
+
set nlink(value: number);
|
|
30
|
+
get uid(): number;
|
|
31
|
+
set uid(value: number);
|
|
32
|
+
get gid(): number;
|
|
33
|
+
set gid(value: number);
|
|
34
|
+
get atime(): number;
|
|
35
|
+
set atime(value: number);
|
|
36
|
+
get mtime(): number;
|
|
37
|
+
set mtime(value: number);
|
|
38
|
+
get ctime(): number;
|
|
39
|
+
set ctime(value: number);
|
|
19
40
|
/**
|
|
20
41
|
* Handy function that converts the Inode to a Node Stats object.
|
|
21
42
|
*/
|
|
@@ -23,11 +44,7 @@ export default class Inode {
|
|
|
23
44
|
/**
|
|
24
45
|
* Get the size of this Inode, in bytes.
|
|
25
46
|
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Writes the inode into the start of the buffer.
|
|
29
|
-
*/
|
|
30
|
-
serialize(data?: ArrayBufferLike | ArrayBufferView): Uint8Array;
|
|
47
|
+
sizeof(): number;
|
|
31
48
|
/**
|
|
32
49
|
* Updates the Inode using information from the stats object. Used by file
|
|
33
50
|
* systems at sync time, e.g.:
|
|
@@ -38,13 +55,5 @@ export default class Inode {
|
|
|
38
55
|
* file system.
|
|
39
56
|
* @return True if any changes have occurred.
|
|
40
57
|
*/
|
|
41
|
-
update(stats: Stats): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* @return [Boolean] True if this item is a file.
|
|
44
|
-
*/
|
|
45
|
-
isFile(): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* @return [Boolean] True if this item is a directory.
|
|
48
|
-
*/
|
|
49
|
-
isDirectory(): boolean;
|
|
58
|
+
update(stats: Readonly<Stats>): boolean;
|
|
50
59
|
}
|
package/dist/inode.js
CHANGED
|
@@ -1,54 +1,125 @@
|
|
|
1
|
+
import { S_IFMT } from './emulation/constants.js';
|
|
1
2
|
import { Stats, FileType } from './stats.js';
|
|
2
|
-
|
|
3
|
+
var Offset;
|
|
4
|
+
(function (Offset) {
|
|
5
|
+
Offset[Offset["ino"] = 0] = "ino";
|
|
6
|
+
Offset[Offset["size"] = 8] = "size";
|
|
7
|
+
Offset[Offset["mode"] = 12] = "mode";
|
|
8
|
+
Offset[Offset["nlink"] = 14] = "nlink";
|
|
9
|
+
Offset[Offset["uid"] = 18] = "uid";
|
|
10
|
+
Offset[Offset["gid"] = 22] = "gid";
|
|
11
|
+
Offset[Offset["atime"] = 26] = "atime";
|
|
12
|
+
Offset[Offset["mtime"] = 34] = "mtime";
|
|
13
|
+
Offset[Offset["ctime"] = 42] = "ctime";
|
|
14
|
+
})(Offset || (Offset = {}));
|
|
15
|
+
export const size_max = 2 ** 32 - 1;
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export const rootIno = 0n;
|
|
20
|
+
/**
|
|
21
|
+
* Generates a random 32 bit integer, then converts to a hex string
|
|
22
|
+
*/
|
|
23
|
+
function _random() {
|
|
24
|
+
return Math.round(Math.random() * 2 ** 32).toString(16);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generate 4 random bits at a time
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export function randomIno() {
|
|
32
|
+
return BigInt('0x' + _random() + _random());
|
|
33
|
+
}
|
|
3
34
|
/**
|
|
4
35
|
* Generic inode definition that can easily be serialized.
|
|
5
36
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
|
|
37
|
+
export class Inode {
|
|
38
|
+
get data() {
|
|
39
|
+
return new Uint8Array(this.buffer);
|
|
40
|
+
}
|
|
41
|
+
constructor(buffer) {
|
|
42
|
+
const setDefaults = !buffer;
|
|
43
|
+
buffer ?? (buffer = new ArrayBuffer(50));
|
|
44
|
+
this.view = new DataView(buffer);
|
|
45
|
+
this.buffer = buffer;
|
|
46
|
+
if (!setDefaults) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// set defaults on a fresh inode
|
|
50
|
+
this.ino = randomIno();
|
|
51
|
+
this.nlink = 1;
|
|
52
|
+
this.size = 4096;
|
|
53
|
+
const now = Date.now();
|
|
54
|
+
this.atime = now;
|
|
55
|
+
this.mtime = now;
|
|
56
|
+
this.ctime = now;
|
|
57
|
+
}
|
|
58
|
+
get ino() {
|
|
59
|
+
return this.view.getBigUint64(Offset.ino, true);
|
|
60
|
+
}
|
|
61
|
+
set ino(value) {
|
|
62
|
+
this.view.setBigUint64(Offset.ino, value, true);
|
|
63
|
+
}
|
|
64
|
+
get size() {
|
|
65
|
+
return this.view.getUint32(Offset.size, true);
|
|
66
|
+
}
|
|
67
|
+
set size(value) {
|
|
68
|
+
this.view.setUint32(Offset.size, value, true);
|
|
69
|
+
}
|
|
70
|
+
get mode() {
|
|
71
|
+
return this.view.getUint16(Offset.mode, true);
|
|
72
|
+
}
|
|
73
|
+
set mode(value) {
|
|
74
|
+
this.view.setUint16(Offset.mode, value, true);
|
|
75
|
+
}
|
|
76
|
+
get nlink() {
|
|
77
|
+
return this.view.getUint32(Offset.nlink, true);
|
|
78
|
+
}
|
|
79
|
+
set nlink(value) {
|
|
80
|
+
this.view.setUint32(Offset.nlink, value, true);
|
|
81
|
+
}
|
|
82
|
+
get uid() {
|
|
83
|
+
return this.view.getUint32(Offset.uid, true);
|
|
84
|
+
}
|
|
85
|
+
set uid(value) {
|
|
86
|
+
this.view.setUint32(Offset.uid, value, true);
|
|
87
|
+
}
|
|
88
|
+
get gid() {
|
|
89
|
+
return this.view.getUint32(Offset.gid, true);
|
|
90
|
+
}
|
|
91
|
+
set gid(value) {
|
|
92
|
+
this.view.setUint32(Offset.gid, value, true);
|
|
93
|
+
}
|
|
94
|
+
get atime() {
|
|
95
|
+
return this.view.getFloat64(Offset.atime, true);
|
|
96
|
+
}
|
|
97
|
+
set atime(value) {
|
|
98
|
+
this.view.setFloat64(Offset.atime, value, true);
|
|
99
|
+
}
|
|
100
|
+
get mtime() {
|
|
101
|
+
return this.view.getFloat64(Offset.mtime, true);
|
|
102
|
+
}
|
|
103
|
+
set mtime(value) {
|
|
104
|
+
this.view.setFloat64(Offset.mtime, value, true);
|
|
105
|
+
}
|
|
106
|
+
get ctime() {
|
|
107
|
+
return this.view.getFloat64(Offset.ctime, true);
|
|
108
|
+
}
|
|
109
|
+
set ctime(value) {
|
|
110
|
+
this.view.setFloat64(Offset.ctime, value, true);
|
|
23
111
|
}
|
|
24
112
|
/**
|
|
25
113
|
* Handy function that converts the Inode to a Node Stats object.
|
|
26
114
|
*/
|
|
27
115
|
toStats() {
|
|
28
|
-
return new Stats((this.mode &
|
|
116
|
+
return new Stats((this.mode & S_IFMT) === FileType.DIRECTORY ? FileType.DIRECTORY : FileType.FILE, this.size, this.mode, this.atime, this.mtime, this.ctime, this.uid, this.gid);
|
|
29
117
|
}
|
|
30
118
|
/**
|
|
31
119
|
* Get the size of this Inode, in bytes.
|
|
32
120
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return 38 + this.id.length;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Writes the inode into the start of the buffer.
|
|
39
|
-
*/
|
|
40
|
-
serialize(data = new Uint8Array(this.getSize())) {
|
|
41
|
-
const view = new DataView('buffer' in data ? data.buffer : data);
|
|
42
|
-
view.setUint32(0, this.size, true);
|
|
43
|
-
view.setUint16(4, this.mode, true);
|
|
44
|
-
view.setFloat64(6, this.atime, true);
|
|
45
|
-
view.setFloat64(14, this.mtime, true);
|
|
46
|
-
view.setFloat64(22, this.ctime, true);
|
|
47
|
-
view.setUint32(30, this.uid, true);
|
|
48
|
-
view.setUint32(34, this.gid, true);
|
|
49
|
-
const buffer = new Uint8Array(view.buffer);
|
|
50
|
-
buffer.set(encode(this.id), 38);
|
|
51
|
-
return buffer;
|
|
121
|
+
sizeof() {
|
|
122
|
+
return this.buffer.byteLength;
|
|
52
123
|
}
|
|
53
124
|
/**
|
|
54
125
|
* Updates the Inode using information from the stats object. Used by file
|
|
@@ -70,19 +141,8 @@ export default class Inode {
|
|
|
70
141
|
this.mode = stats.mode;
|
|
71
142
|
hasChanged = true;
|
|
72
143
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.atime = atimeMs;
|
|
76
|
-
hasChanged = true;
|
|
77
|
-
}
|
|
78
|
-
const mtimeMs = stats.mtime.getTime();
|
|
79
|
-
if (this.mtime !== mtimeMs) {
|
|
80
|
-
this.mtime = mtimeMs;
|
|
81
|
-
hasChanged = true;
|
|
82
|
-
}
|
|
83
|
-
const ctimeMs = stats.ctime.getTime();
|
|
84
|
-
if (this.ctime !== ctimeMs) {
|
|
85
|
-
this.ctime = ctimeMs;
|
|
144
|
+
if (this.nlink !== stats.nlink) {
|
|
145
|
+
this.nlink = stats.nlink;
|
|
86
146
|
hasChanged = true;
|
|
87
147
|
}
|
|
88
148
|
if (this.uid !== stats.uid) {
|
|
@@ -93,20 +153,18 @@ export default class Inode {
|
|
|
93
153
|
this.uid = stats.uid;
|
|
94
154
|
hasChanged = true;
|
|
95
155
|
}
|
|
156
|
+
if (this.atime !== stats.atimeMs) {
|
|
157
|
+
this.atime = stats.atimeMs;
|
|
158
|
+
hasChanged = true;
|
|
159
|
+
}
|
|
160
|
+
if (this.mtime !== stats.mtimeMs) {
|
|
161
|
+
this.mtime = stats.mtimeMs;
|
|
162
|
+
hasChanged = true;
|
|
163
|
+
}
|
|
164
|
+
if (this.ctime !== stats.ctimeMs) {
|
|
165
|
+
this.ctime = stats.ctimeMs;
|
|
166
|
+
hasChanged = true;
|
|
167
|
+
}
|
|
96
168
|
return hasChanged;
|
|
97
169
|
}
|
|
98
|
-
// XXX: Copied from Stats. Should reconcile these two into something more
|
|
99
|
-
// compact.
|
|
100
|
-
/**
|
|
101
|
-
* @return [Boolean] True if this item is a file.
|
|
102
|
-
*/
|
|
103
|
-
isFile() {
|
|
104
|
-
return (this.mode & 0xf000) === FileType.FILE;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @return [Boolean] True if this item is a directory.
|
|
108
|
-
*/
|
|
109
|
-
isDirectory() {
|
|
110
|
-
return (this.mode & 0xf000) === FileType.DIRECTORY;
|
|
111
|
-
}
|
|
112
170
|
}
|
package/dist/stats.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import type
|
|
2
|
+
import type * as Node from 'fs';
|
|
3
3
|
import { Cred } from './cred.js';
|
|
4
4
|
/**
|
|
5
5
|
* Indicates the type of the given file. Applied to 'mode'.
|
|
@@ -10,37 +10,60 @@ export declare enum FileType {
|
|
|
10
10
|
SYMLINK
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* Attribute descriptions are from `man 2 stat'
|
|
16
|
-
* @see http://nodejs.org/api/fs.html#fs_class_fs_stats
|
|
17
|
-
* @see http://man7.org/linux/man-pages/man2/stat.2.html
|
|
13
|
+
* Common code used by both Stats and BigIntStats
|
|
18
14
|
*/
|
|
19
|
-
export declare class
|
|
20
|
-
|
|
15
|
+
export declare abstract class StatsCommon<T extends number | bigint> implements Node.StatsBase<T> {
|
|
16
|
+
protected abstract _isBigint: boolean;
|
|
17
|
+
protected get _typename(): string;
|
|
18
|
+
protected get _typename_inverse(): string;
|
|
19
|
+
protected _convert(arg: number | bigint | string | boolean): T;
|
|
20
|
+
blocks: T;
|
|
21
|
+
mode: T;
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* ID of device containing file
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
ino:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
dev: T;
|
|
26
|
+
/**
|
|
27
|
+
* inode number
|
|
28
|
+
*/
|
|
29
|
+
ino: T;
|
|
30
|
+
/**
|
|
31
|
+
* device ID (if special file)
|
|
32
|
+
*/
|
|
33
|
+
rdev: T;
|
|
34
|
+
/**
|
|
35
|
+
* number of hard links
|
|
36
|
+
*/
|
|
37
|
+
nlink: T;
|
|
38
|
+
/**
|
|
39
|
+
* blocksize for file system I/O
|
|
40
|
+
*/
|
|
41
|
+
blksize: T;
|
|
42
|
+
/**
|
|
43
|
+
* user ID of owner
|
|
44
|
+
*/
|
|
45
|
+
uid: T;
|
|
46
|
+
/**
|
|
47
|
+
* group ID of owner
|
|
48
|
+
*/
|
|
49
|
+
gid: T;
|
|
50
|
+
/**
|
|
51
|
+
* Some file systems stash data on stats objects.
|
|
52
|
+
*/
|
|
53
|
+
fileData?: Uint8Array;
|
|
54
|
+
atimeMs: T;
|
|
40
55
|
get atime(): Date;
|
|
56
|
+
set atime(value: Date);
|
|
57
|
+
mtimeMs: T;
|
|
41
58
|
get mtime(): Date;
|
|
59
|
+
set mtime(value: Date);
|
|
60
|
+
ctimeMs: T;
|
|
42
61
|
get ctime(): Date;
|
|
62
|
+
set ctime(value: Date);
|
|
63
|
+
birthtimeMs: T;
|
|
43
64
|
get birthtime(): Date;
|
|
65
|
+
set birthtime(value: Date);
|
|
66
|
+
size: T;
|
|
44
67
|
/**
|
|
45
68
|
* Provides information about a particular entry in the file system.
|
|
46
69
|
* @param itemType Type of the item (FILE, DIRECTORY, SYMLINK, or SOCKET)
|
|
@@ -54,44 +77,76 @@ export declare class Stats implements StatsBase<number> {
|
|
|
54
77
|
* @param gid the id of the group that owns the file
|
|
55
78
|
* @param birthtimeMs time of file creation, in milliseconds since epoch
|
|
56
79
|
*/
|
|
57
|
-
constructor(itemType
|
|
58
|
-
serialize(): Uint8Array;
|
|
80
|
+
constructor(itemType?: FileType, size?: number | bigint, mode?: number | bigint, atimeMs?: number | bigint, mtimeMs?: number | bigint, ctimeMs?: number | bigint, uid?: number | bigint, gid?: number | bigint, birthtimeMs?: number | bigint);
|
|
59
81
|
/**
|
|
60
|
-
* @
|
|
82
|
+
* @returns true if this item is a file.
|
|
61
83
|
*/
|
|
62
84
|
isFile(): boolean;
|
|
63
85
|
/**
|
|
64
|
-
* @
|
|
86
|
+
* @returns True if this item is a directory.
|
|
65
87
|
*/
|
|
66
88
|
isDirectory(): boolean;
|
|
67
89
|
/**
|
|
68
|
-
* @
|
|
90
|
+
* @returns true if this item is a symbolic link
|
|
69
91
|
*/
|
|
70
92
|
isSymbolicLink(): boolean;
|
|
93
|
+
isSocket(): boolean;
|
|
94
|
+
isBlockDevice(): boolean;
|
|
95
|
+
isCharacterDevice(): boolean;
|
|
96
|
+
isFIFO(): boolean;
|
|
71
97
|
/**
|
|
72
98
|
* Checks if a given user/group has access to this item
|
|
73
99
|
* @param mode The request access as 4 bits (unused, read, write, execute)
|
|
74
100
|
* @param uid The requesting UID
|
|
75
101
|
* @param gid The requesting GID
|
|
76
|
-
* @returns
|
|
102
|
+
* @returns True if the request has access, false if the request does not
|
|
103
|
+
* @internal
|
|
77
104
|
*/
|
|
78
105
|
hasAccess(mode: number, cred: Cred): boolean;
|
|
79
106
|
/**
|
|
80
107
|
* Convert the current stats object into a cred object
|
|
108
|
+
* @internal
|
|
81
109
|
*/
|
|
82
110
|
getCred(uid?: number, gid?: number): Cred;
|
|
83
111
|
/**
|
|
84
112
|
* Change the mode of the file. We use this helper function to prevent messing
|
|
85
113
|
* up the type of the file, which is encoded in mode.
|
|
114
|
+
* @internal
|
|
86
115
|
*/
|
|
87
116
|
chmod(mode: number): void;
|
|
88
117
|
/**
|
|
89
118
|
* Change the owner user/group of the file.
|
|
90
119
|
* This function makes sure it is a valid UID/GID (that is, a 32 unsigned int)
|
|
120
|
+
* @internal
|
|
91
121
|
*/
|
|
92
|
-
chown(uid: number, gid: number): void;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
122
|
+
chown(uid: number | bigint, gid: number | bigint): void;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Implementation of Node's `Stats`.
|
|
126
|
+
*
|
|
127
|
+
* Attribute descriptions are from `man 2 stat'
|
|
128
|
+
* @see http://nodejs.org/api/fs.html#fs_class_fs_stats
|
|
129
|
+
* @see http://man7.org/linux/man-pages/man2/stat.2.html
|
|
130
|
+
*/
|
|
131
|
+
export declare class Stats extends StatsCommon<number> implements Node.Stats {
|
|
132
|
+
protected _isBigint: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Clones the stats object.
|
|
135
|
+
*/
|
|
136
|
+
static clone(s: Stats): Stats;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Stats with bigint
|
|
140
|
+
* @todo Implement with bigint instead of wrapping Stats
|
|
141
|
+
*/
|
|
142
|
+
export declare class BigIntStats extends StatsCommon<bigint> implements Node.BigIntStats {
|
|
143
|
+
protected _isBigint: boolean;
|
|
144
|
+
atimeNs: bigint;
|
|
145
|
+
mtimeNs: bigint;
|
|
146
|
+
ctimeNs: bigint;
|
|
147
|
+
birthtimeNs: bigint;
|
|
148
|
+
/**
|
|
149
|
+
* Clone a stats object.
|
|
150
|
+
*/
|
|
151
|
+
static clone(s: BigIntStats | Stats): BigIntStats;
|
|
97
152
|
}
|