@gjsify/fs 0.3.13 → 0.3.15
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/lib/esm/_virtual/_rolldown/runtime.js +18 -0
- package/lib/esm/callback.js +301 -302
- package/lib/esm/cp.js +207 -227
- package/lib/esm/dir.js +140 -148
- package/lib/esm/dirent.js +137 -128
- package/lib/esm/encoding.js +30 -27
- package/lib/esm/errors.js +15 -11
- package/lib/esm/fd-ops.js +105 -122
- package/lib/esm/file-handle.js +648 -653
- package/lib/esm/fs-watcher.js +153 -161
- package/lib/esm/glob.js +148 -149
- package/lib/esm/index.js +158 -351
- package/lib/esm/promises.js +413 -386
- package/lib/esm/read-stream.js +104 -108
- package/lib/esm/stat-watcher.js +113 -114
- package/lib/esm/statfs.js +56 -43
- package/lib/esm/stats.js +166 -159
- package/lib/esm/sync.js +366 -341
- package/lib/esm/types/index.js +6 -6
- package/lib/esm/utils.js +15 -17
- package/lib/esm/utimes.js +26 -37
- package/lib/esm/write-stream.js +96 -108
- package/package.json +10 -10
package/lib/esm/stats.js
CHANGED
|
@@ -1,165 +1,172 @@
|
|
|
1
|
-
import Gio from "@girs/gio-2.0";
|
|
2
1
|
import { Dirent } from "./dirent.js";
|
|
2
|
+
import Gio from "@girs/gio-2.0";
|
|
3
3
|
import { basename } from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/stats.ts
|
|
4
6
|
const STAT_ATTRIBUTES = "standard::*,time::*,unix::*";
|
|
5
7
|
function populateFromInfo(info) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
class Stats extends Dirent {
|
|
40
|
-
dev;
|
|
41
|
-
ino;
|
|
42
|
-
mode;
|
|
43
|
-
nlink;
|
|
44
|
-
uid;
|
|
45
|
-
gid;
|
|
46
|
-
rdev;
|
|
47
|
-
size;
|
|
48
|
-
blksize;
|
|
49
|
-
blocks;
|
|
50
|
-
atimeMs;
|
|
51
|
-
mtimeMs;
|
|
52
|
-
ctimeMs;
|
|
53
|
-
birthtimeMs;
|
|
54
|
-
atime;
|
|
55
|
-
mtime;
|
|
56
|
-
ctime;
|
|
57
|
-
birthtime;
|
|
58
|
-
_info;
|
|
59
|
-
constructor(infoOrPath, pathOrFilename, filename) {
|
|
60
|
-
let info;
|
|
61
|
-
let pathStr;
|
|
62
|
-
if (infoOrPath instanceof Gio.FileInfo) {
|
|
63
|
-
info = infoOrPath;
|
|
64
|
-
pathStr = pathOrFilename.toString();
|
|
65
|
-
if (!filename) filename = basename(pathStr);
|
|
66
|
-
} else {
|
|
67
|
-
pathStr = infoOrPath.toString();
|
|
68
|
-
if (typeof pathOrFilename === "string") filename = pathOrFilename;
|
|
69
|
-
if (!filename) filename = basename(pathStr);
|
|
70
|
-
const file = Gio.File.new_for_path(pathStr);
|
|
71
|
-
info = file.query_info(STAT_ATTRIBUTES, Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
|
|
72
|
-
}
|
|
73
|
-
super(pathStr, filename, info.get_file_type());
|
|
74
|
-
this._info = info;
|
|
75
|
-
const data = populateFromInfo(info);
|
|
76
|
-
this.dev = data.dev;
|
|
77
|
-
this.ino = data.ino;
|
|
78
|
-
this.mode = data.mode;
|
|
79
|
-
this.nlink = data.nlink;
|
|
80
|
-
this.uid = data.uid;
|
|
81
|
-
this.gid = data.gid;
|
|
82
|
-
this.rdev = data.rdev;
|
|
83
|
-
this.size = data.size;
|
|
84
|
-
this.blksize = data.blksize;
|
|
85
|
-
this.blocks = data.blocks;
|
|
86
|
-
this.atimeMs = data.atimeMs;
|
|
87
|
-
this.mtimeMs = data.mtimeMs;
|
|
88
|
-
this.ctimeMs = data.ctimeMs;
|
|
89
|
-
this.birthtimeMs = data.birthtimeMs;
|
|
90
|
-
this.atime = data.atime;
|
|
91
|
-
this.mtime = data.mtime;
|
|
92
|
-
this.ctime = data.ctime;
|
|
93
|
-
this.birthtime = data.birthtime;
|
|
94
|
-
}
|
|
8
|
+
const atimeSec = info.get_attribute_uint64("time::access");
|
|
9
|
+
const atimeUsec = info.get_attribute_uint32("time::access-usec") || 0;
|
|
10
|
+
const mtimeSec = info.get_attribute_uint64("time::modified");
|
|
11
|
+
const mtimeUsec = info.get_attribute_uint32("time::modified-usec") || 0;
|
|
12
|
+
const ctimeSec = info.get_attribute_uint64("time::changed");
|
|
13
|
+
const ctimeUsec = info.get_attribute_uint32("time::changed-usec") || 0;
|
|
14
|
+
const createdSec = info.get_attribute_uint64("time::created");
|
|
15
|
+
const createdUsec = info.get_attribute_uint32("time::created-usec") || 0;
|
|
16
|
+
const atimeMs = atimeSec * 1e3 + atimeUsec / 1e3;
|
|
17
|
+
const mtimeMs = mtimeSec * 1e3 + mtimeUsec / 1e3;
|
|
18
|
+
const ctimeMs = ctimeSec ? ctimeSec * 1e3 + ctimeUsec / 1e3 : mtimeMs;
|
|
19
|
+
const birthtimeMs = createdSec ? createdSec * 1e3 + createdUsec / 1e3 : ctimeMs;
|
|
20
|
+
return {
|
|
21
|
+
dev: info.get_attribute_uint32("unix::device") || 0,
|
|
22
|
+
ino: Number(info.get_attribute_uint64("unix::inode") || 0),
|
|
23
|
+
mode: info.get_attribute_uint32("unix::mode") || 0,
|
|
24
|
+
nlink: info.get_attribute_uint32("unix::nlink") || 0,
|
|
25
|
+
uid: info.get_attribute_uint32("unix::uid") || 0,
|
|
26
|
+
gid: info.get_attribute_uint32("unix::gid") || 0,
|
|
27
|
+
rdev: info.get_attribute_uint32("unix::rdev") || 0,
|
|
28
|
+
size: Number(info.get_size() || 0),
|
|
29
|
+
blksize: info.get_attribute_uint32("unix::block-size") || 4096,
|
|
30
|
+
blocks: Number(info.get_attribute_uint64("unix::blocks") || 0),
|
|
31
|
+
atimeMs,
|
|
32
|
+
mtimeMs,
|
|
33
|
+
ctimeMs,
|
|
34
|
+
birthtimeMs,
|
|
35
|
+
atime: new Date(atimeMs),
|
|
36
|
+
mtime: new Date(mtimeMs),
|
|
37
|
+
ctime: new Date(ctimeMs),
|
|
38
|
+
birthtime: new Date(birthtimeMs)
|
|
39
|
+
};
|
|
95
40
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
41
|
+
/**
|
|
42
|
+
* A `fs.Stats` object provides information about a file.
|
|
43
|
+
* @since v0.1.21
|
|
44
|
+
*/
|
|
45
|
+
var Stats = class extends Dirent {
|
|
46
|
+
dev;
|
|
47
|
+
ino;
|
|
48
|
+
mode;
|
|
49
|
+
nlink;
|
|
50
|
+
uid;
|
|
51
|
+
gid;
|
|
52
|
+
rdev;
|
|
53
|
+
size;
|
|
54
|
+
blksize;
|
|
55
|
+
blocks;
|
|
56
|
+
atimeMs;
|
|
57
|
+
mtimeMs;
|
|
58
|
+
ctimeMs;
|
|
59
|
+
birthtimeMs;
|
|
60
|
+
atime;
|
|
61
|
+
mtime;
|
|
62
|
+
ctime;
|
|
63
|
+
birthtime;
|
|
64
|
+
_info;
|
|
65
|
+
constructor(infoOrPath, pathOrFilename, filename) {
|
|
66
|
+
let info;
|
|
67
|
+
let pathStr;
|
|
68
|
+
if (infoOrPath instanceof Gio.FileInfo) {
|
|
69
|
+
info = infoOrPath;
|
|
70
|
+
pathStr = pathOrFilename.toString();
|
|
71
|
+
if (!filename) filename = basename(pathStr);
|
|
72
|
+
} else {
|
|
73
|
+
pathStr = infoOrPath.toString();
|
|
74
|
+
if (typeof pathOrFilename === "string") filename = pathOrFilename;
|
|
75
|
+
if (!filename) filename = basename(pathStr);
|
|
76
|
+
const file = Gio.File.new_for_path(pathStr);
|
|
77
|
+
info = file.query_info(STAT_ATTRIBUTES, Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
|
|
78
|
+
}
|
|
79
|
+
super(pathStr, filename, info.get_file_type());
|
|
80
|
+
this._info = info;
|
|
81
|
+
const data = populateFromInfo(info);
|
|
82
|
+
this.dev = data.dev;
|
|
83
|
+
this.ino = data.ino;
|
|
84
|
+
this.mode = data.mode;
|
|
85
|
+
this.nlink = data.nlink;
|
|
86
|
+
this.uid = data.uid;
|
|
87
|
+
this.gid = data.gid;
|
|
88
|
+
this.rdev = data.rdev;
|
|
89
|
+
this.size = data.size;
|
|
90
|
+
this.blksize = data.blksize;
|
|
91
|
+
this.blocks = data.blocks;
|
|
92
|
+
this.atimeMs = data.atimeMs;
|
|
93
|
+
this.mtimeMs = data.mtimeMs;
|
|
94
|
+
this.ctimeMs = data.ctimeMs;
|
|
95
|
+
this.birthtimeMs = data.birthtimeMs;
|
|
96
|
+
this.atime = data.atime;
|
|
97
|
+
this.mtime = data.mtime;
|
|
98
|
+
this.ctime = data.ctime;
|
|
99
|
+
this.birthtime = data.birthtime;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* BigIntStats — same as Stats but with bigint fields and nanosecond precision.
|
|
104
|
+
*/
|
|
105
|
+
var BigIntStats = class extends Dirent {
|
|
106
|
+
dev;
|
|
107
|
+
ino;
|
|
108
|
+
mode;
|
|
109
|
+
nlink;
|
|
110
|
+
uid;
|
|
111
|
+
gid;
|
|
112
|
+
rdev;
|
|
113
|
+
size;
|
|
114
|
+
blksize;
|
|
115
|
+
blocks;
|
|
116
|
+
atimeMs;
|
|
117
|
+
mtimeMs;
|
|
118
|
+
ctimeMs;
|
|
119
|
+
birthtimeMs;
|
|
120
|
+
atimeNs;
|
|
121
|
+
mtimeNs;
|
|
122
|
+
ctimeNs;
|
|
123
|
+
birthtimeNs;
|
|
124
|
+
atime;
|
|
125
|
+
mtime;
|
|
126
|
+
ctime;
|
|
127
|
+
birthtime;
|
|
128
|
+
_info;
|
|
129
|
+
constructor(infoOrPath, pathOrFilename, filename) {
|
|
130
|
+
let info;
|
|
131
|
+
let pathStr;
|
|
132
|
+
if (infoOrPath instanceof Gio.FileInfo) {
|
|
133
|
+
info = infoOrPath;
|
|
134
|
+
pathStr = pathOrFilename.toString();
|
|
135
|
+
if (!filename) filename = basename(pathStr);
|
|
136
|
+
} else {
|
|
137
|
+
pathStr = infoOrPath.toString();
|
|
138
|
+
if (typeof pathOrFilename === "string") filename = pathOrFilename;
|
|
139
|
+
if (!filename) filename = basename(pathStr);
|
|
140
|
+
const file = Gio.File.new_for_path(pathStr);
|
|
141
|
+
info = file.query_info(STAT_ATTRIBUTES, Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
|
|
142
|
+
}
|
|
143
|
+
super(pathStr, filename, info.get_file_type());
|
|
144
|
+
this._info = info;
|
|
145
|
+
const data = populateFromInfo(info);
|
|
146
|
+
this.dev = BigInt(data.dev);
|
|
147
|
+
this.ino = BigInt(data.ino);
|
|
148
|
+
this.mode = BigInt(data.mode);
|
|
149
|
+
this.nlink = BigInt(data.nlink);
|
|
150
|
+
this.uid = BigInt(data.uid);
|
|
151
|
+
this.gid = BigInt(data.gid);
|
|
152
|
+
this.rdev = BigInt(data.rdev);
|
|
153
|
+
this.size = BigInt(data.size);
|
|
154
|
+
this.blksize = BigInt(data.blksize);
|
|
155
|
+
this.blocks = BigInt(data.blocks);
|
|
156
|
+
this.atimeMs = BigInt(Math.trunc(data.atimeMs));
|
|
157
|
+
this.mtimeMs = BigInt(Math.trunc(data.mtimeMs));
|
|
158
|
+
this.ctimeMs = BigInt(Math.trunc(data.ctimeMs));
|
|
159
|
+
this.birthtimeMs = BigInt(Math.trunc(data.birthtimeMs));
|
|
160
|
+
this.atimeNs = this.atimeMs * 1000000n;
|
|
161
|
+
this.mtimeNs = this.mtimeMs * 1000000n;
|
|
162
|
+
this.ctimeNs = this.ctimeMs * 1000000n;
|
|
163
|
+
this.birthtimeNs = this.birthtimeMs * 1000000n;
|
|
164
|
+
this.atime = data.atime;
|
|
165
|
+
this.mtime = data.mtime;
|
|
166
|
+
this.ctime = data.ctime;
|
|
167
|
+
this.birthtime = data.birthtime;
|
|
168
|
+
}
|
|
165
169
|
};
|
|
170
|
+
|
|
171
|
+
//#endregion
|
|
172
|
+
export { BigIntStats, STAT_ATTRIBUTES, Stats };
|