/// /// /// import fs from 'fs-extra'; import { AbstractFsPath } from './core/AbstractFsPath'; import { NodeJsBufferEncoding } from './types/NodeJsBufferEncoding'; /** * Extension class of AbstractFsObject, which extends the native String class, representing a path to a directory. * @see AbstractFsPath */ export declare class DirectoryPath extends AbstractFsPath { /** * Creates a new DirectoryPath instance. * @param dirpath The absolute path to the directory. * @param _unsafe Used internally changing it is not recommended. If true, the path is not checked for whether it is actually absolute, it is not normalized and it is assumed to be of type string. */ constructor(dirpath: string, _unsafe?: boolean); /** * The absolute path to the directory. */ get dirpath(): string; /** * Returns whether this is an DirectoryPath instance. */ get isDirectoryPath(): boolean; /** * The absolute path to the directory of the filesystem object. */ get parent(): DirectoryPath; /** * Returns a new DirectoryPath instance representing a subdirectory of this directory. * @param paths The path segments to join to the directory path. */ subdir(...paths: string[]): DirectoryPath; /** * Returns a new FilePath instance representing a file in this directory. * @param filename The name (including extension) of the file. */ file(filename: string): FilePath; /** * Synchronously reads the directory with fs.readdir and returns its contents as as FsObject instances. * @throws If the path does not exist. */ readdirSync(): AbstractFsPath[]; /** * Asynchronously reads the directory with fs.readdir and returns its contents as as FsObject instances. * @throws If the path does not exist. */ readdir(): Promise; } /** * Extension class of AbstractFsObject, which extends the native String class, representing a path to a file. * @see AbstractFsPath */ export declare class FilePath extends AbstractFsPath { /** * Creates a new FilePath instance. * @param filepath The absolute path * @param _unsafe Used internally changing it is not recommended. If true, the path is not checked for whether it is actually absolute, it is not normalized and it is assumed to be of type string. */ constructor(filepath: string, _unsafe?: boolean); /** * Returns whether this is an FilePath instance. */ get isFilePath(): boolean; /** * The absolute path to the directory of the filesystem object. */ get parent(): DirectoryPath; /** * The absolute path to the file. */ get filepath(): string; /** * The filename (including the file extension). */ get filename(): string; /** * The file extension of the source file. * @returns The file extension, including the leading dot. */ get extension(): string; /** * Read the file synchronously with fs.readFileSync. * @param encoding The encoding to use. If none is specified, a Buffer is returned. */ readFileSync(encoding?: NodeJsBufferEncoding): string | Buffer; /** * Read the file asynchronously with fs.readFile. * @param encoding The encoding to use. If none is specified, a Buffer is returned. */ readFile(encoding?: NodeJsBufferEncoding): Promise; /** * Read the file synchronously as a string with fs.readFileSync. * @param encoding The encoding to use. Defaults to 'utf8'. */ readFileStringSync(encoding?: NodeJsBufferEncoding): string; /** * Read the file asynchronously as a string with fs.readFile. * @param encoding The encoding to use. Defaults to 'utf8'. */ readFileString(encoding?: NodeJsBufferEncoding): Promise; /** * Write or overwrite the file synchronously with fs.writeFileSync. * If the directory path does not exist, it is created and no error is thrown. * @param data A string or Buffer to write to the file. * @param encoding The encoding to use. Defaults to 'utf8'. */ writeFileSync(data: string | NodeJS.ArrayBufferView, encoding?: NodeJsBufferEncoding): void; /** * Write or overwrite the file asynchronously with fs.writeFile. * If the directory path does not exist, it is created and no error is thrown. * @param data A string or Buffer to write to the file. * @param encoding The encoding to use. Defaults to 'utf8'. */ writeFile(data: string | NodeJS.ArrayBufferView, encoding?: NodeJsBufferEncoding): Promise; } /** * Creates a new FsObject instance of the correct type. * @param absolute The absolute path to the filesystem object. * @param stat The fs.Stats object of the filesystem object. * @returns an instance of the correct subclass of @see AbstractFsPath. */ export declare function instantiateCorrectFsPathSubclass(absolute: string, stat: fs.Stats): AbstractFsPath; //# sourceMappingURL=FilePath.d.ts.map