@zenfs/core 2.7.5 → 2.7.7
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/backends/backend.js +0 -2
- package/dist/backends/cow.d.ts +2 -2
- package/dist/backends/cow.js +6 -14
- package/dist/backends/passthrough.d.ts +0 -54
- package/dist/backends/passthrough.js +0 -54
- package/dist/backends/port.d.ts +2 -6
- package/dist/backends/port.js +3 -11
- package/dist/backends/store/fs.d.ts +0 -9
- package/dist/backends/store/fs.js +2 -24
- package/dist/backends/store/store.d.ts +1 -1
- package/dist/backends/store/store.js +2 -8
- package/dist/config.d.ts +7 -0
- package/dist/config.js +9 -3
- package/dist/internal/contexts.d.ts +1 -2
- package/dist/internal/credentials.d.ts +0 -3
- package/dist/internal/error.d.ts +5 -0
- package/dist/internal/error.js +10 -0
- package/dist/internal/file_index.js +0 -1
- package/dist/internal/index_fs.d.ts +2 -2
- package/dist/internal/index_fs.js +2 -2
- package/dist/internal/inode.d.ts +46 -43
- package/dist/internal/inode.js +75 -10
- package/dist/internal/rpc.d.ts +16 -7
- package/dist/internal/rpc.js +2 -11
- package/dist/mixins/async.js +22 -24
- package/dist/mixins/mutexed.d.ts +6 -41
- package/dist/mixins/mutexed.js +36 -109
- package/dist/mixins/sync.js +0 -2
- package/dist/node/async.js +2 -12
- package/dist/node/index.d.ts +1 -1
- package/dist/node/promises.d.ts +1 -6
- package/dist/node/promises.js +18 -22
- package/dist/node/stats.d.ts +25 -99
- package/dist/node/stats.js +22 -56
- package/dist/node/streams.d.ts +1 -37
- package/dist/node/sync.d.ts +1 -6
- package/dist/node/sync.js +16 -20
- package/dist/polyfills.js +25 -0
- package/dist/utils.d.ts +0 -4
- package/dist/vfs/acl.d.ts +1 -3
- package/dist/vfs/acl.js +1 -3
- package/dist/vfs/async.js +77 -69
- package/dist/vfs/config.d.ts +10 -1
- package/dist/vfs/config.js +5 -2
- package/dist/vfs/dir.d.ts +3 -0
- package/dist/vfs/dir.js +4 -1
- package/dist/vfs/file.d.ts +1 -8
- package/dist/vfs/file.js +11 -7
- package/dist/vfs/ioctl.js +2 -2
- package/dist/vfs/shared.d.ts +2 -0
- package/dist/vfs/shared.js +3 -4
- package/dist/vfs/sync.js +77 -61
- package/dist/vfs/vcache.d.ts +14 -14
- package/dist/vfs/vcache.js +65 -58
- package/dist/vfs/watchers.d.ts +1 -0
- package/dist/vfs/watchers.js +2 -4
- package/dist/vfs/xattr.js +18 -17
- package/package.json +2 -4
- package/scripts/make-index.js +1 -1
- package/tests/common/async.test.ts +35 -0
- package/tests/common/config.test.ts +1 -1
- package/tests/common/context.test.ts +1 -1
- package/tests/common/file_index.test.ts +1 -1
- package/tests/common/mounts.test.ts +12 -0
- package/tests/common/vcache.test.ts +13 -0
- package/tests/fs/concurrency.test.ts +3 -3
- package/tests/fs/links.test.ts +76 -0
- package/tests/fs/permissions.test.ts +232 -0
- package/tests/fs/stat.test.ts +1 -1
- package/tests/fs/streams.test.ts +1 -1
- package/tests/fs/xattr.test.ts +10 -0
- package/tests/common/mutex.test.ts +0 -61
package/dist/node/stats.d.ts
CHANGED
|
@@ -1,143 +1,71 @@
|
|
|
1
1
|
import type * as Node from 'node:fs';
|
|
2
2
|
import type { V_Context } from '../context.js';
|
|
3
|
-
import type { InodeFields } from '../internal/inode.js';
|
|
4
|
-
export interface
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
size: T;
|
|
10
|
-
/**
|
|
11
|
-
* Unix-style file mode (e.g. 0o644) that includes the item type
|
|
12
|
-
*/
|
|
13
|
-
mode: T;
|
|
14
|
-
/**
|
|
15
|
-
* Time of last access, since epoch
|
|
16
|
-
*/
|
|
17
|
-
atimeMs: T;
|
|
18
|
-
/**
|
|
19
|
-
* Time of last modification, since epoch
|
|
20
|
-
*/
|
|
21
|
-
mtimeMs: T;
|
|
22
|
-
/**
|
|
23
|
-
* Time of last time file status was changed, since epoch
|
|
24
|
-
*/
|
|
25
|
-
ctimeMs: T;
|
|
26
|
-
/**
|
|
27
|
-
* Time of file creation, since epoch
|
|
28
|
-
*/
|
|
29
|
-
birthtimeMs: T;
|
|
30
|
-
/**
|
|
31
|
-
* The id of the user that owns the file
|
|
32
|
-
*/
|
|
33
|
-
uid: T;
|
|
34
|
-
/**
|
|
35
|
-
* The id of the group that owns the file
|
|
36
|
-
*/
|
|
37
|
-
gid: T;
|
|
38
|
-
/**
|
|
39
|
-
* Inode number
|
|
40
|
-
*/
|
|
41
|
-
ino: T;
|
|
42
|
-
/**
|
|
43
|
-
* Number of hard links
|
|
44
|
-
*/
|
|
45
|
-
nlink: T;
|
|
3
|
+
import type { InodeFields, InodeLike, StatsLike } from '../internal/inode.js';
|
|
4
|
+
export interface StatsExtra<T extends number | bigint> {
|
|
5
|
+
/** ID of device containing file */
|
|
6
|
+
dev: T;
|
|
7
|
+
/** Block size for file system I/O */
|
|
8
|
+
blksize: T;
|
|
46
9
|
}
|
|
47
10
|
/**
|
|
48
11
|
* Provides information about a particular entry in the file system.
|
|
49
12
|
* Common code used by both Stats and BigIntStats.
|
|
50
13
|
*/
|
|
51
|
-
export declare abstract class StatsCommon<T extends number | bigint> implements Node.StatsBase<T>, StatsLike {
|
|
14
|
+
export declare abstract class StatsCommon<T extends number | bigint> implements Node.StatsBase<T>, StatsLike<T>, StatsExtra<T> {
|
|
52
15
|
protected abstract _isBigint: T extends bigint ? true : false;
|
|
53
16
|
protected _convert(arg: number | bigint | string | boolean): T;
|
|
54
17
|
get blocks(): T;
|
|
55
18
|
set blocks(value: T);
|
|
56
|
-
/**
|
|
57
|
-
* Unix-style file mode (e.g. 0o644) that includes the type of the item.
|
|
58
|
-
*/
|
|
19
|
+
/** Unix-style file mode (e.g. 0o644) that includes the type of the item. */
|
|
59
20
|
mode: T;
|
|
60
|
-
/**
|
|
61
|
-
* ID of device containing file
|
|
62
|
-
*/
|
|
21
|
+
/** ID of device containing file */
|
|
63
22
|
dev: T;
|
|
64
|
-
/**
|
|
65
|
-
* Inode number
|
|
66
|
-
*/
|
|
23
|
+
/** Inode number */
|
|
67
24
|
ino: T;
|
|
68
|
-
/**
|
|
69
|
-
* Device ID (if special file)
|
|
70
|
-
*/
|
|
25
|
+
/** Device ID (if special file) */
|
|
71
26
|
rdev: T;
|
|
72
|
-
/**
|
|
73
|
-
* Number of hard links
|
|
74
|
-
*/
|
|
27
|
+
/** Number of hard links */
|
|
75
28
|
nlink: T;
|
|
76
|
-
/**
|
|
77
|
-
* Block size for file system I/O
|
|
78
|
-
*/
|
|
29
|
+
/** Block size for file system I/O */
|
|
79
30
|
blksize: T;
|
|
80
|
-
/**
|
|
81
|
-
* User ID of owner
|
|
82
|
-
*/
|
|
31
|
+
/** User ID of owner */
|
|
83
32
|
uid: T;
|
|
84
|
-
/**
|
|
85
|
-
* Group ID of owner
|
|
86
|
-
*/
|
|
33
|
+
/** Group ID of owner */
|
|
87
34
|
gid: T;
|
|
88
|
-
/**
|
|
89
|
-
* Time of last access, since epoch
|
|
90
|
-
*/
|
|
35
|
+
/** Time of last access, since epoch */
|
|
91
36
|
atimeMs: T;
|
|
92
37
|
get atime(): Date;
|
|
93
38
|
set atime(value: Date);
|
|
94
39
|
get atimeInstant(): Temporal.Instant;
|
|
95
40
|
set atimeInstant(value: Temporal.Instant);
|
|
96
|
-
/**
|
|
97
|
-
* Time of last modification, since epoch
|
|
98
|
-
*/
|
|
41
|
+
/** Time of last modification, since epoch */
|
|
99
42
|
mtimeMs: T;
|
|
100
43
|
get mtime(): Date;
|
|
101
44
|
set mtime(value: Date);
|
|
102
45
|
get mtimeInstant(): Temporal.Instant;
|
|
103
46
|
set mtimeInstant(value: Temporal.Instant);
|
|
104
|
-
/**
|
|
105
|
-
* Time of last time file status was changed, since epoch
|
|
106
|
-
*/
|
|
47
|
+
/** Time of last time file status was changed, since epoch */
|
|
107
48
|
ctimeMs: T;
|
|
108
49
|
get ctime(): Date;
|
|
109
50
|
set ctime(value: Date);
|
|
110
51
|
get ctimeInstant(): Temporal.Instant;
|
|
111
52
|
set ctimeInstant(value: Temporal.Instant);
|
|
112
|
-
/**
|
|
113
|
-
* Time of file creation, since epoch
|
|
114
|
-
*/
|
|
53
|
+
/** Time of file creation, since epoch */
|
|
115
54
|
birthtimeMs: T;
|
|
116
55
|
get birthtime(): Date;
|
|
117
56
|
set birthtime(value: Date);
|
|
118
57
|
get birthtimeInstant(): Temporal.Instant;
|
|
119
58
|
set birthtimeInstant(value: Temporal.Instant);
|
|
120
|
-
/**
|
|
121
|
-
* Size of the item in bytes.
|
|
122
|
-
* For directories/symlinks, this is normally the size of the struct that represents the item.
|
|
123
|
-
*/
|
|
59
|
+
/** Size of the item in bytes. For directories/symlinks, this may be the size of the struct that represents the item. */
|
|
124
60
|
size: T;
|
|
125
|
-
/**
|
|
126
|
-
* @internal Used by inodes
|
|
127
|
-
*/
|
|
61
|
+
/** @internal Used by inodes */
|
|
128
62
|
data?: number;
|
|
129
|
-
/**
|
|
130
|
-
* @internal Used by inodes
|
|
131
|
-
*/
|
|
63
|
+
/** @internal Used by inodes */
|
|
132
64
|
flags?: number;
|
|
133
|
-
/**
|
|
134
|
-
* @internal Used by inodes
|
|
135
|
-
*/
|
|
65
|
+
/** @internal Used by inodes */
|
|
136
66
|
version?: number;
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode, ino, ...rest }?: Partial<StatsLike & InodeFields>);
|
|
67
|
+
/** Creates a new stats instance from a stats-like object. Can be used to copy stats (note) */
|
|
68
|
+
constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode, ino, rdev, dev, blksize, ...rest }?: Partial<InodeLike<number | bigint> & StatsExtra<number | bigint>>);
|
|
141
69
|
isFile(): boolean;
|
|
142
70
|
isDirectory(): boolean;
|
|
143
71
|
isSymbolicLink(): boolean;
|
|
@@ -183,8 +111,6 @@ export declare class BigIntStats extends StatsCommon<bigint> implements Node.Big
|
|
|
183
111
|
* @internal
|
|
184
112
|
*/
|
|
185
113
|
export declare function isStatsEqual<T extends number | bigint>(left: StatsCommon<T>, right: StatsCommon<T>): boolean;
|
|
186
|
-
/** @internal */
|
|
187
|
-
export declare const ZenFsType = 525687744115;
|
|
188
114
|
/**
|
|
189
115
|
* @hidden
|
|
190
116
|
*/
|
package/dist/node/stats.js
CHANGED
|
@@ -15,41 +15,23 @@ export class StatsCommon {
|
|
|
15
15
|
return this._convert(Math.ceil(Number(this.size) / 512));
|
|
16
16
|
}
|
|
17
17
|
set blocks(value) { }
|
|
18
|
-
/**
|
|
19
|
-
* Unix-style file mode (e.g. 0o644) that includes the type of the item.
|
|
20
|
-
*/
|
|
18
|
+
/** Unix-style file mode (e.g. 0o644) that includes the type of the item. */
|
|
21
19
|
mode;
|
|
22
|
-
/**
|
|
23
|
-
* ID of device containing file
|
|
24
|
-
*/
|
|
20
|
+
/** ID of device containing file */
|
|
25
21
|
dev = this._convert(0);
|
|
26
|
-
/**
|
|
27
|
-
* Inode number
|
|
28
|
-
*/
|
|
22
|
+
/** Inode number */
|
|
29
23
|
ino = this._convert(0);
|
|
30
|
-
/**
|
|
31
|
-
* Device ID (if special file)
|
|
32
|
-
*/
|
|
24
|
+
/** Device ID (if special file) */
|
|
33
25
|
rdev = this._convert(0);
|
|
34
|
-
/**
|
|
35
|
-
* Number of hard links
|
|
36
|
-
*/
|
|
26
|
+
/** Number of hard links */
|
|
37
27
|
nlink = this._convert(1);
|
|
38
|
-
/**
|
|
39
|
-
* Block size for file system I/O
|
|
40
|
-
*/
|
|
28
|
+
/** Block size for file system I/O */
|
|
41
29
|
blksize = this._convert(4096);
|
|
42
|
-
/**
|
|
43
|
-
* User ID of owner
|
|
44
|
-
*/
|
|
30
|
+
/** User ID of owner */
|
|
45
31
|
uid = this._convert(0);
|
|
46
|
-
/**
|
|
47
|
-
* Group ID of owner
|
|
48
|
-
*/
|
|
32
|
+
/** Group ID of owner */
|
|
49
33
|
gid = this._convert(0);
|
|
50
|
-
/**
|
|
51
|
-
* Time of last access, since epoch
|
|
52
|
-
*/
|
|
34
|
+
/** Time of last access, since epoch */
|
|
53
35
|
atimeMs;
|
|
54
36
|
get atime() {
|
|
55
37
|
return new Date(Number(this.atimeMs));
|
|
@@ -63,9 +45,7 @@ export class StatsCommon {
|
|
|
63
45
|
set atimeInstant(value) {
|
|
64
46
|
this.atimeMs = this._convert(value.epochMilliseconds);
|
|
65
47
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Time of last modification, since epoch
|
|
68
|
-
*/
|
|
48
|
+
/** Time of last modification, since epoch */
|
|
69
49
|
mtimeMs;
|
|
70
50
|
get mtime() {
|
|
71
51
|
return new Date(Number(this.mtimeMs));
|
|
@@ -79,9 +59,7 @@ export class StatsCommon {
|
|
|
79
59
|
set mtimeInstant(value) {
|
|
80
60
|
this.mtimeMs = this._convert(value.epochMilliseconds);
|
|
81
61
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Time of last time file status was changed, since epoch
|
|
84
|
-
*/
|
|
62
|
+
/** Time of last time file status was changed, since epoch */
|
|
85
63
|
ctimeMs;
|
|
86
64
|
get ctime() {
|
|
87
65
|
return new Date(Number(this.ctimeMs));
|
|
@@ -95,9 +73,7 @@ export class StatsCommon {
|
|
|
95
73
|
set ctimeInstant(value) {
|
|
96
74
|
this.ctimeMs = this._convert(value.epochMilliseconds);
|
|
97
75
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Time of file creation, since epoch
|
|
100
|
-
*/
|
|
76
|
+
/** Time of file creation, since epoch */
|
|
101
77
|
birthtimeMs;
|
|
102
78
|
get birthtime() {
|
|
103
79
|
return new Date(Number(this.birthtimeMs));
|
|
@@ -111,27 +87,16 @@ export class StatsCommon {
|
|
|
111
87
|
set birthtimeInstant(value) {
|
|
112
88
|
this.birthtimeMs = this._convert(value.epochMilliseconds);
|
|
113
89
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Size of the item in bytes.
|
|
116
|
-
* For directories/symlinks, this is normally the size of the struct that represents the item.
|
|
117
|
-
*/
|
|
90
|
+
/** Size of the item in bytes. For directories/symlinks, this may be the size of the struct that represents the item. */
|
|
118
91
|
size;
|
|
119
|
-
/**
|
|
120
|
-
* @internal Used by inodes
|
|
121
|
-
*/
|
|
92
|
+
/** @internal Used by inodes */
|
|
122
93
|
data;
|
|
123
|
-
/**
|
|
124
|
-
* @internal Used by inodes
|
|
125
|
-
*/
|
|
94
|
+
/** @internal Used by inodes */
|
|
126
95
|
flags;
|
|
127
|
-
/**
|
|
128
|
-
* @internal Used by inodes
|
|
129
|
-
*/
|
|
96
|
+
/** @internal Used by inodes */
|
|
130
97
|
version;
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
*/
|
|
134
|
-
constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode, ino, ...rest } = {}) {
|
|
98
|
+
/** Creates a new stats instance from a stats-like object. Can be used to copy stats (note) */
|
|
99
|
+
constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode, ino, rdev, dev, blksize, ...rest } = {}) {
|
|
135
100
|
const now = Date.now();
|
|
136
101
|
this.atimeMs = this._convert(atimeMs ?? now);
|
|
137
102
|
this.mtimeMs = this._convert(mtimeMs ?? now);
|
|
@@ -142,6 +107,9 @@ export class StatsCommon {
|
|
|
142
107
|
this.size = this._convert(size ?? 0);
|
|
143
108
|
this.ino = this._convert(ino ?? 0);
|
|
144
109
|
this.mode = this._convert(mode ?? 0o644 & c.S_IFREG);
|
|
110
|
+
this.rdev = this._convert(rdev ?? 0);
|
|
111
|
+
this.dev = this._convert(dev ?? 0);
|
|
112
|
+
this.blksize = this._convert(blksize ?? 4096);
|
|
145
113
|
if ((this.mode & c.S_IFMT) == 0) {
|
|
146
114
|
this.mode = (this.mode | this._convert(c.S_IFREG));
|
|
147
115
|
}
|
|
@@ -169,7 +137,7 @@ export class StatsCommon {
|
|
|
169
137
|
return (this.mode & c.S_IFMT) === c.S_IFIFO;
|
|
170
138
|
}
|
|
171
139
|
toJSON() {
|
|
172
|
-
return pick(this, _inode_fields);
|
|
140
|
+
return pick(this, ..._inode_fields, 'dev', 'blksize');
|
|
173
141
|
}
|
|
174
142
|
/**
|
|
175
143
|
* Checks if a given user/group has access to this item
|
|
@@ -225,8 +193,6 @@ export function isStatsEqual(left, right) {
|
|
|
225
193
|
&& +left.ctime == +right.ctime
|
|
226
194
|
&& left.mode == right.mode);
|
|
227
195
|
}
|
|
228
|
-
/** @internal */
|
|
229
|
-
export const ZenFsType = 0x7a656e6673; // 'z' 'e' 'n' 'f' 's'
|
|
230
196
|
/**
|
|
231
197
|
* @hidden
|
|
232
198
|
*/
|
package/dist/node/streams.d.ts
CHANGED
|
@@ -1,45 +1,10 @@
|
|
|
1
|
-
import type { Abortable } from 'node:events';
|
|
2
1
|
import type * as fs from 'node:fs';
|
|
3
2
|
import type { CreateReadStreamOptions, CreateWriteStreamOptions } from 'node:fs/promises';
|
|
4
3
|
import type { Callback } from '../utils.js';
|
|
5
4
|
import type { FileHandle } from './promises.js';
|
|
6
5
|
import { Readable } from '@zenfs/streams/readable';
|
|
7
6
|
import { Writable } from '@zenfs/streams/writable';
|
|
8
|
-
|
|
9
|
-
open?: (...args: unknown[]) => unknown;
|
|
10
|
-
close?: (...args: unknown[]) => unknown;
|
|
11
|
-
}
|
|
12
|
-
interface StreamOptions extends Abortable {
|
|
13
|
-
flags?: string;
|
|
14
|
-
encoding?: BufferEncoding;
|
|
15
|
-
fd?: number | FileHandle;
|
|
16
|
-
mode?: number;
|
|
17
|
-
autoClose?: boolean;
|
|
18
|
-
emitClose?: boolean;
|
|
19
|
-
start?: number;
|
|
20
|
-
highWaterMark?: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* This type is from node:fs but not exported.
|
|
24
|
-
* @hidden
|
|
25
|
-
*/
|
|
26
|
-
export interface ReadStreamOptions extends StreamOptions {
|
|
27
|
-
fs?: FSImplementation & {
|
|
28
|
-
read: (...args: unknown[]) => unknown;
|
|
29
|
-
};
|
|
30
|
-
end?: number;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* This type is from node:fs but not exported.
|
|
34
|
-
* @hidden
|
|
35
|
-
*/
|
|
36
|
-
export interface WriteStreamOptions extends StreamOptions {
|
|
37
|
-
flush?: boolean;
|
|
38
|
-
fs?: FSImplementation & {
|
|
39
|
-
write: (...args: unknown[]) => unknown;
|
|
40
|
-
writev?: (...args: unknown[]) => unknown;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
7
|
+
export type { ReadStreamOptions, WriteStreamOptions } from 'node:fs';
|
|
43
8
|
/**
|
|
44
9
|
* A ReadStream implementation that wraps an underlying global ReadableStream.
|
|
45
10
|
*/
|
|
@@ -76,4 +41,3 @@ export declare class WriteStream extends Writable implements fs.WriteStream {
|
|
|
76
41
|
get path(): string;
|
|
77
42
|
get bytesWritten(): number;
|
|
78
43
|
}
|
|
79
|
-
export {};
|
package/dist/node/sync.d.ts
CHANGED
|
@@ -210,13 +210,8 @@ export declare function mkdtempSync(this: V_Context, prefix: fs.PathLike, option
|
|
|
210
210
|
* When the object is disposed, the directory and its contents will be removed if it still exists.
|
|
211
211
|
* If the directory cannot be deleted, disposal will throw an error.
|
|
212
212
|
* The object has a `remove()` method which will perform the same task.
|
|
213
|
-
* @todo Add `satisfies` and maybe change return type once @types/node adds this.
|
|
214
213
|
*/
|
|
215
|
-
export declare function mkdtempDisposableSync(this: V_Context, prefix: fs.PathLike, options?: fs.EncodingOption | fs.BufferEncodingOption):
|
|
216
|
-
path: string;
|
|
217
|
-
remove(): void;
|
|
218
|
-
[Symbol.dispose](): void;
|
|
219
|
-
};
|
|
214
|
+
export declare function mkdtempDisposableSync(this: V_Context, prefix: fs.PathLike, options?: fs.EncodingOption | fs.BufferEncodingOption): fs.DisposableTempDir;
|
|
220
215
|
/**
|
|
221
216
|
* Synchronous `copyFile`. Copies a file.
|
|
222
217
|
* @param flags Optional flags for the copy operation. Currently supports these flags:
|
package/dist/node/sync.js
CHANGED
|
@@ -56,15 +56,14 @@ import { encodeUTF8 } from 'utilium';
|
|
|
56
56
|
import * as constants from '../constants.js';
|
|
57
57
|
import { contextOf } from '../internal/contexts.js';
|
|
58
58
|
import { wrap } from '../internal/error.js';
|
|
59
|
-
import { hasAccess, isDirectory } from '../internal/inode.js';
|
|
59
|
+
import { assertRemovable, hasAccess, isDirectory } from '../internal/inode.js';
|
|
60
60
|
import { dirname, join, matchesGlob, relative, resolve } from '../path.js';
|
|
61
61
|
import { _isNoEntry, _tempDirName, globToRegex, normalizeMode, normalizeOptions, normalizePath, normalizeTime } from '../utils.js';
|
|
62
62
|
import { checkAccess } from '../vfs/config.js';
|
|
63
63
|
import { deleteFD, fromFD, toFD } from '../vfs/file.js';
|
|
64
64
|
import * as flags from '../vfs/flags.js';
|
|
65
|
-
import { _statfs
|
|
65
|
+
import { _statfs } from '../vfs/shared.js';
|
|
66
66
|
import * as _sync from '../vfs/sync.js';
|
|
67
|
-
import { cacheOf, lockPathSync } from '../vfs/vcache.js';
|
|
68
67
|
import { emitChange } from '../vfs/watchers.js';
|
|
69
68
|
import { Dir, Dirent } from './dir.js';
|
|
70
69
|
import { BigIntStats, Stats } from './stats.js';
|
|
@@ -82,7 +81,7 @@ export function existsSync(path) {
|
|
|
82
81
|
return fs.existsSync(resolvedPath);
|
|
83
82
|
}
|
|
84
83
|
catch (e) {
|
|
85
|
-
if (e.errno == Errno.ENOENT)
|
|
84
|
+
if (e.errno == Errno.ENOENT || e.errno == Errno.ENOTDIR || e.errno == Errno.EACCES)
|
|
86
85
|
return false;
|
|
87
86
|
throw e;
|
|
88
87
|
}
|
|
@@ -134,16 +133,14 @@ export function truncateSync(path, len = 0) {
|
|
|
134
133
|
truncateSync;
|
|
135
134
|
export function unlinkSync(path) {
|
|
136
135
|
path = normalizePath.call(this, path);
|
|
137
|
-
const { fs, path: resolved } =
|
|
136
|
+
const { fs, cache, path: resolved } = _sync.resolve(this, path, true, { syscall: 'unlink', path });
|
|
138
137
|
try {
|
|
139
138
|
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
140
139
|
try {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
const _ = __addDisposableResource(env_2, lockPathSync(fs, dirname(resolved), 'rw'), false);
|
|
140
|
+
assertRemovable(this, cache.statSync(dirname(resolved)), cache.statSync(resolved));
|
|
141
|
+
const _ = __addDisposableResource(env_2, cache.lockSync(dirname(resolved), 'rw'), false);
|
|
145
142
|
fs.unlinkSync(resolved);
|
|
146
|
-
|
|
143
|
+
cache.remove(resolved);
|
|
147
144
|
}
|
|
148
145
|
catch (e_2) {
|
|
149
146
|
env_2.error = e_2;
|
|
@@ -372,15 +369,14 @@ export function rmdirSync(path) {
|
|
|
372
369
|
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
373
370
|
try {
|
|
374
371
|
path = normalizePath.call(this, path);
|
|
375
|
-
const { fs, path: resolved } = _sync.resolve(this, path);
|
|
376
|
-
const stats =
|
|
372
|
+
const { fs, cache, path: resolved } = _sync.resolve(this, path, true);
|
|
373
|
+
const stats = cache.statSync(resolved, { path, syscall: 'rmdir' });
|
|
377
374
|
if (!isDirectory(stats))
|
|
378
375
|
throw UV('ENOTDIR', 'rmdir', path);
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const _ = __addDisposableResource(env_5, lockPathSync(fs, dirname(resolved), 'rw'), false);
|
|
376
|
+
assertRemovable(this, cache.statSync(dirname(resolved), { path, syscall: 'rmdir' }), stats, { syscall: 'rmdir', path });
|
|
377
|
+
const _ = __addDisposableResource(env_5, cache.lockSync(dirname(resolved), 'rw'), false);
|
|
382
378
|
wrap(fs, 'rmdirSync', path)(resolved);
|
|
383
|
-
|
|
379
|
+
cache.remove(resolved);
|
|
384
380
|
emitChange(this, 'rename', path.toString());
|
|
385
381
|
}
|
|
386
382
|
catch (e_5) {
|
|
@@ -435,7 +431,7 @@ export function symlinkSync(target, path, type = 'file') {
|
|
|
435
431
|
path = normalizePath.call(this, path);
|
|
436
432
|
const file = __addDisposableResource(env_6, _sync.open(this, path, { flag: 'wx', mode: 0o644 }), false);
|
|
437
433
|
file.writeSync(encodeUTF8(normalizePath.call(this, target, true)));
|
|
438
|
-
file.chmodSync(constants.S_IFLNK);
|
|
434
|
+
file.chmodSync(constants.S_IFLNK | 0o777);
|
|
439
435
|
}
|
|
440
436
|
catch (e_6) {
|
|
441
437
|
env_6.error = e_6;
|
|
@@ -541,7 +537,7 @@ export function rmSync(path, options) {
|
|
|
541
537
|
path = normalizePath.call(this, path);
|
|
542
538
|
let stats;
|
|
543
539
|
try {
|
|
544
|
-
stats = lstatSync.
|
|
540
|
+
stats = lstatSync.call(this, path);
|
|
545
541
|
}
|
|
546
542
|
catch (error) {
|
|
547
543
|
if (error.code != 'ENOENT' || !options?.force)
|
|
@@ -583,7 +579,6 @@ mkdtempSync;
|
|
|
583
579
|
* When the object is disposed, the directory and its contents will be removed if it still exists.
|
|
584
580
|
* If the directory cannot be deleted, disposal will throw an error.
|
|
585
581
|
* The object has a `remove()` method which will perform the same task.
|
|
586
|
-
* @todo Add `satisfies` and maybe change return type once @types/node adds this.
|
|
587
582
|
*/
|
|
588
583
|
export function mkdtempDisposableSync(prefix, options) {
|
|
589
584
|
const path = _tempDirName(prefix);
|
|
@@ -591,6 +586,7 @@ export function mkdtempDisposableSync(prefix, options) {
|
|
|
591
586
|
const remove = () => rmSync(path, { recursive: true, force: true });
|
|
592
587
|
return { path, remove, [Symbol.dispose]: remove };
|
|
593
588
|
}
|
|
589
|
+
mkdtempDisposableSync;
|
|
594
590
|
/**
|
|
595
591
|
* Synchronous `copyFile`. Copies a file.
|
|
596
592
|
* @param flags Optional flags for the copy operation. Currently supports these flags:
|
|
@@ -706,7 +702,7 @@ export function cpSync(source, destination, opts) {
|
|
|
706
702
|
cpSync;
|
|
707
703
|
export function statfsSync(path, options) {
|
|
708
704
|
path = normalizePath.call(this, path);
|
|
709
|
-
const { fs } =
|
|
705
|
+
const { fs } = _sync.resolve(this, path);
|
|
710
706
|
return _statfs(fs, options?.bigint);
|
|
711
707
|
}
|
|
712
708
|
export function globSync(pattern, options = {}) {
|
package/dist/polyfills.js
CHANGED
|
@@ -57,4 +57,29 @@ Uint8Array.fromHex ??=
|
|
|
57
57
|
}
|
|
58
58
|
return bytes;
|
|
59
59
|
});
|
|
60
|
+
Array.fromAsync ??=
|
|
61
|
+
(warn('Using a polyfill of Array.fromAsync'),
|
|
62
|
+
async function collectAsyncIterator(it) {
|
|
63
|
+
const results = [];
|
|
64
|
+
for await (const result of it) {
|
|
65
|
+
results.push(result);
|
|
66
|
+
}
|
|
67
|
+
return results;
|
|
68
|
+
});
|
|
69
|
+
Map.prototype.getOrInsert ??=
|
|
70
|
+
(warn('Using a polyfill of Map.prototype.getOrInsert'),
|
|
71
|
+
function getOrInsert(key, defaultValue) {
|
|
72
|
+
if (!this.has(key))
|
|
73
|
+
this.set(key, defaultValue);
|
|
74
|
+
return this.get(key);
|
|
75
|
+
});
|
|
76
|
+
Map.prototype.getOrInsertComputed ??=
|
|
77
|
+
(warn('Using a polyfill of Map.prototype.getOrInsertComputed'),
|
|
78
|
+
function getOrInsertComputed(key, callback) {
|
|
79
|
+
if (this.has(key))
|
|
80
|
+
return this.get(key);
|
|
81
|
+
const value = callback(key);
|
|
82
|
+
this.set(key, value);
|
|
83
|
+
return value;
|
|
84
|
+
});
|
|
60
85
|
/* node:coverage enable */
|
package/dist/utils.d.ts
CHANGED
|
@@ -3,10 +3,6 @@ import type * as fs from 'node:fs';
|
|
|
3
3
|
import type { Worker as NodeWorker } from 'node:worker_threads';
|
|
4
4
|
import { type OptionalTuple } from 'utilium';
|
|
5
5
|
import type { V_Context } from './internal/contexts.js';
|
|
6
|
-
declare global {
|
|
7
|
-
function atob(data: string): string;
|
|
8
|
-
function btoa(data: string): string;
|
|
9
|
-
}
|
|
10
6
|
/**
|
|
11
7
|
* Decodes a directory listing
|
|
12
8
|
* @hidden
|
package/dist/vfs/acl.d.ts
CHANGED
package/dist/vfs/acl.js
CHANGED
|
@@ -62,9 +62,7 @@ export var Tag;
|
|
|
62
62
|
Tag[Tag["Group"] = 8] = "Group";
|
|
63
63
|
Tag[Tag["Mask"] = 16] = "Mask";
|
|
64
64
|
Tag[Tag["Other"] = 32] = "Other";
|
|
65
|
-
/**
|
|
66
|
-
* @internal @hidden
|
|
67
|
-
*/
|
|
65
|
+
/** @internal @hidden */
|
|
68
66
|
Tag[Tag["_None"] = 0] = "_None";
|
|
69
67
|
})(Tag || (Tag = {}));
|
|
70
68
|
let Entry = (() => {
|