import { BigIntStats } from "node:fs"; /** Identifies a file or directory on disk, however its path is written: letter case, `..`, or a symlink to it. */ export declare const fileId: (stats: BigIntStats) => string; /** * Whether `error` means that a path doesn't exist: it, or a directory on the way to it, is missing, a part of the way * is a file, or the way is a cycle of symlinks that leads nowhere. Other errors, such as missing permissions, mean * that what is there can't be known. Those are thrown, so cleaning stops instead of deleting what it should keep. */ export declare const isNotFound: (error: unknown) => boolean; /** The identity of `file` on disk, following symlinks, or `undefined` when it doesn't exist. */ export declare const statId: (file: string) => Promise; /** * Where a path is on disk, to compare paths by what they point to rather than by how they are written: with other * letter case on case-insensitive file systems such as on Windows and macOS, with `..`, or through symlinks. * * A path that doesn't exist yet, such as an output directory before the first run, is located by its nearest existing * parent and the names below it. Those names are compared ignoring letter case, since nothing on disk tells whether * the file system will tell them apart. They have no files to delete or keep, so the difference doesn't matter. */ export type Location = { /** The identities of the nearest existing file or directory at or above the path, and of each of its parents. */ ids: string[]; /** The names below the nearest existing directory that don't exist yet, in lowercase. */ missing: string[]; }; /** * Remembers where paths are, to look up the same directories only once while nothing on disk changes, e.g. while * checking what cleaning would delete. Use a new one after files are deleted or created. */ export type LocateCache = Map>; export declare function locate(file: string, cache?: LocateCache): Promise; /** Whether `a` and `b` are the same file or directory on disk. */ export declare const isSameLocation: (a: Location, b: Location) => boolean; /** Whether `child` is `parent` itself or somewhere inside it on disk. */ export declare const isSameOrInsideLocation: (child: Location, parent: Location) => boolean; /** * Every file, directory and symlink on the way to `file`, in the order they are reached: each part of the path, and * when a part is a symlink, each part of where it points, until `file` itself. This is how the operating system * follows a path, so every symlink in a chain of symlinks is found, also with relative targets. The way stops at a * part that doesn't exist, and after too many symlinks, such as in a cycle of symlinks. * * `..` after a symlink is the parent on disk of where the symlink points, except on Windows, where `..` is resolved * from the path as written, like Windows does. */ export declare function entriesOnTheWay(file: string): Promise; /** * The entries on the way to `file` (see `entriesOnTheWay`) that are in `dir`, or in a directory inside it, on disk: * the ones that cleaning `dir` would delete. So `file` is found however it and `dir` are written, also through chains * of symlinks. */ export declare function entriesIn(file: string, dir: Location, cache?: LocateCache): Promise; /** Whether cleaning `dir` deletes `file`, or a directory or symlink on the way to it. */ export declare const isReachedThrough: (file: string, dir: Location, cache?: LocateCache) => Promise; /** Whether `file` is a symlink itself, not following it. `false` when it doesn't exist. */ export declare const isSymlink: (file: string) => Promise;