Interface FileHandle

interface FileHandle {
    path: string;
    readable: ReadableStream<Uint8Array>;
    writable: WritableStream<Uint8Array>;
    chmod(mode: number): Promise<void>;
    close(): Promise<void>;
    datasync(): Promise<void>;
    read(buffer: Uint8Array, offset?: number): Promise<number>;
    stat(): Promise<StatResult>;
    sync(): Promise<void>;
    truncate(offset?: number): Promise<void>;
    utime(atime: Date, mtime: Date): Promise<void>;
    write(buffer: Uint8Array, offset?: number): Promise<number>;
}

Properties

path: string

The file path.

readable: ReadableStream<Uint8Array>
writable: WritableStream<Uint8Array>

Methods

  • Change permissions of the file. See fchmod(2)

    Parameters

    • mode: number

      The file mode consisting of permission, suid, sgid, and sticky bits.

    Returns Promise<void>

  • Closes the file.

    Returns Promise<void>

  • Returns Promise<void>

  • Reads data into the given buffer at the given file offset. Returns the amount of read data or null for EOF.

    Parameters

    • buffer: Uint8Array

      Buffer to read data into.

    • Optionaloffset: number

      Offset in the file to read from.

    Returns Promise<number>

  • Returns Promise<void>

  • Truncates the file to the given length.

    Parameters

    • Optionaloffset: number

      Length to truncate the file to.

    Returns Promise<void>

  • Change the access and modification time of the file. See futimes(2)

    Parameters

    • atime: Date

      The new file access time.

    • mtime: Date

      The new file modification time.

    Returns Promise<void>

  • Writes data from the given buffer at the given file offset. Returns the amount of data written.

    Parameters

    • buffer: Uint8Array

      Buffer to write.

    • Optionaloffset: number

      Offset in the file to write to.

    Returns Promise<number>