///
import fs, { PathLike, Stats } from "fs";
import { DurationStr } from './TimeDurations';
import { StreamRangeFactory } from "./Streams";
export declare type StreamFactory = () => NodeJS.ReadableStream;
export declare class Files {
static recursively(path: string, listener: (path: string, stat: fs.Stats) => Promise, aborter?: Aborter): Promise;
static createDirectorySnapshot(path: string, targetPath: string, filter?: DirectorySnapshotPredicate): Promise;
static removeDirectoryRecursivelyAsync(path: string): Promise;
static fileType(path: string): Promise;
static removeAsync(path: string): Promise;
static deleteAsync(path: string): Promise>;
static existsAsync(path: string): Promise;
static createDirSync(dir: string, mode?: number | string | undefined | null): CreateDirResult;
static createDirAsync(dir: string, mode?: number | string | undefined | null): Promise;
static readFileAsync(path: PathLike | number): Promise;
static createReadStream(path: PathLike, options?: CreateReadStreamOptions): fs.ReadStream;
static createReadStreamForRange(path: PathLike): StreamRangeFactory;
static createWriteStream(path: PathLike, options?: CreateWriteStreamOptions): fs.WriteStream;
static writeFileAsync(path: string, data: FileHandle | NodeJS.ReadableStream | Buffer | string | StreamFactory, options?: WriteFileAsyncOptions): Promise;
private static _writeFileAsync;
static renameAsync(oldPath: string, newPath: string): Promise;
static statAsync(path: string): Promise;
static mkdirAsync(path: string, mode?: number | string | undefined | null): Promise;
static accessAsync(path: PathLike, mode: number | undefined): Promise;
static unlinkAsync(path: PathLike): Promise;
static rmdirAsync(path: PathLike): Promise;
static linkAsync(existingPath: PathLike, newPath: PathLike): Promise;
static readdirAsync(path: string): Promise;
static realpathAsync(path: string): Promise;
static copyFileAsync(src: string, dest: string, flags?: number): Promise;
static appendFileAsync(path: string | Buffer | number, data: string | Buffer, options?: AppendFileOptions): Promise;
static openAsync(path: string | Buffer, flags: string | number, mode?: number): Promise;
static closeAsync(fd: number): Promise;
static fdatasyncAsync(fd: number): Promise;
static fsyncAsync(fd: number): Promise;
private static withProperException;
private static createProperException;
private static readonly promised;
}
export interface CreateDirResult {
dir: string;
exists?: boolean;
created?: boolean;
}
export interface WriteFileAsyncOptions {
readonly encoding?: string | null;
readonly mode?: number | string;
readonly flag?: string;
readonly existing?: 'link' | 'copy';
readonly atomic?: boolean;
}
export interface AppendFileOptions {
encoding?: string | null;
mode: number;
flag: string;
}
export interface FileDeleted {
path: string;
deleted: boolean;
}
export declare type CreateReadStreamOptions = string | {
flags?: string;
encoding?: string;
fd?: number;
mode?: number;
autoClose?: boolean;
start?: number;
end?: number;
highWaterMark?: number;
};
export declare type CreateWriteStreamOptions = string | {
flags?: string;
encoding?: string;
fd?: number;
mode?: number;
autoClose?: boolean;
start?: number;
};
export interface FileHandle {
path: string;
}
export declare class FileHandles {
static isFileHandle(obj: any): boolean;
}
export interface RemovedFiles {
readonly path: string;
readonly files: ReadonlyArray;
readonly dirs: ReadonlyArray;
}
export interface SnapshotFiles {
readonly path: string;
readonly files: ReadonlyArray;
readonly dirs: ReadonlyArray;
}
export declare type FileType = 'file' | 'directory' | 'block-device' | 'character-device' | 'fifo' | 'socket' | 'symbolic-link';
export declare type DirectorySnapshotPredicate = (path: string, targetPath: string) => boolean;
export declare const ACCEPT_ALL: DirectorySnapshotPredicate;
export interface RecursionResult {
readonly aborted: boolean;
}
export declare type AbortionProvider = () => boolean;
export declare class Aborter {
private provider;
private aborted;
constructor(provider: AbortionProvider);
protected hasAborted(): boolean;
verify(): void;
wasMarkedAborted(): boolean;
}
export declare class Aborters {
static maxTime(duration?: DurationStr): Aborter;
}
export declare class AbortionError extends Error {
}