@gjsify/fs 0.1.13 → 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.
Files changed (67) hide show
  1. package/lib/esm/callback.js +22 -13
  2. package/lib/esm/cp.js +253 -0
  3. package/lib/esm/dir.js +160 -0
  4. package/lib/esm/fd-ops.js +189 -0
  5. package/lib/esm/file-handle.js +263 -84
  6. package/lib/esm/fs-watcher.js +88 -4
  7. package/lib/esm/glob.js +164 -0
  8. package/lib/esm/index.js +128 -2
  9. package/lib/esm/promises.js +90 -27
  10. package/lib/esm/read-stream.js +53 -43
  11. package/lib/esm/stat-watcher.js +121 -0
  12. package/lib/esm/statfs.js +57 -0
  13. package/lib/esm/sync.js +70 -52
  14. package/lib/esm/utils.js +7 -0
  15. package/lib/esm/utimes.js +62 -0
  16. package/lib/esm/write-stream.js +2 -5
  17. package/lib/types/cp.d.ts +18 -0
  18. package/lib/types/cp.spec.d.ts +2 -0
  19. package/lib/types/dir.d.ts +29 -0
  20. package/lib/types/dir.spec.d.ts +2 -0
  21. package/lib/types/fd-ops.d.ts +57 -0
  22. package/lib/types/fd-ops.spec.d.ts +2 -0
  23. package/lib/types/file-handle.d.ts +34 -4
  24. package/lib/types/fs-watcher.d.ts +9 -2
  25. package/lib/types/glob.d.ts +8 -0
  26. package/lib/types/glob.spec.d.ts +2 -0
  27. package/lib/types/index.d.ts +51 -1
  28. package/lib/types/promises.d.ts +31 -4
  29. package/lib/types/read-stream.d.ts +3 -1
  30. package/lib/types/stat-watcher.d.ts +21 -0
  31. package/lib/types/statfs.d.ts +35 -0
  32. package/lib/types/statfs.spec.d.ts +2 -0
  33. package/lib/types/sync.d.ts +4 -7
  34. package/lib/types/utils.d.ts +2 -0
  35. package/lib/types/utimes.d.ts +13 -0
  36. package/lib/types/utimes.spec.d.ts +2 -0
  37. package/lib/types/watch.spec.d.ts +2 -0
  38. package/lib/types/watchfile.spec.d.ts +2 -0
  39. package/lib/types/write-stream.d.ts +1 -2
  40. package/package.json +12 -12
  41. package/src/callback.ts +22 -13
  42. package/src/cp.spec.ts +181 -0
  43. package/src/cp.ts +328 -0
  44. package/src/dir.spec.ts +204 -0
  45. package/src/dir.ts +199 -0
  46. package/src/fd-ops.spec.ts +234 -0
  47. package/src/fd-ops.ts +251 -0
  48. package/src/file-handle.ts +264 -94
  49. package/src/fs-watcher.ts +101 -6
  50. package/src/glob.spec.ts +201 -0
  51. package/src/glob.ts +205 -0
  52. package/src/index.ts +74 -0
  53. package/src/promises.ts +94 -29
  54. package/src/read-stream.ts +49 -43
  55. package/src/stat-watcher.ts +116 -0
  56. package/src/statfs.spec.ts +67 -0
  57. package/src/statfs.ts +92 -0
  58. package/src/streams.spec.ts +58 -0
  59. package/src/sync.ts +75 -57
  60. package/src/test.mts +13 -2
  61. package/src/utils.ts +10 -0
  62. package/src/utimes.spec.ts +113 -0
  63. package/src/utimes.ts +97 -0
  64. package/src/watch.spec.ts +171 -0
  65. package/src/watchfile.spec.ts +185 -0
  66. package/src/write-stream.ts +5 -8
  67. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,62 @@
