import { Stats } from 'node:fs'; /** * Python pathlib module for TypeScript * * Provides object-oriented filesystem paths with async operations. * * @see {@link https://docs.python.org/3/library/pathlib.html | Python pathlib documentation} * @module */ /** * Path class representing a filesystem path. * Provides both path manipulation (pure) and filesystem operations. */ declare class Path { private readonly _path; /** * Create a new Path instance. * * @param pathSegments - Path segments to join */ constructor(...pathSegments: string[]); /** * Static factory method to create a Path. */ static of(...pathSegments: string[]): Path; /** * The final component of the path. */ get name(): string; /** * The final component without its suffix. */ get stem(): string; /** * The file extension of the final component. */ get suffix(): string; /** * A list of the path's file extensions. */ get suffixes(): string[]; /** * The logical parent of the path. */ get parent(): Path; /** * An immutable sequence of the path's ancestors. */ get parents(): Path[]; /** * The individual components of the path. */ get parts(): string[]; /** * The drive or root (on Windows, the drive letter; on Unix, empty or /). */ get anchor(): string; /** * The drive letter (Windows only, empty on Unix). */ get drive(): string; /** * The root of the path (/ on Unix, \\ or drive:\\ on Windows). */ get root(): string; /** * Whether the path is absolute. */ isAbsolute(): boolean; /** * Combine this path with additional segments. * * @param pathSegments - Path segments to join * @returns A new Path */ joinpath(...pathSegments: string[]): Path; /** * Division operator alternative: join paths. * * @param other - Path segment to join * @returns A new Path */ div(other: string | Path): Path; /** * Return a string representation of the path. */ toString(): string; /** * Return the path as a POSIX path string. */ asPosix(): string; /** * Return the path as a URI. */ asUri(): string; /** * Whether the path exists. */ exists(): Promise; /** * Whether the path is a file. */ isFile(): Promise; /** * Whether the path is a directory. */ isDir(): Promise; /** * Whether the path is a symbolic link. */ isSymlink(): Promise; /** * Read the file contents as text. * * @param encoding - Text encoding (default: utf-8) * @returns File contents as string */ readText(encoding?: BufferEncoding): Promise; /** * Write text to the file. * * @param data - Text to write * @param encoding - Text encoding (default: utf-8) */ writeText(data: string, encoding?: BufferEncoding): Promise; /** * Read the file contents as bytes. * * @returns File contents as Uint8Array */ readBytes(): Promise; /** * Write bytes to the file. * * @param data - Bytes to write */ writeBytes(data: Uint8Array): Promise; /** * Create the directory (and parents if necessary). * * @param options - Options object */ mkdir(options?: { parents?: boolean; existOk?: boolean; }): Promise; /** * Remove the directory. */ rmdir(): Promise; /** * Remove the file or symbolic link. */ unlink(): Promise; /** * Rename the path to target. * * @param target - New path * @returns The new Path */ rename(target: string | Path): Promise; /** * Replace target with this file. * * @param target - Target path to replace * @returns The new Path */ replace(target: string | Path): Promise; /** * Make the path absolute. * * @returns Absolute path */ resolve(): Path; /** * Return the absolute path. * * @returns Absolute path */ absolute(): Path; /** * Return the real path (resolving symlinks). * * @returns Real path */ readlink(): Promise; /** * Get file statistics. * * @returns File stat object */ stat(): Promise; /** * Get symbolic link statistics. * * @returns Stat object for the symlink itself */ lstat(): Promise; /** * Iterate over directory contents. * * @returns Array of Path objects */ iterdir(): Promise; /** * Glob pattern matching. * * @param pattern - Glob pattern * @returns Array of matching Path objects */ glob(pattern: string): Promise; /** * Recursive glob pattern matching. * * @param pattern - Glob pattern * @returns Array of matching Path objects */ rglob(pattern: string): Promise; /** * Internal glob matching implementation. */ private matchGlob; /** * Convert glob pattern to regex. */ private globToRegex; /** * Create a symbolic link. * * @param target - Target of the symlink */ symlinkTo(target: string | Path): Promise; /** * Create a hard link. * * @param target - Target of the link */ linkTo(target: string | Path): Promise; /** * Change file permissions. * * @param mode - Permission mode */ chmod(mode: number): Promise; /** * Update access and modification times. * * @param atime - Access time * @param mtime - Modification time */ touch(atime?: Date, mtime?: Date): Promise; /** * Check if path matches a pattern. * * @param pattern - Glob pattern * @returns True if matches */ match(pattern: string): boolean; /** * Return path relative to another path. * * @param other - Base path * @returns Relative path */ relativeTo(other: string | Path): Path; /** * Return a new path with a different suffix. * * @param suffix - New suffix * @returns New Path */ withSuffix(suffix: string): Path; /** * Return a new path with a different name. * * @param name - New name * @returns New Path */ withName(name: string): Path; /** * Return a new path with a different stem. * * @param stem - New stem * @returns New Path */ withStem(stem: string): Path; /** * Get the current working directory as a Path. */ static cwd(): Path; /** * Get the home directory as a Path. */ static home(): Path; } /** * PurePath class for path manipulation without filesystem access. * This is an alias for Path that only uses the pure path operations. */ declare const PurePath: typeof Path; /** * PurePosixPath for POSIX-style paths. */ declare const PurePosixPath: typeof Path; /** * PureWindowsPath for Windows-style paths. */ declare const PureWindowsPath: typeof Path; /** * PosixPath for POSIX filesystem operations. */ declare const PosixPath: typeof Path; /** * WindowsPath for Windows filesystem operations. */ declare const WindowsPath: typeof Path; type pathlibModule_Path = Path; declare const pathlibModule_Path: typeof Path; declare const pathlibModule_PosixPath: typeof PosixPath; declare const pathlibModule_PurePath: typeof PurePath; declare const pathlibModule_PurePosixPath: typeof PurePosixPath; declare const pathlibModule_PureWindowsPath: typeof PureWindowsPath; declare const pathlibModule_WindowsPath: typeof WindowsPath; declare namespace pathlibModule { export { pathlibModule_Path as Path, pathlibModule_PosixPath as PosixPath, pathlibModule_PurePath as PurePath, pathlibModule_PurePosixPath as PurePosixPath, pathlibModule_PureWindowsPath as PureWindowsPath, pathlibModule_WindowsPath as WindowsPath }; } export { Path as P, WindowsPath as W, PosixPath as a, PurePath as b, PurePosixPath as c, PureWindowsPath as d, pathlibModule as p };