/** * @file Filesystem inspection helpers — `stat` / `lstat` wrappers that return * `undefined` instead of throwing, and the directory / symlink / emptiness * predicates layered on top. Every entry point catches errors and reduces * them to a falsy result; callers that need the underlying error code should * use `node:fs` directly. */ import type { PathLike } from 'node:fs'; import type { IsDirEmptyOptions } from './types.js'; /** * Check if a path is a directory asynchronously. Returns `true` for * directories, `false` for files or non-existent paths. * * @example * ;```ts * if (await isDir('./src')) { * console.log('src is a directory') * } * ``` * * @param filepath - Path to check. * * @returns `true` if path is a directory, `false` otherwise */ export declare function isDir(filepath: PathLike): Promise; /** * Check if a directory is empty synchronously. A directory is considered empty * if it contains no files after applying ignore patterns. Uses glob patterns to * filter ignored files. * * @example * ;```ts * // Check if directory is completely empty * isDirEmptySync('./build') * * // Check if directory is empty, ignoring .DS_Store files * isDirEmptySync('./cache', { ignore: ['.DS_Store'] }) * ``` * * @param dirname - Directory path to check. * @param options - Options including ignore patterns. * * @returns `true` if the directory is empty or doesn't exist, `false` otherwise */ export declare function isDirEmptySync(dirname: PathLike, options?: IsDirEmptyOptions | undefined): boolean; /** * Check if a path is a directory synchronously. Returns `true` for directories, * `false` for files or non-existent paths. * * @example * ;```ts * if (isDirSync('./src')) { * console.log('src is a directory') * } * ``` * * @param filepath - Path to check. * * @returns `true` if path is a directory, `false` otherwise */ export declare function isDirSync(filepath: PathLike): boolean; /** * Check if a path is a symbolic link synchronously. Uses `lstat` to check the * link itself, not the target. * * @example * ;```ts * if (isSymlinkSync('./my-link')) { * console.log('Path is a symbolic link') * } * ``` * * @param filepath - Path to check. * * @returns `true` if path is a symbolic link, `false` otherwise */ export declare function isSymlinkSync(filepath: PathLike): boolean; /** * Realpath a location, returning `undefined` when it does not resolve. * * @example * ;```typescript * readRealPath('/tmp') // '/private/tmp' on macOS * readRealPath('/nope') // undefined * ``` */ export declare function readRealPath(pathname: string): string | undefined; /** * Safely get file stats asynchronously, returning undefined on error. Useful * for checking file existence and properties without error handling. Returns * undefined for any error (file not found, permission denied, etc.). * * @example * ;```ts * // Check if file exists and get its stats * const stats = await safeStat('./file.txt') * if (stats) { * console.log('File size:', stats.size) * console.log('Modified:', stats.mtime) * } * ``` * * @param filepath - Path to check. * * @returns Promise resolving to Stats object, or undefined on error */ export declare function safeStat(filepath: PathLike): Promise; /** * Safely get file stats synchronously, returning undefined on error. Useful for * checking file existence and properties without error handling. Returns * undefined for any error (file not found, permission denied, etc.). * * @example * ;```ts * // Check if file exists and get its size * const stats = safeStatSync('./file.txt') * if (stats) { * console.log('File size:', stats.size) * console.log('Is directory:', stats.isDirectory()) * } * ``` * * @param filepath - Path to check. * * @returns Stats object, or undefined on error */ export declare function safeStatSync(filepath: PathLike): import("node:fs").BigIntStats | import("node:fs").Stats | undefined;