1
+ import GLib from "@girs/glib-2.0";
2
+ import Gio from "@girs/gio-2.0";
3
+ import { normalizePath } from "./utils.js";
4
+ function toGLibDateTime(t) {
5
+ const ms = t instanceof Date ? t.getTime() : typeof t === "bigint" ? Number(t) : typeof t === "string" ? Date.parse(t) : t * 1e3;
6
+ return GLib.DateTime.new_from_unix_utc(Math.floor(ms / 1e3));
7
+ }
8
+ function setTimestamps(path, atime, mtime, flags) {
9
+ const file = Gio.File.new_for_path(path);
10
+ const info = new Gio.FileInfo();
11
+ info.set_modification_date_time(toGLibDateTime(mtime));
12
+ info.set_access_date_time(toGLibDateTime(atime));
13
+ file.set_attributes_from_info(info, flags, null);
14
+ }
15
+ function utimesSync(path, atime, mtime) {
16
+ setTimestamps(normalizePath(path), atime, mtime, Gio.FileQueryInfoFlags.NONE);
17
+ }
18
+ function utimes(path, atime, mtime, callback) {
19
+ Promise.resolve().then(() => utimesSync(path, atime, mtime)).then(() => callback(null), callback);
20
+ }
21
+ async function utimesAsync(path, atime, mtime) {
22
+ utimesSync(path, atime, mtime);
23
+ }
24
+ function lutimesSync(path, atime, mtime) {
25
+ setTimestamps(normalizePath(path), atime, mtime, Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
26
+ }
27
+ function lutimes(path, atime, mtime, callback) {
28
+ Promise.resolve().then(() => lutimesSync(path, atime, mtime)).then(() => callback(null), callback);
29
+ }
30
+ async function lutimesAsync(path, atime, mtime) {
31
+ lutimesSync(path, atime, mtime);
32
+ }
33
+ function lchownSync(path, uid, gid) {
34
+ GLib.spawn_command_line_sync(`chown -h ${uid}:${gid} ${normalizePath(path)}`);
35
+ }
36
+ function lchown(path, uid, gid, callback) {
37
+ Promise.resolve().then(() => lchownSync(path, uid, gid)).then(() => callback(null), callback);
38
+ }
39
+ async function lchownAsync(path, uid, gid) {
40
+ lchownSync(path, uid, gid);
41
+ }
42
+ function lchmodSync(_path, _mode) {
43
+ }
44
+ function lchmod(_path, _mode, callback) {
45
+ callback(null);
46
+ }
47
+ async function lchmodAsync(_path, _mode) {
48
+ }
49
+ export {
50
+ lchmod,
51
+ lchmodAsync,
52
+ lchmodSync,
53
+ lchown,
54
+ lchownAsync,
55
+ lchownSync,
56
+ lutimes,
57
+ lutimesAsync,
58
+ lutimesSync,
59
+ utimes,
60
+ utimesAsync,
61
+ utimesSync
62
+ };
@@ -1,13 +1,10 @@
1
1
  import { Writable } from "node:stream";
2
- import { fileURLToPath, URL } from "node:url";
3
2
  import { open, write, close } from "./callback.js";
3
+ import { normalizePath } from "./utils.js";
4
4
  const kIsPerformingIO = /* @__PURE__ */ Symbol("kIsPerformingIO");
5
5
  const kIoDone = /* @__PURE__ */ Symbol("kIoDone");
6
6
  function toPathIfFileURL(fileURLOrPath) {
7
- if (!(fileURLOrPath instanceof URL)) {
8
- return fileURLOrPath;
9
- }
10
- return fileURLToPath(fileURLOrPath);
7
+ return normalizePath(fileURLOrPath);
11
8
  }
12
9
  class WriteStream extends Writable {
13
10
  /**
@@ -0,0 +1,18 @@
1
+ import type { PathLike } from 'node:fs';
2
+ export interface CpSyncOptions {
3
+ dereference?: boolean;
4
+ errorOnExist?: boolean;
5
+ filter?: (src: string, dest: string) => boolean;
6
+ force?: boolean;
7
+ mode?: number;
8
+ preserveTimestamps?: boolean;
9
+ recursive?: boolean;
10
+ verbatimSymlinks?: boolean;
11
+ }
12
+ export interface CpOptions extends Omit<CpSyncOptions, 'filter'> {
13
+ filter?: (src: string, dest: string) => boolean | Promise<boolean>;
14
+ }
15
+ export declare function cpSync(src: PathLike, dest: PathLike, options?: CpSyncOptions): void;
16
+ export declare function cp(src: PathLike, dest: PathLike, options: CpOptions | ((err: NodeJS.ErrnoException | null) => void), callback?: (err: NodeJS.ErrnoException | null) => void): void;
17
+ declare function cpPromises(src: PathLike, dest: PathLike, opts?: CpOptions): Promise<void>;
18
+ export { cpPromises as cpAsync };
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import Gio from '@girs/gio-2.0';
2
+ import { Dirent } from './dirent.js';
3
+ import type { PathLike } from 'node:fs';
4
+ export declare class Dir {
5
+ readonly path: string;
6
+ private _enumerator;
7
+ private _closed;
8
+ constructor(path: string, enumerator: Gio.FileEnumerator);
9
+ private _assertOpen;
10
+ readSync(): Dirent | null;
11
+ read(): Promise<Dirent | null>;
12
+ read(callback: (err: NodeJS.ErrnoException | null, dirent: Dirent | null) => void): void;
13
+ closeSync(): void;
14
+ close(): Promise<void>;
15
+ close(callback: (err: NodeJS.ErrnoException | null) => void): void;
16
+ [Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
17
+ }
18
+ export declare function opendirSync(path: PathLike): Dir;
19
+ export declare function opendir(path: PathLike, callback: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
20
+ export declare function opendir(path: PathLike, options: {
21
+ encoding?: BufferEncoding | null;
22
+ bufferSize?: number;
23
+ recursive?: boolean;
24
+ }, callback: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
25
+ export declare function opendirAsync(path: PathLike, _options?: {
26
+ encoding?: BufferEncoding | null;
27
+ bufferSize?: number;
28
+ recursive?: boolean;
29
+ }): Promise<Dir>;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,57 @@
1
+ import { Stats, BigIntStats } from './stats.js';
2
+ import type { PathLike, TimeLike, StatOptions } from 'node:fs';
3
+ export declare function fstatSync(fd: number, options?: {
4
+ bigint?: false;
5
+ }): Stats;
6
+ export declare function fstatSync(fd: number, options: {
7
+ bigint: true;
8
+ }): BigIntStats;
9
+ export declare function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
10
+ export declare function fstat(fd: number, options: StatOptions, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
11
+ export declare function fstatAsync(fd: number, options?: StatOptions): Promise<Stats | BigIntStats>;
12
+ export declare function ftruncateSync(fd: number, len?: number): void;
13
+ export declare function ftruncate(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
14
+ export declare function ftruncate(fd: number, len: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
15
+ export declare function ftruncateAsync(fd: number, len?: number): Promise<void>;
16
+ export declare function fdatasyncSync(fd: number): void;
17
+ export declare function fdatasync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
18
+ export declare function fdatasyncAsync(fd: number): Promise<void>;
19
+ export declare function fsyncSync(fd: number): void;
20
+ export declare function fsync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
21
+ export declare function fsyncAsync(fd: number): Promise<void>;
22
+ export declare function fchmodSync(fd: number, mode: number | string): void;
23
+ export declare function fchmod(fd: number, mode: number | string, callback: (err: NodeJS.ErrnoException | null) => void): void;
24
+ export declare function fchmodAsync(fd: number, mode: number | string): Promise<void>;
25
+ export declare function fchownSync(fd: number, uid: number, gid: number): void;
26
+ export declare function fchown(fd: number, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
27
+ export declare function fchownAsync(fd: number, uid: number, gid: number): Promise<void>;
28
+ export declare function futimesSync(fd: number, atime: TimeLike, mtime: TimeLike): void;
29
+ export declare function futimes(fd: number, atime: TimeLike, mtime: TimeLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
30
+ export declare function futimesAsync(fd: number, atime: TimeLike, mtime: TimeLike): Promise<void>;
31
+ export declare function closeSync(fd: number): void;
32
+ export declare function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
33
+ export declare function readSync(fd: number, buffer: NodeJS.ArrayBufferView, options: {
34
+ offset?: number;
35
+ length?: number;
36
+ position?: number | null;
37
+ }): number;
38
+ export declare function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
39
+ export declare function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number;
40
+ export declare function readvSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number | null): number;
41
+ export declare function readv(fd: number, buffers: NodeJS.ArrayBufferView[], callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
42
+ export declare function readv(fd: number, buffers: NodeJS.ArrayBufferView[], position: number | null, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
43
+ export declare function readvAsync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number | null): Promise<{
44
+ bytesRead: number;
45
+ buffers: NodeJS.ArrayBufferView<ArrayBufferLike>[];
46
+ }>;
47
+ export declare function writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number | null): number;
48
+ export declare function writev(fd: number, buffers: NodeJS.ArrayBufferView[], callback: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
49
+ export declare function writev(fd: number, buffers: NodeJS.ArrayBufferView[], position: number | null, callback: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void): void;
50
+ export declare function writevAsync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number | null): Promise<{
51
+ bytesWritten: number;
52
+ buffers: NodeJS.ArrayBufferView<ArrayBufferLike>[];
53
+ }>;
54
+ export declare function exists(path: PathLike, callback: (exists: boolean) => void): void;
55
+ export declare function openAsBlob(path: PathLike, options?: {
56
+ type?: string;
57
+ }): Promise<Blob>;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -1,28 +1,54 @@
1
1
  import { ReadStream } from "./read-stream.js";
2
2
  import { WriteStream } from "./write-stream.js";
3
- import { Stats } from "./stats.js";
3
+ import { Stats, BigIntStats } from "./stats.js";
4
4
  import type { ReadableStream } from "node:stream/web";
5
5
  import { Buffer } from "node:buffer";
6
6
  import type { Abortable } from 'node:events';
7
7
  import type { FlagAndOpenMode, FileReadResult, FileReadOptions, OpenFlags } from './types/index.js';
8
8
  import type { FileHandle as IFileHandle, CreateReadStreamOptions, CreateWriteStreamOptions } from 'node:fs/promises';
9
- import type { ObjectEncodingOptions, Mode, OpenMode, PathLike, StatOptions, BigIntStats, WriteVResult, ReadVResult, ReadPosition } from 'node:fs';
9
+ import type { ObjectEncodingOptions, Mode, OpenMode, PathLike, StatOptions, WriteVResult, ReadVResult, ReadPosition } from 'node:fs';
10
10
  import type { Interface as ReadlineInterface } from 'node:readline';
11
11
  export declare class FileHandle implements IFileHandle {
12
12
  readonly options: {
13
13
  path: PathLike;
14
- flags?: OpenFlags;
14
+ flags?: OpenFlags | number;
15
15
  mode?: Mode;
16
16
  };
17
17
  /** Not part of the default implementation, used internal by gjsify */
18
18
  private _file;
19
+ /**
20
+ * Lazily-opened Gio streams for positional read() / write() so each call does
21
+ * not re-load the entire file via Gio.File.load_contents(). The IOStream is
22
+ * used when the handle was opened with write capability (r+, w, w+, a, a+) —
23
+ * it shares seek state between input and output so writes are visible to
24
+ * subsequent reads without a flush. For read-only handles we only open a
25
+ * FileInputStream; trying to open_readwrite on a read-only file can fall
26
+ * back to create_readwrite(REPLACE_DESTINATION) which would truncate it.
27
+ */
28
+ private _ioStream;
29
+ private _readStream;
30
+ private readonly _gFile;
31
+ private readonly _ioMode;
32
+ private _ioLock;
19
33
  /** Not part of the default implementation, used internal by gjsify */
20
34
  private static instances;
21
35
  constructor(options: {
22
36
  path: PathLike;
23
- flags?: OpenFlags;
37
+ flags?: OpenFlags | number;
24
38
  mode?: Mode;
25
39
  });
40
+ /**
41
+ * Lazy-open the read-capable stream and return both the input stream and
42
+ * its seekable view. Both FileInputStream (read-only handle) and
43
+ * FileIOStream (read/write handle) implement Gio.Seekable, but we return
44
+ * both to avoid callers needing to know which concrete type they got.
45
+ */
46
+ private _getReadStream;
47
+ /** Lazy-open the write-capable stream (IOStream) for this handle. Only valid
48
+ * when the handle was opened with a write-capable mode. */
49
+ private _getWriteStream;
50
+ /** Serialize an async operation on the shared FileIOStream. */
51
+ private _serialize;
26
52
  /**
27
53
  * The numeric file descriptor managed by the {FileHandle} object.
28
54
  * @since v10.0.0
@@ -345,6 +371,10 @@ export declare class FileHandle implements IFileHandle {
345
371
  * @return Fulfills upon success an object containing two properties:
346
372
  */
347
373
  readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(buffers: TBuffers, position?: number): Promise<ReadVResult<TBuffers>>;
374
+ /** @internal */ _flushSync(): void;
375
+ /** @internal */ _closeSync(): void;
376
+ /** @internal */ _readSync(buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
377
+ /** @internal */ _writeSync(data: Uint8Array, position: number | null): number;
348
378
  /**
349
379
  * Closes the file handle after waiting for any pending operation on the handle to
350
380
  * complete.
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'node:events';
2
- import type { FSWatcher as IFSWatcher } from 'node:fs';
2
+ import type { FSWatcher as IFSWatcher, PathLike, WatchOptions } from 'node:fs';
3
3
  export declare class FSWatcher extends EventEmitter implements IFSWatcher {
4
- constructor(filename: string, options: any, listener: any);
4
+ constructor(filename: PathLike, options: any, listener: any);
5
5
  close(): void;
6
6
  /**
7
7
  * When called, requests that the Node.js event loop not exit so long as the
@@ -15,3 +15,10 @@ export declare class FSWatcher extends EventEmitter implements IFSWatcher {
15
15
  unref(): this;
16
16
  }
17
17
  export default FSWatcher;
18
+ type WatchEvent = {
19
+ eventType: string;
20
+ filename: string | null;
21
+ };
22
+ export declare function watchAsync(filename: PathLike, options?: WatchOptions & {
23
+ signal?: AbortSignal;
24
+ }): AsyncIterableIterator<WatchEvent>;
@@ -0,0 +1,8 @@
1
+ export interface GlobOptions {
2
+ cwd?: string | URL;
3
+ exclude?: string | string[] | ((path: string) => boolean);
4
+ withFileTypes?: boolean;
5
+ }
6
+ export declare function globSync(pattern: string | string[], options?: GlobOptions): string[];
7
+ export declare function glob(pattern: string | string[], options: GlobOptions | ((err: NodeJS.ErrnoException | null, matches: string[]) => void), callback?: (err: NodeJS.ErrnoException | null, matches: string[]) => void): void;
8
+ export declare function globAsync(pattern: string | string[], options?: GlobOptions): AsyncIterableIterator<string>;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -4,8 +4,15 @@ import FSWatcher from './fs-watcher.js';
4
4
  import { createReadStream, ReadStream } from './read-stream.js';
5
5
  import { createWriteStream, WriteStream } from './write-stream.js';
6
6
  import * as promises from './promises.js';
7
+ import { cpSync, cp } from './cp.js';
8
+ import { Dir, opendir, opendirSync } from './dir.js';
9
+ import { glob, globSync } from './glob.js';
10
+ import { StatWatcher, watchFile, unwatchFile } from './stat-watcher.js';
11
+ import { statfsSync, statfs } from './statfs.js';
7
12
  import { Stats, BigIntStats } from './stats.js';
8
13
  import { Dirent } from './dirent.js';
14
+ import { utimesSync, utimes, lutimesSync, lutimes, lchownSync, lchown, lchmodSync, lchmod } from './utimes.js';
15
+ import { fstatSync, fstat, ftruncateSync, ftruncate, fdatasyncSync, fdatasync, fsyncSync, fsync, fchmodSync, fchmod, fchownSync, fchown, futimesSync, futimes, closeSync, readSync, writeSync, readvSync, readv, writevSync, writev, exists, openAsBlob } from './fd-ops.js';
9
16
  export declare const constants: {
10
17
  F_OK: number;
11
18
  R_OK: number;
@@ -46,12 +53,14 @@ export declare const constants: {
46
53
  S_IWOTH: number;
47
54
  S_IXOTH: number;
48
55
  };
49
- export { FSWatcher, Stats, BigIntStats, Dirent, existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, rmdirSync, unlinkSync, mkdtempSync, rmSync, statSync, openSync, realpathSync, symlinkSync, lstatSync, renameSync, copyFileSync, accessSync, appendFileSync, readlinkSync, linkSync, truncateSync, chmodSync, chownSync, watch, createReadStream, ReadStream, createWriteStream, WriteStream, promises, open, close, read, write, rm, realpath, readdir, symlink, lstat, stat, rename, copyFile, access, appendFile, readlink, truncate, chmod, chown, mkdir, rmdir, readFile, writeFile, unlink, link, };
56
+ export { FSWatcher, StatWatcher, Stats, BigIntStats, Dirent, Dir, existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync, rmdirSync, unlinkSync, mkdtempSync, rmSync, statSync, openSync, realpathSync, symlinkSync, lstatSync, renameSync, copyFileSync, accessSync, appendFileSync, readlinkSync, linkSync, truncateSync, chmodSync, chownSync, cpSync, opendirSync, globSync, glob, watch, watchFile, unwatchFile, statfsSync, statfs, utimesSync, utimes, lutimesSync, lutimes, lchownSync, lchown, lchmodSync, lchmod, fstatSync, fstat, ftruncateSync, ftruncate, fdatasyncSync, fdatasync, fsyncSync, fsync, fchmodSync, fchmod, fchownSync, fchown, futimesSync, futimes, closeSync, readSync, writeSync, readvSync, readv, writevSync, writev, exists, openAsBlob, createReadStream, ReadStream, createWriteStream, WriteStream, promises, open, close, read, write, rm, realpath, readdir, symlink, lstat, stat, rename, copyFile, cp, access, appendFile, readlink, truncate, chmod, chown, mkdir, rmdir, readFile, writeFile, unlink, link, opendir, };
50
57
  declare const _default: {
51
58
  FSWatcher: typeof FSWatcher;
59
+ StatWatcher: typeof StatWatcher;
52
60
  Stats: typeof Stats;
53
61
  BigIntStats: typeof BigIntStats;
54
62
  Dirent: typeof Dirent;
63
+ Dir: typeof promises.Dir;
55
64
  constants: {
56
65
  F_OK: number;
57
66
  R_OK: number;
@@ -115,7 +124,46 @@ declare const _default: {
115
124
  truncateSync: typeof truncateSync;
116
125
  chmodSync: typeof chmodSync;
117
126
  chownSync: typeof chownSync;
127
+ cpSync: typeof cpSync;
128
+ opendirSync: typeof opendirSync;
129
+ globSync: typeof globSync;
130
+ glob: typeof glob;
118
131
  watch: typeof watch;
132
+ watchFile: typeof watchFile;
133
+ unwatchFile: typeof unwatchFile;
134
+ statfsSync: typeof statfsSync;
135
+ statfs: typeof statfs;
136
+ utimesSync: typeof utimesSync;
137
+ utimes: typeof utimes;
138
+ lutimesSync: typeof lutimesSync;
139
+ lutimes: typeof lutimes;
140
+ lchownSync: typeof lchownSync;
141
+ lchown: typeof lchown;
142
+ lchmodSync: typeof lchmodSync;
143
+ lchmod: typeof lchmod;
144
+ fstatSync: typeof fstatSync;
145
+ fstat: typeof fstat;
146
+ ftruncateSync: typeof ftruncateSync;
147
+ ftruncate: typeof ftruncate;
148
+ fdatasyncSync: typeof fdatasyncSync;
149
+ fdatasync: typeof fdatasync;
150
+ fsyncSync: typeof fsyncSync;
151
+ fsync: typeof fsync;
152
+ fchmodSync: typeof fchmodSync;
153
+ fchmod: typeof fchmod;
154
+ fchownSync: typeof fchownSync;
155
+ fchown: typeof fchown;
156
+ futimesSync: typeof futimesSync;
157
+ futimes: typeof futimes;
158
+ closeSync: typeof closeSync;
159
+ readSync: typeof readSync;
160
+ writeSync: typeof writeSync;
161
+ readvSync: typeof readvSync;
162
+ readv: typeof readv;
163
+ writevSync: typeof writevSync;
164
+ writev: typeof writev;
165
+ exists: typeof exists;
166
+ openAsBlob: typeof promises.openAsBlob;
119
167
  createReadStream: typeof createReadStream;
120
168
  ReadStream: typeof ReadStream;
121
169
  createWriteStream: typeof createWriteStream;
@@ -133,6 +181,7 @@ declare const _default: {
133
181
  stat: typeof stat;
134
182
  rename: typeof rename;
135
183
  copyFile: typeof copyFile;
184
+ cp: typeof cp;
136
185
  access: typeof access;
137
186
  appendFile: typeof appendFile;
138
187
  readlink: typeof readlink;
@@ -145,5 +194,6 @@ declare const _default: {
145
194
  writeFile: typeof writeFile;
146
195
  unlink: typeof unlink;
147
196
  link: typeof link;
197
+ opendir: typeof opendir;
148
198
  };
149
199
  export default _default;
@@ -1,3 +1,10 @@
1
+ import { cpAsync } from './cp.js';
2
+ import { opendirAsync, Dir } from './dir.js';
3
+ import { globAsync } from './glob.js';
4
+ import { watchAsync } from './fs-watcher.js';
5
+ import { statfsAsync } from './statfs.js';
6
+ import { utimesAsync, lutimesAsync, lchownAsync, lchmodAsync } from './utimes.js';
7
+ import { fstatAsync, ftruncateAsync, fdatasyncAsync, fsyncAsync, fchmodAsync, fchownAsync, futimesAsync, readvAsync, writevAsync, openAsBlob } from './fd-ops.js';
1
8
  import { FileHandle } from './file-handle.js';
2
9
  import { Dirent } from './dirent.js';
3
10
  import { Stats, BigIntStats } from './stats.js';
@@ -73,7 +80,7 @@ declare function mkdtemp(prefix: string, options: BufferEncodingOption): Promise
73
80
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
74
81
  */
75
82
  declare function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
76
- declare function writeFile(path: string, data: string | Uint8Array | unknown): Promise<void>;
83
+ declare function writeFile(path: PathLike, data: string | Uint8Array | unknown): Promise<void>;
77
84
  /**
78
85
  * Removes the directory identified by `path`.
79
86
  *
@@ -85,8 +92,8 @@ declare function writeFile(path: string, data: string | Uint8Array | unknown): P
85
92
  * @return Fulfills with `undefined` upon success.
86
93
  */
87
94
  declare function rmdir(path: PathLike, _options?: RmDirOptions): Promise<void>;
88
- declare function unlink(path: string): Promise<void>;
89
- declare function open(path: PathLike, flags?: OpenFlags, mode?: Mode): Promise<FileHandle>;
95
+ declare function unlink(path: PathLike): Promise<void>;
96
+ declare function open(path: PathLike, flags?: OpenFlags | number, mode?: Mode): Promise<FileHandle>;
90
97
  declare function write<TBuffer extends Uint8Array>(fd: number, buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{
91
98
  bytesWritten: number;
92
99
  buffer: TBuffer;
@@ -129,7 +136,8 @@ declare function truncate(path: PathLike, len?: number): Promise<void>;
129
136
  declare function chmod(path: PathLike, mode: number | string): Promise<void>;
130
137
  declare function chown(path: PathLike, uid: number, gid: number): Promise<void>;
131
138
  declare function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
132
- export { readFile, mkdir, mkdtemp, realpath, readdir, writeFile, rmdir, unlink, open, write, rm, lstat, symlink, stat, rename, copyFile, access, appendFile, readlink, truncate, chmod, chown, link, };
139
+ export type { Dir };
140
+ export { readFile, mkdir, mkdtemp, realpath, readdir, writeFile, rmdir, unlink, open, write, rm, lstat, symlink, stat, rename, copyFile, access, appendFile, readlink, truncate, chmod, chown, link, cpAsync as cp, opendirAsync as opendir, globAsync as glob, watchAsync as watch, statfsAsync as statfs, utimesAsync as utimes, lutimesAsync as lutimes, lchownAsync as lchown, lchmodAsync as lchmod, fstatAsync as fstat, ftruncateAsync as ftruncate, fdatasyncAsync as fdatasync, fsyncAsync as fsync, fchmodAsync as fchmod, fchownAsync as fchown, futimesAsync as futimes, readvAsync as readv, writevAsync as writev, openAsBlob, };
133
141
  declare const _default: {
134
142
  readFile: typeof readFile;
135
143
  mkdir: typeof mkdir;
@@ -154,5 +162,24 @@ declare const _default: {
154
162
  chmod: typeof chmod;
155
163
  chown: typeof chown;
156
164
  link: typeof link;
165
+ cp: typeof cpAsync;
166
+ opendir: typeof opendirAsync;
167
+ glob: typeof globAsync;
168
+ watch: typeof watchAsync;
169
+ statfs: typeof statfsAsync;
170
+ utimes: typeof utimesAsync;
171
+ lutimes: typeof lutimesAsync;
172
+ lchown: typeof lchownAsync;
173
+ lchmod: typeof lchmodAsync;
174
+ fstat: typeof fstatAsync;
175
+ ftruncate: typeof ftruncateAsync;
176
+ fdatasync: typeof fdatasyncAsync;
177
+ fsync: typeof fsyncAsync;
178
+ fchmod: typeof fchmodAsync;
179
+ fchown: typeof fchownAsync;
180
+ futimes: typeof futimesAsync;
181
+ readv: typeof readvAsync;
182
+ writev: typeof writevAsync;
183
+ openAsBlob: typeof openAsBlob;
157
184
  };
158
185
  export default _default;
@@ -1,6 +1,5 @@
1
1
  import { Buffer } from "node:buffer";
2
2
  import { Readable } from "node:stream";
3
- import { URL } from "node:url";
4
3
  import type { CreateReadStreamOptions } from 'node:fs/promises';
5
4
  import type { PathLike, ReadStream as IReadStream } from 'node:fs';
6
5
  export declare class ReadStream extends Readable implements IReadStream {
@@ -10,12 +9,15 @@ export declare class ReadStream extends Readable implements IReadStream {
10
9
  fd: number | null;
11
10
  private _gioFile;
12
11
  private _inputStream;
12
+ private _cancellable;
13
13
  private _start;
14
14
  private _end;
15
15
  private _pos;
16
16
  close(callback?: (err?: NodeJS.ErrnoException | null) => void): void;
17
17
  constructor(path: PathLike, opts?: CreateReadStreamOptions);
18
+ _construct(callback: (err?: Error | null) => void): void;
18
19
  _read(size: number): void;
20
+ private _doRead;
19
21
  _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
20
22
  }
21
23
  export declare function createReadStream(path: string | URL, options?: CreateReadStreamOptions): ReadStream;
@@ -0,0 +1,21 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import type { PathLike, Stats } from 'node:fs';
3
+ export declare class StatWatcher extends EventEmitter {
4
+ private _path;
5
+ private _interval;
6
+ private _timerId;
7
+ private _prev;
8
+ private _changeCount;
9
+ constructor(path: string, interval: number);
10
+ start(): void;
11
+ stop(): void;
12
+ addChangeListener(listener: (curr: Stats, prev: Stats) => void): void;
13
+ removeChangeListener(listener: (curr: Stats, prev: Stats) => void): void;
14
+ removeAllChangeListeners(): void;
15
+ get changeListenerCount(): number;
16
+ }
17
+ export declare function watchFile(filename: PathLike, options: {
18
+ persistent?: boolean;
19
+ interval?: number;
20
+ } | ((curr: Stats, prev: Stats) => void), listener?: (curr: Stats, prev: Stats) => void): StatWatcher;
21
+ export declare function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
@@ -0,0 +1,35 @@
1
+ import type { PathLike } from 'node:fs';
2
+ export interface StatFsResult {
3
+ type: number;
4
+ bsize: number;
5
+ blocks: number;
6
+ bfree: number;
7
+ bavail: number;
8
+ files: number;
9
+ ffree: number;
10
+ }
11
+ export interface BigIntStatFsResult {
12
+ type: bigint;
13
+ bsize: bigint;
14
+ blocks: bigint;
15
+ bfree: bigint;
16
+ bavail: bigint;
17
+ files: bigint;
18
+ ffree: bigint;
19
+ }
20
+ export declare function statfsSync(path: PathLike, options?: {
21
+ bigint?: false;
22
+ }): StatFsResult;
23
+ export declare function statfsSync(path: PathLike, options: {
24
+ bigint: true;
25
+ }): BigIntStatFsResult;
26
+ export declare function statfs(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: StatFsResult) => void): void;
27
+ export declare function statfs(path: PathLike, options: {
28
+ bigint?: false;
29
+ }, callback: (err: NodeJS.ErrnoException | null, stats: StatFsResult) => void): void;
30
+ export declare function statfs(path: PathLike, options: {
31
+ bigint: true;
32
+ }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStatFsResult) => void): void;
33
+ export declare function statfsAsync(path: PathLike, options?: {
34
+ bigint?: boolean;
35
+ }): Promise<StatFsResult | BigIntStatFsResult>;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -16,10 +16,7 @@ export declare function readdirSync(path: PathLike, options?: {
16
16
  }): string[] | Dirent[];
17
17
  export declare function realpathSync(path: PathLike): string;
18
18
  export declare function symlinkSync(target: PathLike, path: PathLike, _type?: 'file' | 'dir' | 'junction'): void;
19
- export declare function readFileSync(path: string, options?: {
20
- encoding: any;
21
- flag: string;
22
- }): string | Buffer<ArrayBuffer>;
19
+ export declare function readFileSync(path: PathLike, options?: any): string | Buffer<ArrayBuffer>;
23
20
  /**
24
21
  * Synchronously creates a directory. Returns `undefined`, or if `recursive` is`true`, the first directory path created.
25
22
  * This is the synchronous version of {@link mkdir}.
@@ -57,7 +54,7 @@ export declare function mkdirSync(path: PathLike, options?: Mode | MakeDirectory
57
54
  */
58
55
  export declare function rmdirSync(path: PathLike, _options?: RmDirOptions): void;
59
56
  export declare function unlinkSync(path: PathLike): void;
60
- export declare function writeFileSync(path: string, data: string | Uint8Array): void;
57
+ export declare function writeFileSync(path: PathLike, data: string | Uint8Array): void;
61
58
  export declare function renameSync(oldPath: PathLike, newPath: PathLike): void;
62
59
  export declare function copyFileSync(src: PathLike, dest: PathLike, mode?: number): void;
63
60
  export declare function accessSync(path: PathLike, mode?: number): void;
@@ -73,12 +70,12 @@ export declare function linkSync(existingPath: PathLike, newPath: PathLike): voi
73
70
  export declare function truncateSync(path: PathLike, len?: number): void;
74
71
  export declare function chmodSync(path: PathLike, mode: Mode): void;
75
72
  export declare function chownSync(path: PathLike, uid: number, gid: number): void;
76
- export declare function watch(filename: string, options: {
73
+ export declare function watch(filename: PathLike, options: {
77
74
  persistent?: boolean;
78
75
  recursive?: boolean;
79
76
  encoding?: string;
80
77
  } | undefined, listener: ((eventType: string, filename: string | null) => void) | undefined): FSWatcher;
81
- export declare function openSync(path: PathLike, flags?: OpenFlags, mode?: Mode): FileHandle;
78
+ export declare function openSync(path: PathLike, flags?: OpenFlags | number, mode?: Mode): FileHandle;
82
79
  /**
83
80
  * Returns the created directory path.
84
81
  *
@@ -1,2 +1,4 @@
1
+ import type { PathLike } from 'node:fs';
2
+ export declare function normalizePath(path: PathLike): string;
1
3
  export declare function randomName(): string;
2
4
  export declare function tempDirPath(prefix: string): string;
@@ -0,0 +1,13 @@
1
+ import type { PathLike, TimeLike } from 'node:fs';
2
+ export declare function utimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
3
+ export declare function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
4
+ export declare function utimesAsync(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
5
+ export declare function lutimesSync(path: PathLike, atime: TimeLike, mtime: TimeLike): void;
6
+ export declare function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
7
+ export declare function lutimesAsync(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
8
+ export declare function lchownSync(path: PathLike, uid: number, gid: number): void;
9
+ export declare function lchown(path: PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
10
+ export declare function lchownAsync(path: PathLike, uid: number, gid: number): Promise<void>;
11
+ export declare function lchmodSync(_path: PathLike, _mode: number): void;
12
+ export declare function lchmod(_path: PathLike, _mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
13
+ export declare function lchmodAsync(_path: PathLike, _mode: number): Promise<void>;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -1,10 +1,9 @@
1
1
  import { Writable } from "node:stream";
2
- import { URL } from "node:url";
3
2
  import type { OpenFlags } from './types/index.js';
4
3
  import type { PathLike, WriteStream as IWriteStream } from 'node:fs';
5
4
  import type { CreateWriteStreamOptions } from 'node:fs/promises';
6
5
  declare const kIsPerformingIO: unique symbol;
7
- export declare function toPathIfFileURL(fileURLOrPath: string | Buffer | URL): string | Buffer;
6
+ export declare function toPathIfFileURL(fileURLOrPath: string | Buffer | URL): string;
8
7
  export declare class WriteStream extends Writable implements IWriteStream {
9
8
  /**
10
9
  * Closes `writeStream`. Optionally accepts a