/// /// /// import { SystemError } from './error'; import * as crypto from 'crypto'; export declare class FileError extends SystemError { readonly operation: string; readonly reason: string; constructor(operation: string, reason: string); } export declare class File { private readonly filePath; constructor(filePath: string); /** Appends this file with the given data. If the file does not exist it will be created. */ append(data: Buffer | string): Promise; /** Copies this file into the target folder. If the target folder does not exist it will be created. */ copy(folderPath: string): Promise; /** Creates an empty file if not exists. */ create(): Promise; /** Deletes this file if it exists. Otherwise no action. */ delete(): Promise; /** Replaces text content in this file that matches the given string or regular expression. */ edit(pattern: RegExp | string, replacement: string): Promise; /** Returns true if this file exists. */ exists(): Promise; /** Returns a hash for this file with the given algorithm (default is sha1, digest is hex) */ hash(algorithm?: string, digest?: crypto.BinaryToTextEncoding): Promise; /** Moves this file into the target folder. If the target folder does not exist it will be created. */ move(folderPath: string): Promise; /** Prepends this file with the given data. If the file does not exist it will be created. */ prepend(data: Buffer | string): Promise; /** Reads this file as a JSON object. Will throw if the content cannot be parsed. */ json(): Promise; /** Returns the absolute path of this file. */ path(): string; /** Reads this file as a buffer. */ read(): Promise; /** Reads this file with the given encoding. */ read(encoding: BufferEncoding): Promise; /** Renames this file to the given newname. */ rename(newName: string): Promise; /** Returns the size of this file in bytes. */ size(): Promise; /** Returns the stats object for this file. */ stat(): Promise; /** Truncates the contents of this file. If the file does not exist, it is created. */ truncate(length?: number): Promise; /** Writes to this file. If the file does not exist, it is created. */ write(data: string | Buffer): Promise; /** Asserts the given path exists. */ private assertExists; /** Checks the given path exists. */ private checkExists; /** Creates a directory if not exists. */ private createFolder; } /** Returns an interface to interact with a file. */ export declare function file(file: string): File;