@zenfs/core 2.4.1 → 2.4.3
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/COPYING.md +24 -0
- package/{readme.md → README.md} +16 -74
- package/dist/backends/backend.d.ts +1 -1
- package/dist/backends/fetch.js +1 -1
- package/dist/backends/memory.js +1 -1
- package/dist/backends/passthrough.d.ts +1 -2
- package/dist/backends/single_buffer.d.ts +1 -1
- package/dist/backends/single_buffer.js +27 -24
- package/dist/backends/store/fs.js +4 -4
- package/dist/config.js +15 -15
- package/dist/context.js +3 -2
- package/dist/index.d.ts +9 -3
- package/dist/index.js +9 -4
- package/dist/internal/contexts.d.ts +5 -4
- package/dist/internal/devices.js +1 -1
- package/dist/internal/error.d.ts +11 -2
- package/dist/internal/error.js +38 -2
- package/dist/internal/file_index.js +1 -1
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +2 -1
- package/dist/internal/index_fs.js +1 -1
- package/dist/internal/inode.d.ts +51 -2
- package/dist/internal/inode.js +18 -2
- package/dist/mixins/shared.js +1 -1
- package/dist/node/async.d.ts +278 -0
- package/dist/node/async.js +518 -0
- package/dist/node/compat.d.ts +4 -0
- package/dist/node/compat.js +6 -0
- package/dist/node/dir.d.ts +78 -0
- package/dist/node/dir.js +150 -0
- package/dist/node/index.d.ts +8 -0
- package/dist/node/index.js +8 -0
- package/dist/{vfs → node}/promises.d.ts +10 -66
- package/dist/{vfs → node}/promises.js +141 -478
- package/dist/{vfs → node}/stats.d.ts +0 -4
- package/dist/{vfs → node}/stats.js +1 -16
- package/dist/{vfs → node}/streams.js +2 -2
- package/dist/node/sync.d.ts +252 -0
- package/dist/node/sync.js +682 -0
- package/dist/node/types.d.ts +21 -0
- package/dist/utils.d.ts +1 -7
- package/dist/utils.js +0 -6
- package/dist/vfs/acl.js +1 -1
- package/dist/vfs/async.d.ts +22 -278
- package/dist/vfs/async.js +212 -501
- package/dist/vfs/dir.d.ts +5 -82
- package/dist/vfs/dir.js +5 -233
- package/dist/vfs/file.d.ts +52 -13
- package/dist/vfs/file.js +167 -25
- package/dist/vfs/flags.js +1 -1
- package/dist/vfs/index.d.ts +2 -5
- package/dist/vfs/index.js +2 -5
- package/dist/vfs/shared.d.ts +25 -1
- package/dist/vfs/shared.js +6 -4
- package/dist/vfs/sync.d.ts +17 -245
- package/dist/vfs/sync.js +129 -773
- package/dist/vfs/watchers.d.ts +1 -1
- package/dist/vfs/watchers.js +2 -2
- package/dist/vfs/xattr.js +1 -1
- package/eslint.shared.js +1 -0
- package/package.json +7 -5
- package/scripts/make-index.js +5 -29
- package/scripts/test.js +59 -51
- package/tests/backend/fetch.test.ts +2 -2
- package/tests/backend/port.test.ts +2 -3
- package/tests/backend/single-buffer.test.ts +48 -1
- package/tests/common/casefold.test.ts +1 -1
- package/tests/common/context.test.ts +11 -4
- package/tests/common/devices.test.ts +3 -3
- package/tests/common/handle.test.ts +4 -3
- package/tests/common/inode.test.ts +2 -2
- package/tests/common/mounts.test.ts +1 -3
- package/tests/common/mutex.test.ts +1 -3
- package/tests/common/path.test.ts +2 -2
- package/tests/common/readline.test.ts +1 -1
- package/tests/common.ts +5 -4
- package/tests/fetch/fetch.ts +1 -1
- package/tests/fs/dir.test.ts +3 -43
- package/tests/fs/directory.test.ts +4 -4
- package/tests/fs/errors.test.ts +2 -2
- package/tests/fs/links.test.ts +1 -1
- package/tests/fs/permissions.test.ts +3 -3
- package/tests/fs/read.test.ts +1 -1
- package/tests/fs/scaling.test.ts +1 -1
- package/tests/fs/stat.test.ts +1 -2
- package/tests/fs/times.test.ts +1 -1
- package/tests/fs/watch.test.ts +3 -2
- package/tests/setup/context.ts +1 -2
- package/tests/setup/cow.ts +1 -1
- package/tests/setup/index.ts +2 -2
- package/tests/setup/port.ts +1 -1
- package/tests/setup/single-buffer.ts +1 -1
- package/tests/setup.ts +4 -3
- package/dist/vfs/types.d.ts +0 -24
- package/tests/assignment.ts +0 -21
- /package/dist/{vfs/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/{vfs/constants.js → constants.js} +0 -0
- /package/dist/{readline.d.ts → node/readline.d.ts} +0 -0
- /package/dist/{readline.js → node/readline.js} +0 -0
- /package/dist/{vfs → node}/streams.d.ts +0 -0
- /package/dist/{vfs → node}/types.js +0 -0
package/dist/vfs/dir.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import type { Dir as _Dir, Dirent as _Dirent } from 'node:fs';
|
|
2
|
-
import type { V_Context } from '../context.js';
|
|
3
|
-
import type { InodeLike } from '../internal/inode.js';
|
|
4
|
-
import type { Callback } from '../utils.js';
|
|
5
|
-
import { Buffer } from 'buffer';
|
|
6
|
-
import { BufferView } from 'utilium/buffer.js';
|
|
7
1
|
/**
|
|
8
2
|
* @see `DT_*` in `dirent.h`
|
|
9
3
|
*/
|
|
@@ -28,80 +22,9 @@ export declare function ifToDt(mode: number): DirType;
|
|
|
28
22
|
* @see `DTTOIF` in `dirent.h`
|
|
29
23
|
*/
|
|
30
24
|
export declare function dtToIf(dt: DirType): number;
|
|
31
|
-
declare
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
protected accessor type: DirType;
|
|
37
|
-
protected accessor _name: Uint8Array;
|
|
38
|
-
get name(): Name;
|
|
39
|
-
/**
|
|
40
|
-
* @internal @protected
|
|
41
|
-
*/
|
|
42
|
-
_encoding?: BufferEncoding | 'buffer' | null;
|
|
43
|
-
/**
|
|
44
|
-
* @internal @protected
|
|
45
|
-
*/
|
|
46
|
-
_parentPath: string;
|
|
47
|
-
get parentPath(): string;
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated Removed in Node v24, use `parentPath` instead.
|
|
50
|
-
*/
|
|
51
|
-
get path(): string;
|
|
52
|
-
/**
|
|
53
|
-
* @internal
|
|
54
|
-
*/
|
|
55
|
-
static from(path: string, stats: InodeLike, encoding?: BufferEncoding | 'buffer' | null): Dirent;
|
|
56
|
-
isFile(): boolean;
|
|
57
|
-
isDirectory(): boolean;
|
|
58
|
-
isBlockDevice(): boolean;
|
|
59
|
-
isCharacterDevice(): boolean;
|
|
60
|
-
isSymbolicLink(): boolean;
|
|
61
|
-
isFIFO(): boolean;
|
|
62
|
-
isSocket(): boolean;
|
|
25
|
+
export declare class Dirent {
|
|
26
|
+
ino: number;
|
|
27
|
+
type: DirType;
|
|
28
|
+
path: string;
|
|
29
|
+
name: string;
|
|
63
30
|
}
|
|
64
|
-
/**
|
|
65
|
-
* A class representing a directory stream.
|
|
66
|
-
*/
|
|
67
|
-
export declare class Dir implements _Dir, AsyncIterator<Dirent> {
|
|
68
|
-
readonly path: string;
|
|
69
|
-
protected readonly context: V_Context;
|
|
70
|
-
protected closed: boolean;
|
|
71
|
-
protected checkClosed(): void;
|
|
72
|
-
protected _entries?: Dirent[];
|
|
73
|
-
constructor(path: string, context: V_Context);
|
|
74
|
-
/**
|
|
75
|
-
* Asynchronously close the directory's underlying resource handle.
|
|
76
|
-
* Subsequent reads will result in errors.
|
|
77
|
-
*/
|
|
78
|
-
close(): Promise<void>;
|
|
79
|
-
close(cb: Callback): void;
|
|
80
|
-
/**
|
|
81
|
-
* Synchronously close the directory's underlying resource handle.
|
|
82
|
-
* Subsequent reads will result in errors.
|
|
83
|
-
*/
|
|
84
|
-
closeSync(): void;
|
|
85
|
-
protected _read(): Promise<Dirent | null>;
|
|
86
|
-
/**
|
|
87
|
-
* Asynchronously read the next directory entry via `readdir(3)` as an `Dirent`.
|
|
88
|
-
* After the read is completed, a value is returned that will be resolved with an `Dirent`, or `null` if there are no more directory entries to read.
|
|
89
|
-
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
|
|
90
|
-
*/
|
|
91
|
-
read(): Promise<Dirent | null>;
|
|
92
|
-
read(cb: Callback<[Dirent | null]>): void;
|
|
93
|
-
/**
|
|
94
|
-
* Synchronously read the next directory entry via `readdir(3)` as a `Dirent`.
|
|
95
|
-
* If there are no more directory entries to read, null will be returned.
|
|
96
|
-
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
|
|
97
|
-
*/
|
|
98
|
-
readSync(): Dirent | null;
|
|
99
|
-
next(): Promise<IteratorResult<Dirent>>;
|
|
100
|
-
/**
|
|
101
|
-
* Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
|
|
102
|
-
*/
|
|
103
|
-
[Symbol.asyncIterator](): this;
|
|
104
|
-
[Symbol.dispose](): void;
|
|
105
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
106
|
-
}
|
|
107
|
-
export {};
|
package/dist/vfs/dir.js
CHANGED
|
@@ -1,47 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
-
var _, done = false;
|
|
7
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
-
var context = {};
|
|
9
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
-
if (kind === "accessor") {
|
|
14
|
-
if (result === void 0) continue;
|
|
15
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
-
}
|
|
20
|
-
else if (_ = accept(result)) {
|
|
21
|
-
if (kind === "field") initializers.unshift(_);
|
|
22
|
-
else descriptor[key] = _;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
-
done = true;
|
|
27
|
-
};
|
|
28
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
-
var useValue = arguments.length > 2;
|
|
30
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
-
}
|
|
33
|
-
return useValue ? value : void 0;
|
|
34
|
-
};
|
|
35
|
-
import { Buffer } from 'buffer';
|
|
36
|
-
import { withErrno } from 'kerium';
|
|
37
|
-
import { warn } from 'kerium/log';
|
|
38
|
-
import { sizeof } from 'memium';
|
|
39
|
-
import { $from, struct, types as t } from 'memium/decorators';
|
|
40
|
-
import { encodeUTF8 } from 'utilium';
|
|
41
|
-
import { BufferView } from 'utilium/buffer.js';
|
|
42
|
-
import { basename, dirname } from '../path.js';
|
|
43
|
-
import { readdir } from './promises.js';
|
|
44
|
-
import { readdirSync } from './sync.js';
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
45
2
|
/**
|
|
46
3
|
* @see `DT_*` in `dirent.h`
|
|
47
4
|
*/
|
|
@@ -71,194 +28,9 @@ export function ifToDt(mode) {
|
|
|
71
28
|
export function dtToIf(dt) {
|
|
72
29
|
return dt << 12;
|
|
73
30
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let _classDescriptor;
|
|
78
|
-
let _classExtraInitializers = [];
|
|
79
|
-
let _classThis;
|
|
80
|
-
let _classSuper = $from(BufferView);
|
|
81
|
-
let _ino_decorators;
|
|
82
|
-
let _ino_initializers = [];
|
|
83
|
-
let _ino_extraInitializers = [];
|
|
84
|
-
let __ino_decorators;
|
|
85
|
-
let __ino_initializers = [];
|
|
86
|
-
let __ino_extraInitializers = [];
|
|
87
|
-
let _type_decorators;
|
|
88
|
-
let _type_initializers = [];
|
|
89
|
-
let _type_extraInitializers = [];
|
|
90
|
-
let __name_decorators;
|
|
91
|
-
let __name_initializers = [];
|
|
92
|
-
let __name_extraInitializers = [];
|
|
93
|
-
var Dirent = class extends _classSuper {
|
|
94
|
-
static { _classThis = this; }
|
|
95
|
-
static {
|
|
96
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
97
|
-
_ino_decorators = [(_a = t).uint32.bind(_a)];
|
|
98
|
-
__ino_decorators = [(_b = t).uint32.bind(_b)];
|
|
99
|
-
_type_decorators = [(_c = t).uint8.bind(_c)];
|
|
100
|
-
__name_decorators = [t.char(256)];
|
|
101
|
-
__esDecorate(this, null, _ino_decorators, { kind: "accessor", name: "ino", static: false, private: false, access: { has: obj => "ino" in obj, get: obj => obj.ino, set: (obj, value) => { obj.ino = value; } }, metadata: _metadata }, _ino_initializers, _ino_extraInitializers);
|
|
102
|
-
__esDecorate(this, null, __ino_decorators, { kind: "accessor", name: "_ino", static: false, private: false, access: { has: obj => "_ino" in obj, get: obj => obj._ino, set: (obj, value) => { obj._ino = value; } }, metadata: _metadata }, __ino_initializers, __ino_extraInitializers);
|
|
103
|
-
__esDecorate(this, null, _type_decorators, { kind: "accessor", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
|
|
104
|
-
__esDecorate(this, null, __name_decorators, { kind: "accessor", name: "_name", static: false, private: false, access: { has: obj => "_name" in obj, get: obj => obj._name, set: (obj, value) => { obj._name = value; } }, metadata: _metadata }, __name_initializers, __name_extraInitializers);
|
|
105
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
106
|
-
Dirent = _classThis = _classDescriptor.value;
|
|
107
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
108
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
109
|
-
}
|
|
110
|
-
#ino_accessor_storage = __runInitializers(this, _ino_initializers, void 0);
|
|
111
|
-
get ino() { return this.#ino_accessor_storage; }
|
|
112
|
-
set ino(value) { this.#ino_accessor_storage = value; }
|
|
113
|
-
#_ino_accessor_storage = (__runInitializers(this, _ino_extraInitializers), __runInitializers(this, __ino_initializers, void 0));
|
|
114
|
-
/** Reserved for 64-bit inodes */
|
|
115
|
-
get _ino() { return this.#_ino_accessor_storage; }
|
|
116
|
-
set _ino(value) { this.#_ino_accessor_storage = value; }
|
|
117
|
-
#type_accessor_storage = (__runInitializers(this, __ino_extraInitializers), __runInitializers(this, _type_initializers, void 0));
|
|
118
|
-
get type() { return this.#type_accessor_storage; }
|
|
119
|
-
set type(value) { this.#type_accessor_storage = value; }
|
|
120
|
-
#_name_accessor_storage = (__runInitializers(this, _type_extraInitializers), __runInitializers(this, __name_initializers, void 0));
|
|
121
|
-
get _name() { return this.#_name_accessor_storage; }
|
|
122
|
-
set _name(value) { this.#_name_accessor_storage = value; }
|
|
123
|
-
get name() {
|
|
124
|
-
const end = (this._name.indexOf(0) + 1 || 256) - 1;
|
|
125
|
-
const name = Buffer.from(this._name.subarray(0, end));
|
|
126
|
-
return (this._encoding == 'buffer' ? name : name.toString(this._encoding));
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* @internal @protected
|
|
130
|
-
*/
|
|
131
|
-
_encoding = __runInitializers(this, __name_extraInitializers);
|
|
132
|
-
/**
|
|
133
|
-
* @internal @protected
|
|
134
|
-
*/
|
|
135
|
-
_parentPath;
|
|
136
|
-
get parentPath() {
|
|
137
|
-
return this._parentPath;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* @deprecated Removed in Node v24, use `parentPath` instead.
|
|
141
|
-
*/
|
|
142
|
-
get path() {
|
|
143
|
-
warn('Dirent.path was removed in Node v24, use parentPath instead');
|
|
144
|
-
return this._parentPath;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* @internal
|
|
148
|
-
*/
|
|
149
|
-
static from(path, stats, encoding) {
|
|
150
|
-
const dirent = new Dirent(new ArrayBuffer(sizeof(Dirent) + 1));
|
|
151
|
-
dirent._parentPath = dirname(path);
|
|
152
|
-
dirent._name = encodeUTF8(basename(path));
|
|
153
|
-
dirent.ino = stats.ino;
|
|
154
|
-
dirent.type = ifToDt(stats.mode);
|
|
155
|
-
dirent._encoding = encoding;
|
|
156
|
-
return dirent;
|
|
157
|
-
}
|
|
158
|
-
isFile() {
|
|
159
|
-
return this.type === DirType.REG;
|
|
160
|
-
}
|
|
161
|
-
isDirectory() {
|
|
162
|
-
return this.type === DirType.DIR;
|
|
163
|
-
}
|
|
164
|
-
isBlockDevice() {
|
|
165
|
-
return this.type === DirType.BLK;
|
|
166
|
-
}
|
|
167
|
-
isCharacterDevice() {
|
|
168
|
-
return this.type === DirType.CHR;
|
|
169
|
-
}
|
|
170
|
-
isSymbolicLink() {
|
|
171
|
-
return this.type === DirType.LNK;
|
|
172
|
-
}
|
|
173
|
-
isFIFO() {
|
|
174
|
-
return this.type === DirType.FIFO;
|
|
175
|
-
}
|
|
176
|
-
isSocket() {
|
|
177
|
-
return this.type === DirType.SOCK;
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
return Dirent = _classThis;
|
|
181
|
-
})();
|
|
182
|
-
export { Dirent };
|
|
183
|
-
/**
|
|
184
|
-
* A class representing a directory stream.
|
|
185
|
-
*/
|
|
186
|
-
export class Dir {
|
|
31
|
+
export class Dirent {
|
|
32
|
+
ino;
|
|
33
|
+
type;
|
|
187
34
|
path;
|
|
188
|
-
|
|
189
|
-
closed = false;
|
|
190
|
-
checkClosed() {
|
|
191
|
-
if (this.closed)
|
|
192
|
-
throw withErrno('EBADF', 'Can not use closed Dir');
|
|
193
|
-
}
|
|
194
|
-
_entries;
|
|
195
|
-
constructor(path, context) {
|
|
196
|
-
this.path = path;
|
|
197
|
-
this.context = context;
|
|
198
|
-
}
|
|
199
|
-
close(cb) {
|
|
200
|
-
this.closed = true;
|
|
201
|
-
if (!cb) {
|
|
202
|
-
return Promise.resolve();
|
|
203
|
-
}
|
|
204
|
-
cb(null);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Synchronously close the directory's underlying resource handle.
|
|
208
|
-
* Subsequent reads will result in errors.
|
|
209
|
-
*/
|
|
210
|
-
closeSync() {
|
|
211
|
-
this.closed = true;
|
|
212
|
-
}
|
|
213
|
-
async _read() {
|
|
214
|
-
this.checkClosed();
|
|
215
|
-
this._entries ??= await readdir.call(this.context, this.path, {
|
|
216
|
-
withFileTypes: true,
|
|
217
|
-
});
|
|
218
|
-
if (!this._entries.length)
|
|
219
|
-
return null;
|
|
220
|
-
return this._entries.shift() ?? null;
|
|
221
|
-
}
|
|
222
|
-
read(cb) {
|
|
223
|
-
if (!cb) {
|
|
224
|
-
return this._read();
|
|
225
|
-
}
|
|
226
|
-
void this._read().then(value => cb(null, value));
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Synchronously read the next directory entry via `readdir(3)` as a `Dirent`.
|
|
230
|
-
* If there are no more directory entries to read, null will be returned.
|
|
231
|
-
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
|
|
232
|
-
*/
|
|
233
|
-
readSync() {
|
|
234
|
-
this.checkClosed();
|
|
235
|
-
this._entries ??= readdirSync.call(this.context, this.path, { withFileTypes: true });
|
|
236
|
-
if (!this._entries.length)
|
|
237
|
-
return null;
|
|
238
|
-
return this._entries.shift() ?? null;
|
|
239
|
-
}
|
|
240
|
-
async next() {
|
|
241
|
-
const value = await this._read();
|
|
242
|
-
if (value) {
|
|
243
|
-
return { done: false, value };
|
|
244
|
-
}
|
|
245
|
-
await this.close();
|
|
246
|
-
return { done: true, value: undefined };
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
|
|
250
|
-
*/
|
|
251
|
-
[Symbol.asyncIterator]() {
|
|
252
|
-
return this;
|
|
253
|
-
}
|
|
254
|
-
[Symbol.dispose]() {
|
|
255
|
-
if (this.closed)
|
|
256
|
-
return;
|
|
257
|
-
this.closeSync();
|
|
258
|
-
}
|
|
259
|
-
async [Symbol.asyncDispose]() {
|
|
260
|
-
if (this.closed)
|
|
261
|
-
return;
|
|
262
|
-
await this.close();
|
|
263
|
-
}
|
|
35
|
+
name;
|
|
264
36
|
}
|
package/dist/vfs/file.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface FileReadResult<T extends ArrayBufferView> {
|
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export declare class
|
|
13
|
+
export declare class Handle {
|
|
14
14
|
readonly context: V_Context;
|
|
15
15
|
readonly path: string;
|
|
16
16
|
readonly fs: FileSystem;
|
|
@@ -41,25 +41,64 @@ export declare class SyncHandle {
|
|
|
41
41
|
* Whether the file is open or closed
|
|
42
42
|
*/
|
|
43
43
|
protected closed: boolean;
|
|
44
|
+
get isClosed(): boolean;
|
|
44
45
|
/**
|
|
45
46
|
* Creates a file with `path` and, optionally, the given contents.
|
|
46
47
|
* Note that, if contents is specified, it will be mutated by the file.
|
|
47
48
|
*/
|
|
48
49
|
constructor(context: V_Context, path: string, fs: FileSystem, internalPath: string, flag: number, inode: InodeLike);
|
|
50
|
+
protected get _isSync(): boolean;
|
|
49
51
|
[Symbol.dispose](): void;
|
|
50
|
-
|
|
51
|
-
sync(): void;
|
|
52
|
+
syncSync(): void;
|
|
52
53
|
/**
|
|
53
54
|
* Default implementation maps to `syncSync`.
|
|
54
55
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
datasyncSync(): void;
|
|
57
|
+
closeSync(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Cleans up. This will *not* sync the file data to the FS
|
|
60
|
+
*/
|
|
61
|
+
protected disposeSync(force?: boolean): void;
|
|
62
|
+
truncateSync(length: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Write buffer to the file.
|
|
65
|
+
* @param buffer Uint8Array containing the data to write to the file.
|
|
66
|
+
* @param offset Offset in the buffer to start reading data from.
|
|
67
|
+
* @param length The amount of bytes to write to the file.
|
|
68
|
+
* @param position Offset from the beginning of the file where this data should be written.
|
|
69
|
+
* If position is null, the data will be written at the current position.
|
|
70
|
+
* @returns bytes written
|
|
71
|
+
*/
|
|
72
|
+
writeSync(buffer: Uint8Array, offset?: number, length?: number, position?: number): number;
|
|
73
|
+
/**
|
|
74
|
+
* Read data from the file.
|
|
75
|
+
* @param buffer The buffer that the data will be written to.
|
|
76
|
+
* @param offset The offset within the buffer where writing will start.
|
|
77
|
+
* @param length An integer specifying the number of bytes to read.
|
|
78
|
+
* @param position An integer specifying where to begin reading from in the file.
|
|
79
|
+
* If position is null, data will be read from the current file position.
|
|
80
|
+
* @returns number of bytes written
|
|
81
|
+
*/
|
|
82
|
+
readSync(buffer: ArrayBufferView, offset?: number, length?: number, position?: number): number;
|
|
83
|
+
chmodSync(mode: number): void;
|
|
84
|
+
chownSync(uid: number, gid: number): void;
|
|
85
|
+
/**
|
|
86
|
+
* Change the file timestamps of the file.
|
|
87
|
+
*/
|
|
88
|
+
utimesSync(atime: number, mtime: number): void;
|
|
89
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
90
|
+
sync(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Default implementation maps to `sync`.
|
|
93
|
+
*/
|
|
94
|
+
datasync(): Promise<void>;
|
|
95
|
+
close(): Promise<void>;
|
|
57
96
|
/**
|
|
58
97
|
* Cleans up. This will *not* sync the file data to the FS
|
|
59
98
|
*/
|
|
60
99
|
protected dispose(force?: boolean): void;
|
|
61
100
|
stat(): InodeLike;
|
|
62
|
-
truncate(length: number): void
|
|
101
|
+
truncate(length: number): Promise<void>;
|
|
63
102
|
/**
|
|
64
103
|
* Write buffer to the file.
|
|
65
104
|
* @param buffer Uint8Array containing the data to write to the file.
|
|
@@ -69,7 +108,7 @@ export declare class SyncHandle {
|
|
|
69
108
|
* If position is null, the data will be written at the current position.
|
|
70
109
|
* @returns bytes written
|
|
71
110
|
*/
|
|
72
|
-
write(buffer: Uint8Array, offset?: number, length?: number, position?: number): number
|
|
111
|
+
write(buffer: Uint8Array, offset?: number, length?: number, position?: number): Promise<number>;
|
|
73
112
|
/**
|
|
74
113
|
* Read data from the file.
|
|
75
114
|
* @param buffer The buffer that the data will be written to.
|
|
@@ -79,13 +118,13 @@ export declare class SyncHandle {
|
|
|
79
118
|
* If position is null, data will be read from the current file position.
|
|
80
119
|
* @returns number of bytes written
|
|
81
120
|
*/
|
|
82
|
-
read(buffer: ArrayBufferView, offset?: number, length?: number, position?: number): number
|
|
83
|
-
chmod(mode: number): void
|
|
84
|
-
chown(uid: number, gid: number): void
|
|
121
|
+
read(buffer: ArrayBufferView, offset?: number, length?: number, position?: number): Promise<number>;
|
|
122
|
+
chmod(mode: number): Promise<void>;
|
|
123
|
+
chown(uid: number, gid: number): Promise<void>;
|
|
85
124
|
/**
|
|
86
125
|
* Change the file timestamps of the file.
|
|
87
126
|
*/
|
|
88
|
-
utimes(atime: number, mtime: number): void
|
|
127
|
+
utimes(atime: number, mtime: number): Promise<void>;
|
|
89
128
|
/**
|
|
90
129
|
* Create a stream for reading the file.
|
|
91
130
|
*/
|
|
@@ -98,9 +137,9 @@ export declare class SyncHandle {
|
|
|
98
137
|
/**
|
|
99
138
|
* @internal @hidden
|
|
100
139
|
*/
|
|
101
|
-
export declare function toFD(file:
|
|
140
|
+
export declare function toFD(file: Handle): number;
|
|
102
141
|
/**
|
|
103
142
|
* @internal @hidden
|
|
104
143
|
*/
|
|
105
|
-
export declare function fromFD($: V_Context, fd: number):
|
|
144
|
+
export declare function fromFD($: V_Context, fd: number): Handle;
|
|
106
145
|
export declare function deleteFD($: V_Context, fd: number): boolean;
|