import type { FileInfo } from "../adapters/base.js"; import { isNotFoundError } from "./not-found-error.js"; export { isNotFoundError }; /** Stable native identity for one filesystem object. */ export interface PathIdentity { readonly device: string; readonly inode: string; } /** * Runtime-neutral filesystem contract. * * Operations reject filesystem failures. Callers that intentionally tolerate a * missing path can classify the rejection with {@link isNotFoundError}. */ export interface FileSystem { readTextFile(path: string): Promise; readFile(path: string): Promise; /** Exact bounded binary read; implementations must reject oversized files before materializing them. */ readFileBytesWithinLimit?(path: string, byteLimit: number): Promise; readFileSnapshotWithinLimit?(path: string, containmentRoot: string, byteLimit: number): Promise; writeTextFile(path: string, data: string): Promise; writeFile(path: string, data: Uint8Array): Promise; createFileBytesExclusive?(path: string, data: Uint8Array): Promise; /** Atomically replace a path when same-filesystem rename is supported. */ rename?(from: string, to: string): Promise; exists(path: string): Promise; stat(path: string): Promise; lstat?(path: string): Promise; mkdir(path: string, options?: { recursive?: boolean; }): Promise; readDir(path: string): AsyncIterable<{ name: string; isFile: boolean; isDirectory: boolean; isSymlink?: boolean; }>; /** Remove a path, rejecting when it does not exist. */ remove(path: string, options?: { recursive?: boolean; }): Promise; /** Atomically create a unique directory beneath the operating-system temp root. */ makeTempDir(options?: { prefix?: string; }): Promise; /** Change permissions, rejecting operational failures. */ chmod(path: string, mode: number): Promise; } /** Create the runtime-native filesystem implementation. */ export declare function createFileSystem(): FileSystem; /** Read a file as text. */ export declare function readTextFile(path: string): Promise; /** Read a file as bytes. */ export declare function readFile(path: string): Promise; /** Write text to a file. */ export declare function writeTextFile(path: string, data: string): Promise; /** Write bytes to a file. */ export declare function writeFile(path: string, data: Uint8Array): Promise; /** Return false for a missing path and propagate every other filesystem error. */ export declare function exists(path: string): Promise; /** Read file metadata. */ export declare function stat(path: string): Promise; /** Read file metadata without following a terminal symbolic link. */ export declare function lstat(path: string): Promise; /** * Read a path's native device/inode identity without following a terminal * symbolic link. Returns undefined only when the runtime cannot expose a * stable identity for the backing filesystem. */ export declare function getPathIdentity(path: string): Promise; /** Create a directory. */ export declare function mkdir(path: string, options?: { recursive?: boolean; }): Promise; /** Remove a file or directory, rejecting when the path does not exist. */ export declare function remove(path: string, options?: { recursive?: boolean; }): Promise; /** Read directory entries. */ export declare function readDir(path: string): AsyncIterable<{ name: string; isFile: boolean; isDirectory: boolean; isSymlink?: boolean; }>; /** Atomically create a unique directory beneath the operating-system temp root. */ export declare function makeTempDir(options?: { prefix?: string; }): Promise; /** Change file permissions, rejecting operational failures. */ export declare function chmod(path: string, mode: number): Promise; export declare function symlink(target: string, path: string): Promise; /** * Resolve a path to its canonical absolute form, following symlinks. * Throws if the path does not exist. Useful for containment checks where a * symlink could otherwise escape an intended directory. */ export declare function realPath(path: string): Promise; /** Error shape for is already exists. */ export declare function isAlreadyExistsError(error: unknown): boolean; //# sourceMappingURL=fs.d.ts.map