import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper/response.helper.interface"; export default class FileManager { private readonly responseHelper; private readonly WorkerProcess; constructor(); WriteFile(path: string, data: string): Promise; /** * Writes a file and fsyncs it before returning, so the write is guaranteed on disk * (not just sitting in the OS page cache) once this resolves. Use for anything a * crash-recovery path depends on finding - e.g. transaction registry state - where * a plain `WriteFile` can silently vanish on power loss even though the call succeeded. */ WriteFileDurable(path: string, data: string): Promise; /** Atomically creates a file only if absent (OS-level 'wx' flag) - safe for lock files. */ WriteFileExclusive(path: string, data: string): Promise; ReadFile(path: string): Promise; /** * Streams a file line-by-line — memory-efficient for large files. * Returns each non-empty line as a string element in the resolved array. * * @param path - Absolute path to the file. * @returns Array of trimmed non-empty lines, or empty array on error. */ ReadLines(path: string): Promise; /** * Appends data to a file without reading or rewriting existing content (O(1)). * Creates the file and parent directories if they don't already exist. * * @param path - Absolute path to the file. * @param data - String to append (caller should include trailing newline if needed). */ AppendFile(path: string, data: string): Promise; /** * Appends data and fsyncs before returning, so the appended line is guaranteed on disk * even if the process dies immediately after. O(1) durable counterpart to * {@link WriteFileDurable} - use it for append-only journals whose loss would break * crash recovery. * * @param path - Absolute path to the file. * @param data - String to append (caller should include trailing newline if needed). */ AppendFileDurable(path: string, data: string): Promise; DeleteFile(path: string): Promise; FileExists(path: string): Promise; CreateFile(path: string): Promise; MoveFile(oldPath: string, newPath: string): Promise; /** * Retrieves the size of a file in bytes. * * @param path - The path to the file. * @returns A promise that resolves to a SuccessInterface containing the file size in bytes, * or an ErrorInterface if an error occurs. */ GetFileSize(path: string): Promise; DeleteFileWithLock(collectionPath: string, fileName: string): Promise; }