UNPKG

@z-test/memory-bank-mcp

Version:
91 lines (90 loc) 2.66 kB
import fs from 'fs-extra'; /** * Utility class for file operations * * Provides methods for common file system operations with proper error handling. */ export declare class FileUtils { /** * Ensures a directory exists, creating it if necessary * * @param dirPath - Path to the directory * @throws Error if directory creation fails */ static ensureDirectory(dirPath: string): Promise<void>; /** * Checks if a file or directory exists * * @param filePath - Path to check * @returns True if the path exists, false otherwise */ static fileExists(filePath: string): Promise<boolean>; /** * Reads a file's contents * * @param filePath - Path to the file * @returns The file contents as a string * @throws Error if file reading fails */ static readFile(filePath: string): Promise<string>; /** * Writes content to a file * * @param filePath - Path to the file * @param content - Content to write * @throws Error if file writing fails */ static writeFile(filePath: string, content: string): Promise<void>; /** * Lists files in a directory * * @param dirPath - Path to the directory * @returns Array of file names * @throws Error if directory reading fails */ static listFiles(dirPath: string): Promise<string[]>; /** * Gets file statistics * * @param filePath - Path to the file * @returns File statistics * @throws Error if stat operation fails */ static getFileStats(filePath: string): Promise<fs.Stats>; /** * Checks if a path is a directory * * @param dirPath - Path to check * @returns True if the path is a directory, false otherwise */ static isDirectory(dirPath: string): Promise<boolean>; /** * Deletes a file or directory * * @param targetPath - Path to delete * @throws Error if deletion fails */ static delete(targetPath: string): Promise<void>; /** * Copies a file or directory * * @param sourcePath - Source path * @param destPath - Destination path * @throws Error if copy operation fails */ static copy(sourcePath: string, destPath: string): Promise<void>; /** * Joins path segments * * @param paths - Path segments to join * @returns Joined path */ static joinPath(...paths: string[]): string; /** * Deletes a file * * @param filePath - Path to the file to delete * @throws Error if file deletion fails */ static deleteFile(filePath: string): Promise<void>; }