@zenfs/core
Version:
A filesystem, anywhere
79 lines (78 loc) • 2.92 kB
TypeScript
import type { Dir as _Dir, Dirent as _Dirent } from 'node:fs';
import type { V_Context } from '../context.js';
import type { Callback } from '../utils.js';
import { Buffer } from 'buffer';
import { DirType, type Dirent as VFSDirent } from '../vfs/dir.js';
export declare class Dirent<Name extends string | Buffer = string> implements _Dirent<Name> {
ino: number;
type: DirType;
protected _name: string;
get name(): Name;
/**
* @internal @protected
*/
_encoding?: BufferEncoding | 'buffer' | null;
/**
* @internal @protected
*/
_parentPath: string;
get parentPath(): string;
/**
* @deprecated Removed in Node v24, use `parentPath` instead.
*/
get path(): string;
/**
* @internal
*/
static from(vfs: VFSDirent, encoding?: BufferEncoding | 'buffer' | null): Dirent<string>;
isFile(): boolean;
isDirectory(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
}
/**
* A class representing a directory stream.
*/
export declare class Dir implements _Dir, AsyncIterator<Dirent> {
readonly path: string;
protected readonly context: V_Context;
protected closed: boolean;
protected checkClosed(): void;
protected _entries?: Dirent[];
constructor(path: string, context: V_Context);
/**
* Asynchronously close the directory's underlying resource handle.
* Subsequent reads will result in errors.
*/
close(): Promise<void>;
close(cb: Callback): void;
/**
* Synchronously close the directory's underlying resource handle.
* Subsequent reads will result in errors.
*/
closeSync(): void;
protected _read(): Promise<Dirent | null>;
/**
* Asynchronously read the next directory entry via `readdir(3)` as an `Dirent`.
* 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.
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
*/
read(): Promise<Dirent | null>;
read(cb: Callback<[Dirent | null]>): void;
/**
* Synchronously read the next directory entry via `readdir(3)` as a `Dirent`.
* If there are no more directory entries to read, null will be returned.
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
*/
readSync(): Dirent | null;
next(): Promise<IteratorResult<Dirent>>;
/**
* Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
*/
[Symbol.asyncIterator](): this;
[Symbol.dispose](): void;
[Symbol.asyncDispose](): Promise<void>;
}