Interface BoundContext

Allows you to restrict operations to a specific root path and set of credentials.

interface BoundContext {
    children: FSContext[];
    credentials: Credentials;
    descriptors: Map<number, SyncHandle>;
    fs: fs & {
        access: (
            this: FSContext,
            ...args: [path: PathLike, mode: number, cb: Callback],
        ) => void;
        accessSync: (
            this: FSContext,
            ...args: [path: PathLike, mode: number],
        ) => void;
        appendFile: (
            this: FSContext,
            ...args: [
                filename: PathLike,
                data: FileContents,
                encoding?: BufferEncoding,
                cb?: Callback,
            ],
        ) => void;
        appendFileSync: (
            this: FSContext,
            ...args: [
                filename: PathOrFileDescriptor,
                data: FileContents,
                _options: WriteFileOptions,
            ],
        ) => void;
        BigIntStatsFs: typeof BigIntStatsFs;
        chmod: (
            this: FSContext,
            ...args: [path: PathLike, mode: string | number, cb: Callback],
        ) => void;
        chmodSync: (
            this: FSContext,
            ...args: [path: PathLike, mode: Mode],
        ) => void;
        chown: (
            this: FSContext,
            ...args: [path: PathLike, uid: number, gid: number, cb: Callback],
        ) => void;
        chownSync: (
            this: FSContext,
            ...args: [path: PathLike, uid: number, gid: number],
        ) => void;
        chroot: (this: FSContext, ...args: [path: string]) => void;
        close: (this: FSContext, ...args: [fd: number, cb: Callback]) => void;
        closeSync: (this: FSContext, ...args: [fd: number]) => void;
        constants: constants;
        copyFile: (
            this: FSContext,
            ...args: [
                src: PathLike,
                dest: PathLike,
                flags: number,
                callback: Callback,
            ],
        ) => void;
        copyFileSync: (
            this: FSContext,
            ...args: [source: PathLike, destination: PathLike, flags?: number],
        ) => void;
        cp: (
            this: FSContext,
            ...args: [
                source: PathLike,
                destination: PathLike,
                opts: CopyOptions,
                callback: Callback,
            ],
        ) => void;
        cpSync: (
            this: FSContext,
            ...args: [
                source: PathLike,
                destination: PathLike,
                opts?: CopySyncOptions,
            ],
        ) => void;
        createReadStream: (
            this: FSContext,
            ...args: [path: PathLike, options?: BufferEncoding | ReadStreamOptions],
        ) => ReadStream;
        createWriteStream: (
            this: FSContext,
            ...args: [path: PathLike, options?: BufferEncoding | WriteStreamOptions],
        ) => WriteStream;
        Dir: typeof Dir;
        Dirent: typeof Dirent;
        exists: (
            this: FSContext,
            ...args: [path: PathLike, cb: (exists: boolean) => unknown],
        ) => void;
        existsSync: (this: FSContext, ...args: [path: PathLike]) => boolean;
        fchmod: (
            this: FSContext,
            ...args: [fd: number, mode: string | number, cb: Callback],
        ) => void;
        fchmodSync: (
            this: FSContext,
            ...args: [fd: number, mode: string | number],
        ) => void;
        fchown: (
            this: FSContext,
            ...args: [fd: number, uid: number, gid: number, cb: Callback],
        ) => void;
        fchownSync: (
            this: FSContext,
            ...args: [fd: number, uid: number, gid: number],
        ) => void;
        fdatasync: (this: FSContext, ...args: [fd: number, cb: Callback]) => void;
        fdatasyncSync: (this: FSContext, ...args: [fd: number]) => void;
        fstat: (
            this: FSContext,
            ...args: [
                fd: number,
                options: StatOptions & { bigint: true },
                cb: Callback<[BigIntStats]>,
            ],
        ) => void;
        fstatSync: (
            this: FSContext,
            ...args: [fd: number, options: { bigint: true }],
        ) => BigIntStats;
        fsync: (this: FSContext, ...args: [fd: number, cb: Callback]) => void;
        fsyncSync: (this: FSContext, ...args: [fd: number]) => void;
        ftruncate: (
            this: FSContext,
            ...args: [fd: number, len?: number, cb?: Callback],
        ) => void;
        ftruncateSync: (
            this: FSContext,
            ...args: [fd: number, len: null | number],
        ) => void;
        futimes: (
            this: FSContext,
            ...args: [
                fd: number,
                atime: number
                | Date,
                mtime: number | Date,
                cb: Callback,
            ],
        ) => void;
        futimesSync: (
            this: FSContext,
            ...args: [
                fd: number,
                atime: string
                | number
                | Date,
                mtime: string | number | Date,
            ],
        ) => void;
        glob: (
            this: FSContext,
            ...args: [
                pattern: string
                | string[],
                options: GlobOptions,
                callback: GlobCallback<[string[] | Dirent[]]>,
            ],
        ) => void;
        globSync: (
            this: FSContext,
            ...args: [pattern: string | string[], options: GlobOptions],
        ) => string[] | Dirent[];
        IOC: typeof IOC;
        IOC32: typeof IOC32;
        ioctl: (this: FSContext, ...args: never) => Promise<any>;
        ioctlSync: (this: FSContext, ...args: never) => any;
        lchmod: (
            this: FSContext,
            ...args: [path: PathLike, mode: string | number, cb: Callback],
        ) => void;
        lchmodSync: (
            this: FSContext,
            ...args: [path: PathLike, mode: string | number],
        ) => void;
        lchown: (
            this: FSContext,
            ...args: [path: PathLike, uid: number, gid: number, cb: Callback],
        ) => void;
        lchownSync: (
            this: FSContext,
            ...args: [path: PathLike, uid: number, gid: number],
        ) => void;
        link: (
            this: FSContext,
            ...args: [existing: PathLike, newpath: PathLike, cb: Callback],
        ) => void;
        linkSync: (
            this: FSContext,
            ...args: [targetPath: PathLike, linkPath: PathLike],
        ) => void;
        lopenSync: (
            this: FSContext,
            ...args: [path: PathLike, flag: string, mode?: null | Mode],
        ) => number;
        lstat: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options: StatOptions,
                callback: Callback<[Stats | BigIntStats]>,
            ],
        ) => void;
        lstatSync: (
            this: FSContext,
            ...args: [path: PathLike, options: { bigint: true }],
        ) => BigIntStats;
        lutimes: (
            this: FSContext,
            ...args: [
                path: PathLike,
                atime: number
                | Date,
                mtime: number | Date,
                cb: Callback,
            ],
        ) => void;
        lutimesSync: (
            this: FSContext,
            ...args: [
                path: PathLike,
                atime: string
                | number
                | Date,
                mtime: string | number | Date,
            ],
        ) => void;
        mkdir: (
            this: FSContext,
            ...args: [path: PathLike, mode?: Mode, cb: Callback],
        ) => void;
        mkdirSync: (
            this: FSContext,
            ...args: [path: PathLike, options?: null | Mode | MakeDirectoryOptions],
        ) => undefined | string;
        mkdtemp: (
            this: FSContext,
            ...args: [
                prefix: string,
                options: BufferEncodingOption,
                callback: Callback<[Buffer<ArrayBufferLike>]>,
            ],
        ) => void;
        mkdtempSync: (
            this: FSContext,
            ...args: [prefix: string, options?: EncodingOption],
        ) => string;
        mount: (
            this: FSContext,
            ...args: [mountPoint: string, fs: FileSystem],
        ) => void;
        open: (
            this: FSContext,
            ...args: [
                path: PathLike,
                flag: OpenMode,
                mode: string
                | number,
                cb?: Callback<[number]>,
            ],
        ) => void;
        openAsBlob: (
            this: FSContext,
            ...args: [path: PathLike, options?: OpenAsBlobOptions],
        ) => Promise<Blob>;
        opendir: (
            this: FSContext,
            ...args: [path: PathLike, options: OpenDirOptions, cb: Callback<[Dir]>],
        ) => void;
        opendirSync: (
            this: FSContext,
            ...args: [path: PathLike, options?: OpenDirOptions],
        ) => Dir;
        openSync: (
            this: FSContext,
            ...args: [path: PathLike, flag: OpenMode, mode: null | Mode],
        ) => number;
        promises: promises;
        read: (
            this: FSContext,
            ...args: [
                fd: number,
                buffer: Uint8Array<ArrayBufferLike>,
                offset: number,
                length: number,
                position?: number,
                cb: Callback<[number, Uint8Array<ArrayBufferLike>]>,
            ],
        ) => void;
        readdir: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options: { withFileTypes: true },
                cb: Callback<[Dirent[]]>,
            ],
        ) => void;
        readdirSync: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options?: | null
                | "ascii"
                | "utf8"
                | "utf-8"
                | "utf16le"
                | "utf-16le"
                | "ucs2"
                | "ucs-2"
                | "base64"
                | "base64url"
                | "latin1"
                | "binary"
                | "hex"
                | ReaddirOptions & ObjectEncodingOptions
                | ReaddirOptions & "buffer"
                | ReaddirOptions & { encoding: "buffer" },
            ],
        ) => string[] | Buffer<ArrayBufferLike>[] | Dirent[];
        readFile: (
            this: FSContext,
            ...args: [
                filename: PathLike,
                options: BufferEncoding
                | { encoding: BufferEncoding; flag?: string },
                cb: Callback<[string]>,
            ],
        ) => void;
        readFileSync: (
            this: FSContext,
            ...args: [
                path: PathOrFileDescriptor,
                options?: | null
                | BufferEncoding
                | (EncodingOption & { flag?: string | undefined; }),
            ],
        ) => string;
        readlink: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options: EncodingOption,
                callback: Callback<[string]>,
            ],
        ) => void;
        readlinkSync: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options?: | null
                | "buffer"
                | "ascii"
                | "utf8"
                | "utf-8"
                | "utf16le"
                | "utf-16le"
                | "ucs2"
                | "ucs-2"
                | "base64"
                | "base64url"
                | "latin1"
                | "binary"
                | "hex"
                | ObjectEncodingOptions
                | { encoding: "buffer" },
            ],
        ) => string | Buffer<ArrayBufferLike>;
        ReadStream: typeof ReadStream;
        readSync: (
            this: FSContext,
            ...args: [
                fd: number,
                buffer: ArrayBufferView<ArrayBufferLike>,
                offset: number,
                length: number,
                position?: null | ReadPosition,
            ],
        ) => number;
        readv: (
            this: FSContext,
            ...args: [
                fd: number,
                buffers: ArrayBufferView<ArrayBufferLike>[],
                position: number,
                cb: readvCb,
            ],
        ) => void;
        readvSync: (
            this: FSContext,
            ...args: [
                fd: number,
                buffers: readonly ArrayBufferView<ArrayBufferLike>[],
                position?: number,
            ],
        ) => number;
        realpath: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options: EncodingOption,
                cb: Callback<[string]>,
            ],
        ) => void;
        realpathSync: (
            this: FSContext,
            ...args: [path: PathLike, options?: EncodingOption],
        ) => string;
        rename: (
            this: FSContext,
            ...args: [oldPath: PathLike, newPath: PathLike, cb: Callback],
        ) => void;
        renameSync: (
            this: FSContext,
            ...args: [oldPath: PathLike, newPath: PathLike],
        ) => void;
        rm: (
            this: FSContext,
            ...args: [path: PathLike, options: RmOptions, callback: Callback],
        ) => void;
        rmdir: (this: FSContext, ...args: [path: PathLike, cb: Callback]) => void;
        rmdirSync: (this: FSContext, ...args: [path: PathLike]) => void;
        rmSync: (
            this: FSContext,
            ...args: [path: PathLike, options?: RmOptions],
        ) => void;
        stat: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options: StatOptions,
                callback: Callback<[Stats] | [BigIntStats]>,
            ],
        ) => void;
        statfs: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options: StatFsOptions & { bigint: true },
                callback: Callback<[BigIntStatsFs]>,
            ],
        ) => void;
        statfsSync: (
            this: FSContext,
            ...args: [path: PathLike, options?: StatFsOptions],
        ) => BigIntStatsFs | StatsFs;
        Stats: typeof Stats;
        StatsFs: typeof StatsFs;
        statSync: (
            this: FSContext,
            ...args: [path: PathLike, options: { bigint: true }],
        ) => BigIntStats;
        symlink: (
            this: FSContext,
            ...args: [target: PathLike, path: PathLike, type?: Type, cb?: Callback],
        ) => void;
        symlinkSync: (
            this: FSContext,
            ...args: [target: PathLike, path: PathLike, type: null | Type],
        ) => void;
        truncate: (
            this: FSContext,
            ...args: [path: PathLike, len: number, cb?: Callback],
        ) => void;
        truncateSync: (
            this: FSContext,
            ...args: [path: PathLike, len: null | number],
        ) => void;
        umount: (this: FSContext, ...args: [mountPoint: string]) => void;
        unlink: (this: FSContext, ...args: [path: PathLike, cb: Callback]) => void;
        unlinkSync: (this: FSContext, ...args: [path: PathLike]) => void;
        unwatchFile: (
            this: FSContext,
            ...args: [path: PathLike, listener: (curr: Stats, prev: Stats) => void],
        ) => void;
        utimes: (
            this: FSContext,
            ...args: [
                path: PathLike,
                atime: number
                | Date,
                mtime: number | Date,
                cb: Callback,
            ],
        ) => void;
        utimesSync: (
            this: FSContext,
            ...args: [
                path: PathLike,
                atime: string
                | number
                | Date,
                mtime: string | number | Date,
            ],
        ) => void;
        watch: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options: { persistent?: boolean },
                listener?: (event: string, filename: string) => any,
            ],
        ) => FSWatcher<string | Buffer<ArrayBufferLike>>;
        watchFile: (
            this: FSContext,
            ...args: [
                path: PathLike,
                options: { interval?: number; persistent?: boolean },
                listener: (curr: Stats, prev: Stats) => void,
            ],
        ) => void;
        write: (
            this: FSContext,
            ...args: [
                fd: number,
                data: FileContents,
                position: null
                | number,
                encoding: BufferEncoding,
                cb?: Callback<[number, string]>,
            ],
        ) => void;
        writeFile: (
            this: FSContext,
            ...args: [
                filename: PathLike,
                data: FileContents,
                options?: WriteFileOptions,
                cb?: Callback,
            ],
        ) => void;
        writeFileSync: (
            this: FSContext,
            ...args: [
                path: PathOrFileDescriptor,
                data: FileContents,
                encoding?: BufferEncoding,
            ],
        ) => void;
        WriteStream: typeof WriteStream;
        writeSync: (
            this: FSContext,
            ...args: [
                fd: number,
                data: string,
                position?: null
                | number,
                encoding?: null | BufferEncoding,
            ],
        ) => number;
        writev: (
            this: FSContext,
            ...args: [
                fd: number,
                buffers: Uint8Array<ArrayBufferLike>[],
                position: number,
                cb: writevCb,
            ],
        ) => void;
        writevSync: (
            this: FSContext,
            ...args: [
                fd: number,
                buffers: readonly ArrayBufferView<ArrayBufferLike>[],
                position?: number,
            ],
        ) => number;
        xattr: xattr;
    } & {
        promises: Bound<promises, FSContext>;
        xattr: Bound<xattr, FSContext>;
    };
    id: number;
    parent: FSContext;
    path: Bound<__module, FSContext>;
    pwd: string;
    root: string;
    bind(init: ContextInit): BoundContext;
}

