import { type FlushKind } from './flush.ts'; /** * One buffered whole-file handle. * * The shape every encoder used to hand-roll: open snapshots the file * into a growable buffer, byte-level calls touch only that buffer, and * close asks `flushPlan` whether the mount is owed a tail or the whole * file. `lowWrite` and `dirty` exist purely to answer that closing * question. Mirrors Python's `FileHandle`. */ export declare class FileHandle { readonly path: string; buf: Uint8Array; pos: number; readonly writable: boolean; readonly baseLen: number; lowWrite: number; dirty: boolean; constructor(path: string, buf: Uint8Array, writable?: boolean); /** * A handle over `data`, positioned by the open mode. * * Args: * path: guest-absolute virtual path. * data: the file's content at open (empty when the open created * or truncated it). * mode: whether writes are accepted, and whether the position * starts at the end. */ static opened(path: string, data: Uint8Array, mode: { writable: boolean; append: boolean; }): FileHandle; /** * Read from the position, advancing it by what was read. * * Args: * size: byte budget; null or negative reads to the end. A * position past the end reads empty and stays. */ read(size: number | null): Uint8Array; /** Read at an explicit offset without moving the position. */ pread(offset: number, size: number): Uint8Array; /** * Splice bytes in at an offset without moving the position. * * Grows the buffer through a zero fill when the offset lies past the * end, and keeps the two facts the closing flush plan reads: the * lowest offset written and that anything was written at all. */ pwrite(offset: number, data: Uint8Array): void; /** Write at the position, advancing it past the payload. */ write(data: Uint8Array): void; /** * Move the position, POSIX whence numbering (0 start, 1 position, * 2 end). Answers the new position, or null when the whence is * unknown or the target would be negative (the position is then * untouched). */ seek(offset: number, whence: number): number | null; /** * Resize the buffer, zero-filling growth. Either direction rewrites * what the file already held (a shrink drops bytes, a zero fill * fabricates them), which no tail can express, so the close ships * the whole buffer. */ truncate(size: number): void; /** True when the position sits at or past the end. */ get eof(): boolean; /** What this handle owes the mount at close. */ flushPlan(): [FlushKind, Uint8Array]; } /** * Apply buffered (offset, payload) writes over a base file. * * The batch form of the pwrite splice, for the kernel adapters: FUSE * buffers each write as an (offset, payload) pair on its handle and * owes the mount one merged body at flush, which is exactly a sequence * of pwrites over what the file held. * * Args: * base: the file's content before this handle's writes. * writes: the buffered writes, in arrival order. */ export declare function mergeWrites(base: Uint8Array, writes: [number, Uint8Array][]): Uint8Array; //# sourceMappingURL=file_handle.d.ts.map