@gjsify/fs 0.3.16 → 0.3.18
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 +1 -18
- package/lib/esm/callback.js +1 -356
- package/lib/esm/cp.js +1 -233
- package/lib/esm/dir.js +1 -152
- package/lib/esm/dirent.js +1 -148
- package/lib/esm/encoding.js +1 -36
- package/lib/esm/errors.js +1 -17
- package/lib/esm/fd-ops.js +1 -172
- package/lib/esm/file-handle.js +1 -666
- package/lib/esm/fs-watcher.js +1 -163
- package/lib/esm/glob.js +1 -163
- package/lib/esm/index.js +1 -163
- package/lib/esm/promises.js +1 -471
- package/lib/esm/read-stream.js +1 -109
- package/lib/esm/stat-watcher.js +1 -120
- package/lib/esm/statfs.js +1 -70
- package/lib/esm/stats.js +1 -172
- package/lib/esm/sync.js +1 -418
- package/lib/esm/types/index.js +1 -6
- package/lib/esm/utils.js +1 -23
- package/lib/esm/utimes.js +1 -51
- package/lib/esm/write-stream.js +1 -101
- package/package.json +11 -11
- package/tsconfig.tsbuildinfo +1 -1
package/lib/esm/stat-watcher.js
CHANGED
|
@@ -1,120 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { EventEmitter } from "node:events";
|
|
3
|
-
|
|
4
|
-
//#region src/stat-watcher.ts
|
|
5
|
-
function zeroedStat() {
|
|
6
|
-
return {
|
|
7
|
-
dev: 0,
|
|
8
|
-
ino: 0,
|
|
9
|
-
mode: 0,
|
|
10
|
-
nlink: 0,
|
|
11
|
-
uid: 0,
|
|
12
|
-
gid: 0,
|
|
13
|
-
rdev: 0,
|
|
14
|
-
size: 0,
|
|
15
|
-
blksize: 0,
|
|
16
|
-
blocks: 0,
|
|
17
|
-
atimeMs: 0,
|
|
18
|
-
mtimeMs: 0,
|
|
19
|
-
ctimeMs: 0,
|
|
20
|
-
birthtimeMs: 0,
|
|
21
|
-
atime: new Date(0),
|
|
22
|
-
mtime: new Date(0),
|
|
23
|
-
ctime: new Date(0),
|
|
24
|
-
birthtime: new Date(0),
|
|
25
|
-
isFile: () => false,
|
|
26
|
-
isDirectory: () => false,
|
|
27
|
-
isBlockDevice: () => false,
|
|
28
|
-
isCharacterDevice: () => false,
|
|
29
|
-
isSymbolicLink: () => false,
|
|
30
|
-
isFIFO: () => false,
|
|
31
|
-
isSocket: () => false
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
var StatWatcher = class extends EventEmitter {
|
|
35
|
-
_path;
|
|
36
|
-
_interval;
|
|
37
|
-
_timerId = null;
|
|
38
|
-
_prev;
|
|
39
|
-
_changeCount = 0;
|
|
40
|
-
constructor(path, interval) {
|
|
41
|
-
super();
|
|
42
|
-
this._path = path;
|
|
43
|
-
this._interval = interval;
|
|
44
|
-
this._prev = zeroedStat();
|
|
45
|
-
}
|
|
46
|
-
start() {
|
|
47
|
-
try {
|
|
48
|
-
this._prev = statSync(this._path);
|
|
49
|
-
} catch {}
|
|
50
|
-
this._timerId = setInterval(() => {
|
|
51
|
-
let curr;
|
|
52
|
-
try {
|
|
53
|
-
curr = statSync(this._path);
|
|
54
|
-
} catch {
|
|
55
|
-
curr = zeroedStat();
|
|
56
|
-
}
|
|
57
|
-
const prev = this._prev;
|
|
58
|
-
if (curr.mtimeMs !== prev.mtimeMs || curr.size !== prev.size || curr.ino !== prev.ino) {
|
|
59
|
-
this._prev = curr;
|
|
60
|
-
this.emit("change", curr, prev);
|
|
61
|
-
}
|
|
62
|
-
}, this._interval);
|
|
63
|
-
}
|
|
64
|
-
stop() {
|
|
65
|
-
if (this._timerId !== null) {
|
|
66
|
-
clearInterval(this._timerId);
|
|
67
|
-
this._timerId = null;
|
|
68
|
-
}
|
|
69
|
-
this.emit("stop");
|
|
70
|
-
}
|
|
71
|
-
addChangeListener(listener) {
|
|
72
|
-
this._changeCount++;
|
|
73
|
-
this.on("change", listener);
|
|
74
|
-
}
|
|
75
|
-
removeChangeListener(listener) {
|
|
76
|
-
this._changeCount--;
|
|
77
|
-
this.removeListener("change", listener);
|
|
78
|
-
}
|
|
79
|
-
removeAllChangeListeners() {
|
|
80
|
-
this._changeCount = 0;
|
|
81
|
-
this.removeAllListeners("change");
|
|
82
|
-
}
|
|
83
|
-
get changeListenerCount() {
|
|
84
|
-
return this._changeCount;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const statWatchers = new Map();
|
|
88
|
-
function watchFile(filename, options, listener) {
|
|
89
|
-
if (typeof options === "function") {
|
|
90
|
-
listener = options;
|
|
91
|
-
options = {};
|
|
92
|
-
}
|
|
93
|
-
const interval = options.interval ?? 5007;
|
|
94
|
-
const resolved = filename.toString();
|
|
95
|
-
let watcher = statWatchers.get(resolved);
|
|
96
|
-
if (!watcher) {
|
|
97
|
-
watcher = new StatWatcher(resolved, interval);
|
|
98
|
-
watcher.start();
|
|
99
|
-
statWatchers.set(resolved, watcher);
|
|
100
|
-
}
|
|
101
|
-
if (listener) watcher.addChangeListener(listener);
|
|
102
|
-
return watcher;
|
|
103
|
-
}
|
|
104
|
-
function unwatchFile(filename, listener) {
|
|
105
|
-
const resolved = filename.toString();
|
|
106
|
-
const watcher = statWatchers.get(resolved);
|
|
107
|
-
if (!watcher) return;
|
|
108
|
-
if (listener) {
|
|
109
|
-
watcher.removeChangeListener(listener);
|
|
110
|
-
} else {
|
|
111
|
-
watcher.removeAllChangeListeners();
|
|
112
|
-
}
|
|
113
|
-
if (watcher.changeListenerCount === 0) {
|
|
114
|
-
watcher.stop();
|
|
115
|
-
statWatchers.delete(resolved);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
//#endregion
|
|
120
|
-
export { StatWatcher, unwatchFile, watchFile };
|
|
1
|
+
import{statSync as e}from"./sync.js";import{EventEmitter as t}from"node:events";function n(){return{dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0),isFile:()=>!1,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1}}var r=class extends t{_path;_interval;_timerId=null;_prev;_changeCount=0;constructor(e,t){super(),this._path=e,this._interval=t,this._prev=n()}start(){try{this._prev=e(this._path)}catch{}this._timerId=setInterval(()=>{let t;try{t=e(this._path)}catch{t=n()}let r=this._prev;(t.mtimeMs!==r.mtimeMs||t.size!==r.size||t.ino!==r.ino)&&(this._prev=t,this.emit(`change`,t,r))},this._interval)}stop(){this._timerId!==null&&(clearInterval(this._timerId),this._timerId=null),this.emit(`stop`)}addChangeListener(e){this._changeCount++,this.on(`change`,e)}removeChangeListener(e){this._changeCount--,this.removeListener(`change`,e)}removeAllChangeListeners(){this._changeCount=0,this.removeAllListeners(`change`)}get changeListenerCount(){return this._changeCount}};const i=new Map;function a(e,t,n){typeof t==`function`&&(n=t,t={});let a=t.interval??5007,o=e.toString(),s=i.get(o);return s||(s=new r(o,a),s.start(),i.set(o,s)),n&&s.addChangeListener(n),s}function o(e,t){let n=e.toString(),r=i.get(n);r&&(t?r.removeChangeListener(t):r.removeAllChangeListeners(),r.changeListenerCount===0&&(r.stop(),i.delete(n)))}export{r as StatWatcher,o as unwatchFile,a as watchFile};
|
package/lib/esm/statfs.js
CHANGED
|
@@ -1,70 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import GLib from "@girs/glib-2.0";
|
|
3
|
-
import Gio from "@girs/gio-2.0";
|
|
4
|
-
|
|
5
|
-
//#region src/statfs.ts
|
|
6
|
-
const FS_INFO_ATTRS = ["filesystem::size", "filesystem::free"].join(",");
|
|
7
|
-
const BSIZE = 4096;
|
|
8
|
-
function buildStatFs(info) {
|
|
9
|
-
const totalBytes = Number(info.get_attribute_uint64("filesystem::size") ?? 0);
|
|
10
|
-
const freeBytes = Number(info.get_attribute_uint64("filesystem::free") ?? 0);
|
|
11
|
-
const blocks = Math.floor(totalBytes / BSIZE);
|
|
12
|
-
const bfree = Math.floor(freeBytes / BSIZE);
|
|
13
|
-
return {
|
|
14
|
-
type: 0,
|
|
15
|
-
bsize: BSIZE,
|
|
16
|
-
blocks,
|
|
17
|
-
bfree,
|
|
18
|
-
bavail: bfree,
|
|
19
|
-
files: 0,
|
|
20
|
-
ffree: 0
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function buildBigIntStatFs(info) {
|
|
24
|
-
const totalBytes = BigInt(info.get_attribute_uint64("filesystem::size") ?? 0);
|
|
25
|
-
const freeBytes = BigInt(info.get_attribute_uint64("filesystem::free") ?? 0);
|
|
26
|
-
const bsize = BigInt(BSIZE);
|
|
27
|
-
const blocks = totalBytes / bsize;
|
|
28
|
-
const bfree = freeBytes / bsize;
|
|
29
|
-
return {
|
|
30
|
-
type: 0n,
|
|
31
|
-
bsize,
|
|
32
|
-
blocks,
|
|
33
|
-
bfree,
|
|
34
|
-
bavail: bfree,
|
|
35
|
-
files: 0n,
|
|
36
|
-
ffree: 0n
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function statfsSync(path, options) {
|
|
40
|
-
const file = Gio.File.new_for_path(normalizePath(path));
|
|
41
|
-
const info = file.query_filesystem_info(FS_INFO_ATTRS, null);
|
|
42
|
-
return options?.bigint === true ? buildBigIntStatFs(info) : buildStatFs(info);
|
|
43
|
-
}
|
|
44
|
-
function queryFsInfoAsync(path, useBigInt) {
|
|
45
|
-
return new Promise((resolve, reject) => {
|
|
46
|
-
const file = Gio.File.new_for_path(normalizePath(path));
|
|
47
|
-
file.query_filesystem_info_async(FS_INFO_ATTRS, GLib.PRIORITY_DEFAULT, null, (_s, res) => {
|
|
48
|
-
try {
|
|
49
|
-
const info = file.query_filesystem_info_finish(res);
|
|
50
|
-
resolve(useBigInt ? buildBigIntStatFs(info) : buildStatFs(info));
|
|
51
|
-
} catch (err) {
|
|
52
|
-
reject(err);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function statfs(path, optionsOrCb, callback) {
|
|
58
|
-
if (typeof optionsOrCb === "function") {
|
|
59
|
-
callback = optionsOrCb;
|
|
60
|
-
optionsOrCb = {};
|
|
61
|
-
}
|
|
62
|
-
const useBigInt = optionsOrCb?.bigint === true;
|
|
63
|
-
queryFsInfoAsync(path, useBigInt).then((result) => callback(null, result), (err) => callback(err, null));
|
|
64
|
-
}
|
|
65
|
-
async function statfsAsync(path, options) {
|
|
66
|
-
return queryFsInfoAsync(path, options?.bigint === true);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
export { statfs, statfsAsync, statfsSync };
|
|
1
|
+
import{normalizePath as e}from"./utils.js";import t from"@girs/glib-2.0";import n from"@girs/gio-2.0";const r=[`filesystem::size`,`filesystem::free`].join(`,`),i=4096;function a(e){let t=Number(e.get_attribute_uint64(`filesystem::size`)??0),n=Number(e.get_attribute_uint64(`filesystem::free`)??0),r=Math.floor(t/i),a=Math.floor(n/i);return{type:0,bsize:i,blocks:r,bfree:a,bavail:a,files:0,ffree:0}}function o(e){let t=BigInt(e.get_attribute_uint64(`filesystem::size`)??0),n=BigInt(e.get_attribute_uint64(`filesystem::free`)??0),r=BigInt(i),a=t/r,o=n/r;return{type:0n,bsize:r,blocks:a,bfree:o,bavail:o,files:0n,ffree:0n}}function s(t,i){let s=n.File.new_for_path(e(t)).query_filesystem_info(r,null);return i?.bigint===!0?o(s):a(s)}function c(i,s){return new Promise((c,l)=>{let u=n.File.new_for_path(e(i));u.query_filesystem_info_async(r,t.PRIORITY_DEFAULT,null,(e,t)=>{try{let e=u.query_filesystem_info_finish(t);c(s?o(e):a(e))}catch(e){l(e)}})})}function l(e,t,n){typeof t==`function`&&(n=t,t={}),c(e,t?.bigint===!0).then(e=>n(null,e),e=>n(e,null))}async function u(e,t){return c(e,t?.bigint===!0)}export{l as statfs,u as statfsAsync,s as statfsSync};
|
package/lib/esm/stats.js
CHANGED
|
@@ -1,172 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Gio from "@girs/gio-2.0";
|
|
3
|
-
import { basename } from "node:path";
|
|
4
|
-
|
|
5
|
-
//#region src/stats.ts
|
|
6
|
-
const STAT_ATTRIBUTES = "standard::*,time::*,unix::*";
|
|
7
|
-
function populateFromInfo(info) {
|
|
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
|
-
};
|
|
40
|
-
}
|
|
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
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
//#endregion
|
|
172
|
-
export { BigIntStats, STAT_ATTRIBUTES, Stats };
|
|
1
|
+
import{Dirent as e}from"./dirent.js";import t from"@girs/gio-2.0";import{basename as n}from"node:path";const r=`standard::*,time::*,unix::*`;function i(e){let t=e.get_attribute_uint64(`time::access`),n=e.get_attribute_uint32(`time::access-usec`)||0,r=e.get_attribute_uint64(`time::modified`),i=e.get_attribute_uint32(`time::modified-usec`)||0,a=e.get_attribute_uint64(`time::changed`),o=e.get_attribute_uint32(`time::changed-usec`)||0,s=e.get_attribute_uint64(`time::created`),c=e.get_attribute_uint32(`time::created-usec`)||0,l=t*1e3+n/1e3,u=r*1e3+i/1e3,d=a?a*1e3+o/1e3:u,f=s?s*1e3+c/1e3:d;return{dev:e.get_attribute_uint32(`unix::device`)||0,ino:Number(e.get_attribute_uint64(`unix::inode`)||0),mode:e.get_attribute_uint32(`unix::mode`)||0,nlink:e.get_attribute_uint32(`unix::nlink`)||0,uid:e.get_attribute_uint32(`unix::uid`)||0,gid:e.get_attribute_uint32(`unix::gid`)||0,rdev:e.get_attribute_uint32(`unix::rdev`)||0,size:Number(e.get_size()||0),blksize:e.get_attribute_uint32(`unix::block-size`)||4096,blocks:Number(e.get_attribute_uint64(`unix::blocks`)||0),atimeMs:l,mtimeMs:u,ctimeMs:d,birthtimeMs:f,atime:new Date(l),mtime:new Date(u),ctime:new Date(d),birthtime:new Date(f)}}var a=class extends e{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atime;mtime;ctime;birthtime;_info;constructor(e,a,o){let s,c;e instanceof t.FileInfo?(s=e,c=a.toString(),o||=n(c)):(c=e.toString(),typeof a==`string`&&(o=a),o||=n(c),s=t.File.new_for_path(c).query_info(r,t.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(c,o,s.get_file_type()),this._info=s;let l=i(s);this.dev=l.dev,this.ino=l.ino,this.mode=l.mode,this.nlink=l.nlink,this.uid=l.uid,this.gid=l.gid,this.rdev=l.rdev,this.size=l.size,this.blksize=l.blksize,this.blocks=l.blocks,this.atimeMs=l.atimeMs,this.mtimeMs=l.mtimeMs,this.ctimeMs=l.ctimeMs,this.birthtimeMs=l.birthtimeMs,this.atime=l.atime,this.mtime=l.mtime,this.ctime=l.ctime,this.birthtime=l.birthtime}},o=class extends e{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atimeNs;mtimeNs;ctimeNs;birthtimeNs;atime;mtime;ctime;birthtime;_info;constructor(e,a,o){let s,c;e instanceof t.FileInfo?(s=e,c=a.toString(),o||=n(c)):(c=e.toString(),typeof a==`string`&&(o=a),o||=n(c),s=t.File.new_for_path(c).query_info(r,t.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(c,o,s.get_file_type()),this._info=s;let l=i(s);this.dev=BigInt(l.dev),this.ino=BigInt(l.ino),this.mode=BigInt(l.mode),this.nlink=BigInt(l.nlink),this.uid=BigInt(l.uid),this.gid=BigInt(l.gid),this.rdev=BigInt(l.rdev),this.size=BigInt(l.size),this.blksize=BigInt(l.blksize),this.blocks=BigInt(l.blocks),this.atimeMs=BigInt(Math.trunc(l.atimeMs)),this.mtimeMs=BigInt(Math.trunc(l.mtimeMs)),this.ctimeMs=BigInt(Math.trunc(l.ctimeMs)),this.birthtimeMs=BigInt(Math.trunc(l.birthtimeMs)),this.atimeNs=this.atimeMs*1000000n,this.mtimeNs=this.mtimeMs*1000000n,this.ctimeNs=this.ctimeMs*1000000n,this.birthtimeNs=this.birthtimeMs*1000000n,this.atime=l.atime,this.mtime=l.mtime,this.ctime=l.ctime,this.birthtime=l.birthtime}};export{o as BigIntStats,r as STAT_ATTRIBUTES,a as Stats};
|