Hierarchy (View Summary)

Properties

children: FSContext[]

The child contexts

credentials: Credentials

The credentials of the context, used for access checks

descriptors: Map<number, SyncHandle>

A map of open file descriptors to their handles

fs: fs & {
    access: (
        this: FSContext,
        ...args: [path: PathLike, mode: number, cb: Callback],
    ) => void;
    accessSync: (
        this: FSContext,
        ...args: [path: PathLike, mode: number],
    ) => void;
    appendFile: (
        this: FSContext,
        ...args: [
            filename: PathLike,
            data: FileContents,
            encoding?: BufferEncoding,
            cb?: Callback,
        ],
    ) => void;
    appendFileSync: (
        this: FSContext,
        ...args: [
            filename: PathOrFileDescriptor,
            data: FileContents,
            _options: WriteFileOptions,
        ],
    ) => void;
    BigIntStatsFs: typeof BigIntStatsFs;
    chmod: (
        this: FSContext,
        ...args: [path: PathLike, mode: string | number, cb: Callback],
    ) => void;
    chmodSync: (this: FSContext, ...args: [path: PathLike, mode: Mode]) => void;
    chown: (
        this: FSContext,
        ...args: [path: PathLike, uid: number, gid: number, cb: Callback],
    ) => void;
    chownSync: (
        this: FSContext,
        ...args: [path: PathLike, uid: number, gid: number],
    ) => void;
    chroot: (this: FSContext, ...args: [path: string]) => void;
    close: (this: FSContext, ...args: [fd: number, cb: Callback]) => void;
    closeSync: (this: FSContext, ...args: [fd: number]) => void;
    constants: constants;
    copyFile: (
        this: FSContext,
        ...args: [
            src: PathLike,
            dest: PathLike,
            flags: number,
            callback: Callback,
        ],
    ) => void;
    copyFileSync: (
        this: FSContext,
        ...args: [source: PathLike, destination: PathLike, flags?: number],
    ) => void;
    cp: (
        this: FSContext,
        ...args: [
            source: PathLike,
            destination: PathLike,
            opts: CopyOptions,
            callback: Callback,
        ],
    ) => void;
    cpSync: (
        this: FSContext,
        ...args: [source: PathLike, destination: PathLike, opts?: CopySyncOptions],
    ) => void;
    createReadStream: (
        this: FSContext,
        ...args: [path: PathLike, options?: BufferEncoding | ReadStreamOptions],
    ) => ReadStream;
    createWriteStream: (
        this: FSContext,
        ...args: [path: PathLike, options?: BufferEncoding | WriteStreamOptions],
    ) => WriteStream;
    Dir: typeof Dir;
    Dirent: typeof Dirent;
    exists: (
        this: FSContext,
        ...args: [path: PathLike, cb: (exists: boolean) => unknown],
    ) => void;
    existsSync: (this: FSContext, ...args: [path: PathLike]) => boolean;
    fchmod: (
        this: FSContext,
        ...args: [fd: number, mode: string | number, cb: Callback],
    ) => void;
    fchmodSync: (
        this: FSContext,
        ...args: [fd: number, mode: string | number],
    ) => void;
    fchown: (
        this: FSContext,
        ...args: [fd: number, uid: number, gid: number, cb: Callback],
    ) => void;
    fchownSync: (
        this: FSContext,
        ...args: [fd: number, uid: number, gid: number],
    ) => void;
    fdatasync: (this: FSContext, ...args: [fd: number, cb: Callback]) => void;
    fdatasyncSync: (this: FSContext, ...args: [fd: number]) => void;
    fstat: (
        this: FSContext,
        ...args: [
            fd: number,
            options: StatOptions & { bigint: true },
            cb: Callback<[BigIntStats]>,
        ],
    ) => void;
    fstatSync: (
        this: FSContext,
        ...args: [fd: number, options: { bigint: true }],
    ) => BigIntStats;
    fsync: (this: FSContext, ...args: [fd: number, cb: Callback]) => void;
    fsyncSync: (this: FSContext, ...args: [fd: number]) => void;
    ftruncate: (
        this: FSContext,
        ...args: [fd: number, len?: number, cb?: Callback],
    ) => void;
    ftruncateSync: (
        this: FSContext,
        ...args: [fd: number, len: null | number],
    ) => void;
    futimes: (
        this: FSContext,
        ...args: [
            fd: number,
            atime: number
            | Date,
            mtime: number | Date,
            cb: Callback,
        ],
    ) => void;
    futimesSync: (
        this: FSContext,
        ...args: [
            fd: number,
            atime: string
            | number
            | Date,
            mtime: string | number | Date,
        ],
    ) => void;
    glob: (
        this: FSContext,
        ...args: [
            pattern: string
            | string[],
            options: GlobOptions,
            callback: GlobCallback<[string[] | Dirent[]]>,
        ],
    ) => void;
    globSync: (
        this: FSContext,
        ...args: [pattern: string | string[], options: GlobOptions],
    ) => string[] | Dirent[];
    IOC: typeof IOC;
    IOC32: typeof IOC32;
    ioctl: (this: FSContext, ...args: never) => Promise<any>;
    ioctlSync: (this: FSContext, ...args: never) => any;
    lchmod: (
        this: FSContext,
        ...args: [path: PathLike, mode: string | number, cb: Callback],
    ) => void;
    lchmodSync: (
        this: FSContext,
        ...args: [path: PathLike, mode: string | number],
    ) => void;
    lchown: (
        this: FSContext,
        ...args: [path: PathLike, uid: number, gid: number, cb: Callback],
    ) => void;
    lchownSync: (
        this: FSContext,
        ...args: [path: PathLike, uid: number, gid: number],
    ) => void;
    link: (
        this: FSContext,
        ...args: [existing: PathLike, newpath: PathLike, cb: Callback],
    ) => void;
    linkSync: (
        this: FSContext,
        ...args: [targetPath: PathLike, linkPath: PathLike],
    ) => void;
    lopenSync: (
        this: FSContext,
        ...args: [path: PathLike, flag: string, mode?: null | Mode],
    ) => number;
    lstat: (
        this: FSContext,
        ...args: [
            path: PathLike,
            options: StatOptions,
            callback: Callback<[Stats | BigIntStats]>,
        ],
    ) => void;
    lstatSync: (
        this: FSContext,
        ...args: [path: PathLike, options: { bigint: true }],
    ) => BigIntStats;
    lutimes: (
        this: FSContext,
        ...args: [
            path: PathLike,
            atime: number
            | Date,
            mtime: number | Date,
            cb: Callback,
        ],
    ) => void;
    lutimesSync: (
        this: FSContext,
        ...args: [
            path: PathLike,
            atime: string
            | number
            | Date,
            mtime: string | number | Date,
        ],
    ) => void;
    mkdir: (
        this: FSContext,
        ...args: [path: PathLike, mode?: Mode, cb: Callback],
    ) => void;
    mkdirSync: (
        this: FSContext,
        ...args: [path: PathLike, options?: null | Mode | MakeDirectoryOptions],
    ) => undefined | string;
    mkdtemp: (
        this: FSContext,
        ...args: [
            prefix: string,
            options: BufferEncodingOption,
            callback: Callback<[Buffer<ArrayBufferLike>]>,
        ],
    ) => void;
    mkdtempSync: (
        this: FSContext,
        ...args: [prefix: string, options?: EncodingOption],
    ) => string;
    mount: (
        this: FSContext,
        ...args: [mountPoint: string, fs: FileSystem],
    ) => void;
    open: (
        this: FSContext,
        ...args: [
            path: PathLike,
            flag: OpenMode,
            mode: string
            | number,
            cb?: Callback<[number]>,
        ],
    ) => void;
    openAsBlob: (
        this: FSContext,
        ...args: [path: PathLike, options?: OpenAsBlobOptions],
    ) => Promise<Blob>;
    opendir: (
        this: FSContext,
        ...args: [path: PathLike, options: OpenDirOptions, cb: Callback<[Dir]>],
    ) => void;
    opendirSync: (
        this: FSContext,
        ...args: [path: PathLike, options?: OpenDirOptions],
    ) => Dir;
    openSync: (
        this: FSContext,
        ...args: [path: PathLike, flag: OpenMode, mode: null | Mode],
    ) => number;
    promises: promises;
    read: (
        this: FSContext,
        ...args: [
            fd: number,
            buffer: Uint8Array<ArrayBufferLike>,
            offset: number,
            length: number,
            position?: number,
            cb: Callback<[number, Uint8Array<ArrayBufferLike>]>,
        ],
    ) => void;
    readdir: (
        this: FSContext,
        ...args: [
            path: PathLike,
            options: { withFileTypes: true },
            cb: Callback<[Dirent[]]>,
        ],
    ) => void;
    readdirSync: (
        this: FSContext,
        ...args: [
            path: PathLike,
            options?: | null
            | "ascii"
            | "utf8"
            | "utf-8"
            | "utf16le"
            | "utf-16le"
            | "ucs2"
            | "ucs-2"
            | "base64"
            | "base64url"
            | "latin1"
            | "binary"
            | "hex"
            | ReaddirOptions & ObjectEncodingOptions
            | ReaddirOptions & "buffer"
            | ReaddirOptions & { encoding: "buffer" },
        ],
    ) => string[] | Buffer<ArrayBufferLike>[] | Dirent[];
    readFile: (
        this: FSContext,
        ...args: [
            filename: PathLike,
            options: BufferEncoding
            | { encoding: BufferEncoding; flag?: string },
            cb: Callback<[string]>,
        ],
    ) => void;
    readFileSync: (
        this: FSContext,
        ...args: [
            path: PathOrFileDescriptor,
            options?: | null
            | BufferEncoding
            | (EncodingOption & { flag?: string | undefined; }),
        ],
    ) => string;
    readlink: (
        this: FSContext,
        ...args: [
            path: PathLike,
            options: EncodingOption,
            callback: Callback<[string]>,
        ],
    ) => void;
    readlinkSync: (
        this: FSContext,
        ...args: [
            path: PathLike,
            options?: | null
            | "buffer"
            | "ascii"
            | "utf8"
            | "utf-8"
            | "utf16le"
            | "utf-16le"
            | "ucs2"
            | "ucs-2"
            | "base64"
            | "base64url"
            | "latin1"
            | "binary"
            | "hex"
            | ObjectEncodingOptions
            | { encoding: "buffer" },
        ],
    ) => string | Buffer<ArrayBufferLike>;
    ReadStream: typeof ReadStream;
    readSync: (
        this: FSContext,
        ...args: [
            fd: number,
            buffer: ArrayBufferView<ArrayBufferLike>,
            offset: number,
            length: number,
            position?: null | ReadPosition,
        ],
    ) => number;
    readv: (
        this: FSContext,
        ...args: [
            fd: number,
            buffers: ArrayBufferView<ArrayBufferLike>[],
            position: number,
            cb: readvCb,
        ],
    ) => void;
    readvSync: (
        this: FSContext,
        ...args: [
            fd: number,
            buffers: readonly ArrayBufferView<ArrayBufferLike>[],
            position?: number,
        ],
    ) => number;
    realpath: (
        this: FSContext,
        ...args: [path: PathLike, options: EncodingOption, cb: Callback<[string]>],
    ) => void;
    realpathSync: (
        this: FSContext,
        ...args: [path: PathLike, options?: EncodingOption],
    ) => string;
    rename: (
        this: FSContext,
        ...args: [oldPath: PathLike, newPath: PathLike, cb: Callback],
    ) => void;
    renameSync: (
        this: FSContext,
        ...args: [oldPath: PathLike, newPath: PathLike],
    ) => void;
    rm: (
        this: FSContext,
        ...args: [path: PathLike, options: RmOptions, callback: Callback],
    ) => void;
    rmdir: (this: FSContext, ...args: [path: PathLike, cb: Callback]) => void;
    rmdirSync: (this: FSContext, ...args: [path: PathLike]) => void;
    rmSync: (
        this: FSContext,
        ...args: [path: PathLike, options?: RmOptions],
    ) => void;
    stat: (
        this: FSContext,
        ...args: [
            path: PathLike,
            options: StatOptions,
            callback: Callback<[Stats] | [BigIntStats]>,
        ],
    ) => void;
    statfs: (
        this: FSContext,
        ...args: [
            path: PathLike,
            options: StatFsOptions & { bigint: true },
            callback: Callback<[BigIntStatsFs]>,
        ],
    ) => void;
    statfsSync: (
        this: FSContext,
        ...args: [path: PathLike, options?: StatFsOptions],
    ) => BigIntStatsFs | StatsFs;
    Stats: typeof Stats;
    StatsFs: typeof StatsFs;
    statSync: (
        this: FSContext,
        ...args: [path: PathLike, options: { bigint: true }],
    ) => BigIntStats;
    symlink: (
        this: FSContext,
        ...args: [target: PathLike, path: PathLike, type?: Type, cb?: Callback],
    ) => void;
    symlinkSync: (
        this: FSContext,
        ...args: [target: PathLike, path: PathLike, type: null | Type],
    ) => void;
    truncate: (
        this: FSContext,
        ...args: [path: PathLike, len: number, cb?: Callback],
    ) => void;
    truncateSync: (
        this: FSContext,
        ...args: [path: PathLike, len: null | number],
    ) => void;
    umount: (this: FSContext, ...args: [mountPoint: string]) => void;
    unlink: (this: FSContext, ...args: [path: PathLike, cb: Callback]) => void;
    unlinkSync: (this: FSContext, ...args: [path: PathLike]) => void;
    unwatchFile: (
        this: FSContext,
        ...args: [path: PathLike, listener: (curr: Stats, prev: Stats) => void],
    ) => void;
    utimes: (
        this: FSContext,
        ...args: [
            path: PathLike,
            atime: number
            | Date,
            mtime: number | Date,
            cb: Callback,
        ],
    ) => void;
    utimesSync: (
        this: FSContext,
        ...args: [
            path: PathLike,
            atime: string
            | number
            | Date,
            mtime: string | number | Date,
        ],
    ) => void;
    watch: (
        this: FSContext,
        ...args: [
            path: PathLike,
            options: { persistent?: boolean },
            listener?: (event: string, filename: string) => any,
        ],
    ) => FSWatcher<string | Buffer<ArrayBufferLike>>;
    watchFile: (
        this: FSContext,
        ...args: [
            path: PathLike,
            options: { interval?: number; persistent?: boolean },
            listener: (curr: Stats, prev: Stats) => void,
        ],
    ) => void;
    write: (
        this: FSContext,
        ...args: [
            fd: number,
            data: FileContents,
            position: null
            | number,
            encoding: BufferEncoding,
            cb?: Callback<[number, string]>,
        ],
    ) => void;
    writeFile: (
        this: FSContext,
        ...args: [
            filename: PathLike,
            data: FileContents,
            options?: WriteFileOptions,
            cb?: Callback,
        ],
    ) => void;
    writeFileSync: (
        this: FSContext,
        ...args: [
            path: PathOrFileDescriptor,
            data: FileContents,
            encoding?: BufferEncoding,
        ],
    ) => void;
    WriteStream: typeof WriteStream;
    writeSync: (
        this: FSContext,
        ...args: [
            fd: number,
            data: string,
            position?: null
            | number,
            encoding?: null | BufferEncoding,
        ],
    ) => number;
    writev: (
        this: FSContext,
        ...args: [
            fd: number,
            buffers: Uint8Array<ArrayBufferLike>[],
            position: number,
            cb: writevCb,
        ],
    ) => void;
    writevSync: (
        this: FSContext,
        ...args: [
            fd: number,
            buffers: readonly ArrayBufferView<ArrayBufferLike>[],
            position?: number,
        ],
    ) => number;
    xattr: xattr;
} & { promises: Bound<promises, FSContext>; xattr: Bound<xattr, FSContext> }
id: number

The unique ID of the context

parent: FSContext

The parent context, if any.

path: Bound<__module, FSContext>

Path functions, bound to the context

pwd: string

The current working directory of the context

root: string

The absolute root path of the context

Note the parent's root is not considered

Methods