/// /// /// /// import { Node, Link, File } from './node'; import Stats from './Stats'; import Dirent from './Dirent'; import { TSetTimeout } from './setTimeoutUnref'; import { Writable } from 'stream'; import { constants } from './constants'; import { EventEmitter } from 'events'; import { TDataOut } from './encoding'; import * as misc from './node/types/misc'; import * as opts from './node/types/options'; import { FsCallbackApi, WritevCallback } from './node/types/FsCallbackApi'; import { ToTreeOptions } from './print'; import type { PathLike, symlink } from 'fs'; import type { FsPromisesApi, FsSynchronousApi } from './node/types'; export interface IError extends Error { code?: string; } export type TFileId = PathLike | number; export type TData = TDataOut | ArrayBufferView | DataView; export type TFlags = string | number; export type TMode = string | number; export type TTime = number | string | Date; export type TCallback = (error?: IError | null, data?: TData) => void; export type TFlagsCopy = typeof constants.COPYFILE_EXCL | typeof constants.COPYFILE_FICLONE | typeof constants.COPYFILE_FICLONE_FORCE; export interface IAppendFileOptions extends opts.IFileOptions { } export interface IWatchFileOptions { persistent?: boolean; interval?: number; } export interface IWatchOptions extends opts.IOptions { persistent?: boolean; recursive?: boolean; } export declare function filenameToSteps(filename: string, base?: string): string[]; export declare function pathToSteps(path: PathLike): string[]; export declare function dataToStr(data: TData, encoding?: string): string; export declare function toUnixTimestamp(time: any): any; type DirectoryContent = string | null; export interface DirectoryJSON { [key: string]: DirectoryContent; } export interface NestedDirectoryJSON { [key: string]: DirectoryContent | NestedDirectoryJSON; } /** * `Volume` represents a file system. */ export declare class Volume implements FsCallbackApi, FsSynchronousApi { static fromJSON(json: DirectoryJSON, cwd?: string): Volume; static fromNestedJSON(json: NestedDirectoryJSON, cwd?: string): Volume; /** * Global file descriptor counter. UNIX file descriptors start from 0 and go sequentially * up, so here, in order not to conflict with them, we choose some big number and descrease * the file descriptor of every new opened file. * @type {number} * @todo This should not be static, right? */ static fd: number; root: Link; ino: number; inodes: { [ino: number]: Node; }; releasedInos: number[]; fds: { [fd: number]: File; }; releasedFds: number[]; maxFiles: number; openFiles: number; StatWatcher: new () => StatWatcher; ReadStream: new (...args: any[]) => misc.IReadStream; WriteStream: new (...args: any[]) => IWriteStream; FSWatcher: new () => FSWatcher; props: { Node: new (...args: any[]) => Node; Link: new (...args: any[]) => Link; File: new (...args: any[]) => File; }; private promisesApi; get promises(): FsPromisesApi; constructor(props?: {}); createLink(): Link; createLink(parent: Link, name: string, isDirectory?: boolean, perm?: number): Link; deleteLink(link: Link): boolean; private newInoNumber; private newFdNumber; createNode(isDirectory?: boolean, perm?: number): Node; private deleteNode; getLink(steps: string[]): Link | null; getLinkOrThrow(filename: string, funcName?: string): Link; getResolvedLink(filenameOrSteps: string | string[]): Link | null; getResolvedLinkOrThrow(filename: string, funcName?: string): Link; resolveSymlinks(link: Link): Link | null; private getLinkAsDirOrThrow; private getLinkParent; private getLinkParentAsDirOrThrow; private getFileByFd; private getFileByFdOrThrow; /** * @todo This is not used anymore. Remove. */ private wrapAsync; private _toJSON; toJSON(paths?: PathLike | PathLike[], json?: {}, isRelative?: boolean, asBuffer?: boolean): DirectoryJSON; fromJSON(json: DirectoryJSON, cwd?: string): void; fromNestedJSON(json: NestedDirectoryJSON, cwd?: string): void; toTree(opts?: ToTreeOptions): string; reset(): void; mountSync(mountpoint: string, json: DirectoryJSON): void; private openLink; private openFile; private openBase; openSync(path: PathLike, flags: TFlags, mode?: TMode): number; open(path: PathLike, flags: TFlags, /* ... */ callback: TCallback): any; open(path: PathLike, flags: TFlags, mode: TMode, callback: TCallback): any; private closeFile; closeSync(fd: number): void; close(fd: number, callback: TCallback): void; private openFileOrGetById; private readBase; readSync(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number | null): number; read(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number | null, callback: (err?: Error | null, bytesRead?: number, buffer?: Buffer | ArrayBufferView | DataView) => void): void; private readvBase; readv(fd: number, buffers: ArrayBufferView[], callback: misc.TCallback2): void; readv(fd: number, buffers: ArrayBufferView[], position: number | null, callback: misc.TCallback2): void; readvSync(fd: number, buffers: ArrayBufferView[], position: number | null): number; private readFileBase; readFileSync(file: TFileId, options?: opts.IReadFileOptions | string): TDataOut; readFile(id: TFileId, callback: TCallback): any; readFile(id: TFileId, options: opts.IReadFileOptions | string, callback: TCallback): any; private writeBase; writeSync(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset?: number, length?: number, position?: number): number; writeSync(fd: number, str: string, position?: number, encoding?: BufferEncoding): number; write(fd: number, buffer: Buffer | ArrayBufferView | DataView, callback: (...args: any[]) => void): any; write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, callback: (...args: any[]) => void): any; write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, callback: (...args: any[]) => void): any; write(fd: number, buffer: Buffer | ArrayBufferView | DataView, offset: number, length: number, position: number, callback: (...args: any[]) => void): any; write(fd: number, str: string, callback: (...args: any[]) => void): any; write(fd: number, str: string, position: number, callback: (...args: any[]) => void): any; write(fd: number, str: string, position: number, encoding: BufferEncoding, callback: (...args: any[]) => void): any; private writevBase; writev(fd: number, buffers: ArrayBufferView[], callback: WritevCallback): void; writev(fd: number, buffers: ArrayBufferView[], position: number | null, callback: WritevCallback): void; writevSync(fd: number, buffers: ArrayBufferView[], position: number | null): number; private writeFileBase; writeFileSync(id: TFileId, data: TData, options?: opts.IWriteFileOptions): void; writeFile(id: TFileId, data: TData, callback: TCallback): any; writeFile(id: TFileId, data: TData, options: opts.IWriteFileOptions | string, callback: TCallback): any; private linkBase; private copyFileBase; copyFileSync(src: PathLike, dest: PathLike, flags?: TFlagsCopy): void; copyFile(src: PathLike, dest: PathLike, callback: TCallback): any; copyFile(src: PathLike, dest: PathLike, flags: TFlagsCopy, callback: TCallback): any; linkSync(existingPath: PathLike, newPath: PathLike): void; link(existingPath: PathLike, newPath: PathLike, callback: TCallback): void; private unlinkBase; unlinkSync(path: PathLike): void; unlink(path: PathLike, callback: TCallback): void; private symlinkBase; symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type): void; symlink(target: PathLike, path: PathLike, callback: TCallback): any; symlink(target: PathLike, path: PathLike, type: symlink.Type, callback: TCallback): any; private realpathBase; realpathSync(path: PathLike, options?: opts.IRealpathOptions | string): TDataOut; realpath(path: PathLike, callback: TCallback): any; realpath(path: PathLike, options: opts.IRealpathOptions | string, callback: TCallback): any; private lstatBase; lstatSync(path: PathLike): Stats; lstatSync(path: PathLike, options: { throwIfNoEntry?: true | undefined; }): Stats; lstatSync(path: PathLike, options: { bigint: false; throwIfNoEntry?: true | undefined; }): Stats; lstatSync(path: PathLike, options: { bigint: true; throwIfNoEntry?: true | undefined; }): Stats; lstatSync(path: PathLike, options: { throwIfNoEntry: false; }): Stats | undefined; lstatSync(path: PathLike, options: { bigint: false; throwIfNoEntry: false; }): Stats | undefined; lstatSync(path: PathLike, options: { bigint: true; throwIfNoEntry: false; }): Stats | undefined; lstat(path: PathLike, callback: TCallback): void; lstat(path: PathLike, options: opts.IStatOptions, callback: TCallback): void; private statBase; statSync(path: PathLike): Stats; statSync(path: PathLike, options: { throwIfNoEntry?: true; }): Stats; statSync(path: PathLike, options: { throwIfNoEntry: false; }): Stats | undefined; statSync(path: PathLike, options: { bigint: false; throwIfNoEntry?: true; }): Stats; statSync(path: PathLike, options: { bigint: true; throwIfNoEntry?: true; }): Stats; statSync(path: PathLike, options: { bigint: false; throwIfNoEntry: false; }): Stats | undefined; statSync(path: PathLike, options: { bigint: true; throwIfNoEntry: false; }): Stats | undefined; stat(path: PathLike, callback: TCallback): void; stat(path: PathLike, options: opts.IStatOptions, callback: TCallback): void; private fstatBase; fstatSync(fd: number): Stats; fstatSync(fd: number, options: { bigint: false; }): Stats; fstatSync(fd: number, options: { bigint: true; }): Stats; fstat(fd: number, callback: TCallback): void; fstat(fd: number, options: opts.IFStatOptions, callback: TCallback): void; private renameBase; renameSync(oldPath: PathLike, newPath: PathLike): void; rename(oldPath: PathLike, newPath: PathLike, callback: TCallback): void; private existsBase; existsSync(path: PathLike): boolean; exists(path: PathLike, callback: (exists: boolean) => void): void; private accessBase; accessSync(path: PathLike, mode?: number): void; access(path: PathLike, callback: TCallback): any; access(path: PathLike, mode: number, callback: TCallback): any; appendFileSync(id: TFileId, data: TData, options?: IAppendFileOptions | string): void; appendFile(id: TFileId, data: TData, callback: TCallback): any; appendFile(id: TFileId, data: TData, options: IAppendFileOptions | string, callback: TCallback): any; private readdirBase; readdirSync(path: PathLike, options?: opts.IReaddirOptions | string): TDataOut[] | Dirent[]; readdir(path: PathLike, callback: TCallback): any; readdir(path: PathLike, options: opts.IReaddirOptions | string, callback: TCallback): any; private readlinkBase; readlinkSync(path: PathLike, options?: opts.IOptions): TDataOut; readlink(path: PathLike, callback: TCallback): any; readlink(path: PathLike, options: opts.IOptions, callback: TCallback): any; private fsyncBase; fsyncSync(fd: number): void; fsync(fd: number, callback: TCallback): void; private fdatasyncBase; fdatasyncSync(fd: number): void; fdatasync(fd: number, callback: TCallback): void; private ftruncateBase; ftruncateSync(fd: number, len?: number): void; ftruncate(fd: number, callback: TCallback): any; ftruncate(fd: number, len: number, callback: TCallback): any; private truncateBase; /** * `id` should be a file descriptor or a path. `id` as file descriptor will * not be supported soon. */ truncateSync(id: TFileId, len?: number): void; truncate(id: TFileId, callback: TCallback): any; truncate(id: TFileId, len: number, callback: TCallback): any; private futimesBase; futimesSync(fd: number, atime: TTime, mtime: TTime): void; futimes(fd: number, atime: TTime, mtime: TTime, callback: TCallback): void; private utimesBase; utimesSync(path: PathLike, atime: TTime, mtime: TTime): void; utimes(path: PathLike, atime: TTime, mtime: TTime, callback: TCallback): void; private mkdirBase; /** * Creates directory tree recursively. * @param filename * @param modeNum */ private mkdirpBase; mkdirSync(path: PathLike, options: opts.IMkdirOptions & { recursive: true; }): string | undefined; mkdirSync(path: PathLike, options?: TMode | (opts.IMkdirOptions & { recursive?: false; })): void; mkdirSync(path: PathLike, options?: TMode | opts.IMkdirOptions): string | undefined; mkdir(path: PathLike, callback: TCallback): any; mkdir(path: PathLike, mode: TMode | (opts.IMkdirOptions & { recursive?: false; }), callback: TCallback): any; mkdir(path: PathLike, mode: opts.IMkdirOptions & { recursive: true; }, callback: TCallback): any; mkdir(path: PathLike, mode: TMode | opts.IMkdirOptions, callback: TCallback): any; private mkdtempBase; mkdtempSync(prefix: string, options?: opts.IOptions): TDataOut; mkdtemp(prefix: string, callback: TCallback): any; mkdtemp(prefix: string, options: opts.IOptions, callback: TCallback): any; private rmdirBase; rmdirSync(path: PathLike, options?: opts.IRmdirOptions): void; rmdir(path: PathLike, callback: TCallback): any; rmdir(path: PathLike, options: opts.IRmdirOptions, callback: TCallback): any; private rmBase; rmSync(path: PathLike, options?: opts.IRmOptions): void; rm(path: PathLike, callback: TCallback): void; rm(path: PathLike, options: opts.IRmOptions, callback: TCallback): void; private fchmodBase; fchmodSync(fd: number, mode: TMode): void; fchmod(fd: number, mode: TMode, callback: TCallback): void; private chmodBase; chmodSync(path: PathLike, mode: TMode): void; chmod(path: PathLike, mode: TMode, callback: TCallback): void; private lchmodBase; lchmodSync(path: PathLike, mode: TMode): void; lchmod(path: PathLike, mode: TMode, callback: TCallback): void; private fchownBase; fchownSync(fd: number, uid: number, gid: number): void; fchown(fd: number, uid: number, gid: number, callback: TCallback): void; private chownBase; chownSync(path: PathLike, uid: number, gid: number): void; chown(path: PathLike, uid: number, gid: number, callback: TCallback): void; private lchownBase; lchownSync(path: PathLike, uid: number, gid: number): void; lchown(path: PathLike, uid: number, gid: number, callback: TCallback): void; private statWatchers; watchFile(path: PathLike, listener: (curr: Stats, prev: Stats) => void): StatWatcher; watchFile(path: PathLike, options: IWatchFileOptions, listener: (curr: Stats, prev: Stats) => void): StatWatcher; unwatchFile(path: PathLike, listener?: (curr: Stats, prev: Stats) => void): void; createReadStream(path: misc.PathLike, options?: opts.IReadStreamOptions | string): misc.IReadStream; createWriteStream(path: PathLike, options?: opts.IWriteStreamOptions | string): IWriteStream; watch(path: PathLike, options?: IWatchOptions | string, listener?: (eventType: string, filename: string) => void): FSWatcher; cpSync: FsSynchronousApi['cpSync']; lutimesSync: FsSynchronousApi['lutimesSync']; statfsSync: FsSynchronousApi['statfsSync']; opendirSync: FsSynchronousApi['opendirSync']; cp: FsCallbackApi['cp']; lutimes: FsCallbackApi['lutimes']; statfs: FsCallbackApi['statfs']; openAsBlob: FsCallbackApi['openAsBlob']; opendir: FsCallbackApi['opendir']; } export declare class StatWatcher extends EventEmitter { vol: Volume; filename: string; interval: number; timeoutRef?: any; setTimeout: TSetTimeout; prev: Stats; constructor(vol: Volume); private loop; private hasChanged; private onInterval; start(path: string, persistent?: boolean, interval?: number): void; stop(): void; } export interface IWriteStream extends Writable { bytesWritten: number; path: string; pending: boolean; new (path: PathLike, options: opts.IWriteStreamOptions): any; open(): any; close(): any; } export declare class FSWatcher extends EventEmitter { _vol: Volume; _filename: string; _steps: string[]; _filenameEncoded: TDataOut; _recursive: boolean; _encoding: BufferEncoding; _link: Link; _timer: any; private _listenerRemovers; constructor(vol: Volume); private _getName; private _onParentChild; private _emit; private _persist; start(path: PathLike, persistent?: boolean, recursive?: boolean, encoding?: BufferEncoding): void; close(): void; } export {};