export interface AtomicWriteOptions { /** * File permissions (octal number, e.g., 0o640). * Defaults to 0o640. */ mode?: number; /** * File owner in "user" or "user:group" format. * Only applied when running as root. */ owner?: string; /** * Force sync to disk before rename (fsync). * Recommended for critical data. * Defaults to false. */ fsync?: boolean; /** * Create parent directories if they don't exist. * Defaults to true. */ createDirs?: boolean; /** * Mode for created parent directories. * Defaults to 0o750. */ dirMode?: number; /** * Create backup of existing file before write. * Backup will be at filePath + '.backup'. * Defaults to false. */ backup?: boolean; /** * Verify written content by re-reading and comparing hash. * Defaults to false. */ verify?: boolean; } /** * Write content to a file atomically. * * Uses temp file + rename pattern to ensure the file is either * fully written or not modified at all. * * @param filePath - Absolute path to target file * @param content - Content to write (string or Buffer) * @param options - Write options * @returns Hash of written content (SHA-256) */ export declare function writeAtomic(filePath: string, content: string | Buffer, options?: AtomicWriteOptions): string; /** * Write content atomically with full durability guarantees. * This is the paranoid version with fsync, verification, and backup. * * @param filePath - Absolute path to target file * @param content - Content to write * @param options - Additional options * @returns Hash of written content */ export declare function writeAtomicDurable(filePath: string, content: string | Buffer, options?: Omit): string; /** * Calculate SHA-256 hash of content. * * @param content - Content to hash * @returns Hex-encoded hash */ export declare function hashContent(content: string | Buffer): string; /** * Verify a file matches expected hash. * * @param filePath - Path to file * @param expectedHash - Expected SHA-256 hash * @returns true if file matches hash */ export declare function verifyFile(filePath: string, expectedHash: string): boolean; /** * Recover file from backup if main file is corrupted or missing. * * @param filePath - Path to main file * @param validator - Optional function to validate content * @returns Recovered content or null */ export declare function recoverFromBackup(filePath: string, validator?: (content: string) => boolean): string | null; /** * Clean up temp and backup files for a given path. * * @param filePath - Main file path */ export declare function cleanupTempFiles(filePath: string): void; /** * Ensure a directory exists with proper permissions. * * @param dirPath - Directory path * @param mode - Directory mode (default: 0o750) * @param owner - Optional owner in "user:group" format */ export declare function ensureDir(dirPath: string, mode?: number, owner?: string): void; //# sourceMappingURL=file.d.ts.map