import { IOResult, type ByteSource } from '../../../io/types.ts';
import { PathSpec, type StatFn } from '../../../types.ts';
import type { LinkResolver } from '../utils/links.ts';
/**
 * The compression suffix gzip reads off `name`, as spelled there.
 *
 * As gzip 1.13 reads it: the -S suffix and the ones gzip always knows,
 * compared without regard to ASCII case, and only where the name is longer
 * than the suffix with no slash right before it, so neither `.gz` nor
 * `d/.gz` has one. A -S suffix that ends one of the built-in ones is tried
 * after them, or `-S z` would take the `z` off `a.gz`. Mirrors Python's
 * gzip_suffix.
 */
export declare function gzipSuffix(name: string, suffix: string): string | null;
/** gzip's refusal of a -S suffix it cannot use, before any input. Mirrors
 * Python's suffix_refusal. */
export declare function suffixRefusal(suffix: string): IOResult | null;
/**
 * One input gzip opened, and the name it opened it by: the operand or a
 * suffixed retry of it, as typed, and its bytes, read up to the first chunk.
 * `link` is where the link the name stands on sits, when gzip followed one:
 * an output in place is made beside the link, and the input it then removes
 * is the link itself. Mirrors Python's GzipInput.
 */
export interface GzipInput {
    name: PathSpec;
    stream: AsyncIterable<Uint8Array>;
    link: string | null;
}
/**
 * Open one operand the way gzip 1.13 opens it.
 *
 * A name typed with a trailing slash has to be a directory. Without -c, -t
 * or -f gzip opens with O_NOFOLLOW, so a link standing at the name, dangling
 * or not, is ELOOP, which -q never quiets; with them it is followed, a
 * retried name through the dispatcher, since what it leads to may live on any
 * mount. A directory is a warning. A missing name with no suffix gzip knows
 * is retried, when decompressing, with each suffix in turn and reported with
 * the -S one; any other failure ends the operand. Every failure is reported
 * in gzip's words and answers null. Mirrors Python's open_gzip_input.
 */
export declare function openGzipInput(path: PathSpec, source: (p: PathSpec) => AsyncIterable<Uint8Array>, 
/** Takes a failure's line, exit code and whether it is a warning. */
report: (line: string, code: number, warning: boolean) => void, options?: {
    suffix?: string;
    decompress?: boolean;
    follow?: boolean;
    resolver?: LinkResolver | null;
}): Promise<GzipInput | null>;
/**
 * Whether anything stands where gzip creates an output. gzip creates with
 * O_EXCL, which a link standing there refuses, dangling or not, so the probe
 * is an lstat: through the dispatcher while the namespace holds links, the mount's
 * own stat otherwise. Mirrors Python's output_taken.
 */
export declare function outputTaken(where: PathSpec, stat: StatFn | undefined, resolver: LinkResolver | null): Promise<boolean>;
/** An output gzip names from a typed name standing on a link: in the link's
 * own directory, whatever the link leads to. Mirrors Python's beside_link. */
export declare function besideLink(link: string, typed: string): PathSpec;
/**
 * Write an in-place output, replacing a link standing at its name. gzip -f
 * unlinks whatever holds the name before it creates the file, so a link there
 * is removed, never written through; an output beside a link goes through the
 * dispatcher, since the link may sit on any mount. Mirrors Python's replace_output.
 */
export declare function replaceOutput(out: PathSpec, data: ByteSource, write: (path: PathSpec, data: ByteSource) => Promise<void>, resolver: LinkResolver | null, beside: boolean): Promise<void>;
/**
 * Remove an input once its in-place output is written: the link it was named
 * through, when there is one. Mirrors Python's remove_input.
 */
export declare function removeInput(path: PathSpec, link: string | null, unlink: (path: PathSpec) => Promise<void>, resolver: LinkResolver | null): Promise<void>;
/** gzip's refusal to replace an output already standing at its name. */
export declare function existsLine(name: string): string;
/**
 * Decode operands in order the way gzip 1.13 does, in its voice.
 *
 * gunzip and zcat are gzip, so every line says `gzip:`. Each operand opens as
 * `openGzipInput` says. In place, a name with no known suffix and an output
 * already there are skipped with a warning (exit 2), a link standing there
 * counting as one; a warning under -q prints nothing and keeps its exit code,
 * except the unknown suffix, which -q drops whole. -f replaces an output, and
 * decodes a name standing on a link beside the link, removing the link rather
 * than what it leads to; with the output stdout it copies what is not gzip.
 * An input stdin cannot open as gzip ends the run, as gzip exits there.
 *
 * With -f, an output already there is replaced, and when the input then
 * turns out corrupt GNU has already unlinked it: mirage keeps it. Mirrors
 * Python's decompress_inputs.
 */
export declare function decompressInputs(paths: PathSpec[], read: (path: PathSpec) => AsyncIterable<Uint8Array>, options: {
    stdin: ByteSource | null;
    toStdout?: boolean;
    testOnly?: boolean;
    keep?: boolean;
    force?: boolean;
    quiet?: boolean;
    suffix?: string;
    write?: (path: PathSpec, data: ByteSource) => Promise<void>;
    unlink?: (path: PathSpec) => Promise<void>;
    stat?: StatFn;
    resolver?: LinkResolver | null;
}): Promise<[ByteSource | null, IOResult]>;
//# sourceMappingURL=decompress.d.ts.map