import { IOResult } from '../../../io/types.ts'; import type { MountView, StatPath } from '../../../ops/types.ts'; import { FileStat, PathSpec } from '../../../types.ts'; type Stat = (p: PathSpec) => Promise; /** * Stat one operand the way a reporting command needs it. * * Two things no single backend stat can get right, both about paths that * are namespace structure rather than backend state: * * A path that only exists because mounts sit under it (`/repos` when * `/repos/alpha` is mounted) has no backend to answer for it, so the * backend stat throws and the operand reads as absent. `statPath` routes * through the dispatcher, which answers such a path from the mount table, * so it is asked second and only on a miss. Its row is already named from * the path. * * A mount root has a backend, but that backend names its own root rather * than the path: ram answers `/`, and disk answers the host directory's * basename, which leaks the path behind the mount. So the row is renamed * here, the way `ls` renames a child-mount row for the same reason. * * Mirrors Python `mirage.commands.builtin.utils.operands.operand_stat`. */ export declare function operandStat(path: PathSpec, stat: Stat, statPath?: StatPath | null, mounts?: MountView | null): Promise; /** * Wrap a walker's readdir so a mount parent lists as empty, not absent. * * A directory that exists only because mounts sit under it has no backend * to list it, so the readdir throws and a recursive command reports the * operand missing even as the fan-out searches the mounts below it and * prints hits. Empty is the honest answer for the primary backend: the * directory is there, and it owns nothing in it. * * Empty rather than the mount names, because the fan-out already runs the * command once per descendant mount and concatenates. Listing them here * would search each one twice. * * The visible descendants, not every descendant. Answering at all tells * the session the directory is there, and a directory that exists only * because of a mount it may not be told about is a directory it may not be * told about either: a hidden mount under an otherwise absent parent has * to keep reading as absence, the same way the mount itself does. * * Only for an absence, which is why the catch is `isMissError` and not the * walk's own wider set: a directory the backend refused with EACCES or * ENOTSUP is there and holds data this run cannot read, and calling it * empty would let `grep -r` print the descendant mount's hits and exit 0 * while silently omitting it. A refusal that is not absence keeps * propagating and gets reported. */ export declare function mountParentReaddir(readdir: (p: string) => Promise, mounts?: MountView | null): (p: string) => Promise; /** * Wrap a walker's stat so a mount parent reports as a directory. * * The twin of `mountParentReaddir`, and the reason a recursive search over * `/repos` reported it missing while still printing hits from * `/repos/alpha`: the operand was statted before it was walked, the * primary backend has no such path, and the miss was reported as absence. * * The mount table decides, not the dispatcher. A dispatched stat would * answer for paths inside the descendant mounts too, which is exactly what * the primary run must not see: the fan-out searches each of them * separately, so claiming their entries here would search them twice. * * Visible descendants only, because a row is a disclosure: the parent of a * mount this session may not be told about stays absent, which is what * every other verb already answers there. * * An absence only, the same as its readdir twin: a backend that refused the * path rather than not having it is reporting something the run must not * paper over with a synthesized row. */ export declare function mountParentStat(stat: (p: string) => Promise, mounts?: MountView | null): (p: string) => Promise; export declare function hasUnresolvedGlob(paths: PathSpec[]): boolean; export declare function resolveScript(name: string, cwd: string): PathSpec; export declare function splitReadable(paths: readonly PathSpec[], stat: Stat, cmdName: string): Promise<[PathSpec[], string]>; export interface ReadOperand { path: PathSpec; data: Uint8Array; } export declare function readOperandsCoded(paths: readonly PathSpec[], stream: (p: PathSpec) => AsyncIterable, cmdName: string): Promise<[ReadOperand[], string, number]>; export declare function readOperands(paths: readonly PathSpec[], stream: (p: PathSpec) => AsyncIterable, cmdName: string): Promise<[ReadOperand[], string]>; export declare function operandsIo(err: string, init?: { cache?: string[]; exitCode?: number; }): IOResult; export declare function singleChunk(data: Uint8Array): AsyncIterable; export declare function defaultPaths(paths: PathSpec[], cwd: string, mountPrefix?: string): PathSpec[]; export {}; //# sourceMappingURL=operands.d.ts.map