A FileHandle object is a wrapper for a numeric file descriptor. Instances of FileHandle are distinct from numeric file descriptors in that they provide an object oriented API for working with files.

Constructors

Accessors

Methods

  • Asynchronously append the given contents to a file.

    The underlying file will not be closed automatically.

    It is unsafe to call appendFile() multiple times on the same file without waiting for the Promise to be resolved (or rejected).

    Parameters

    • data: ArrayBufferView

    Returns Promise<void>

  • Asynchronously append the given contents to a file.

    The underlying file will not be closed automatically.

    It is unsafe to call appendFile() multiple times on the same file without waiting for the Promise to be resolved (or rejected).

    Parameters

    Returns Promise<void>

  • Parameters

    • mode: string | number

    Returns Promise<void>

  • Parameters

    • uid: number
    • gid: number

    Returns Promise<void>

  • Asynchronously reads data from the file.

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • buffer: TBuffer

      The buffer that the data will be written to.

    • offset: number

      The offset in the buffer at which to start writing.

    • length: number

      The number of bytes to read.

    • position: null | number = null

      The offset from the beginning of the file from which data should be read. If null, data will be read from the current position.

    Returns Promise<{
        buffer: TBuffer;
        bytesRead: number;
    }>

  • Asynchronously reads the entire contents of a file.

    The underlying file will not be closed automatically.

    Returns Promise<Buffer>

  • Asynchronously reads the entire contents of a file.

    The underlying file will not be closed automatically.

    Parameters

    Returns Promise<string>

  • Parameters

    • Optionallength: number

    Returns Promise<void>

  • Parameters

    • atime: string | number | Date
    • mtime: string | number | Date

    Returns Promise<void>

  • Asynchronously writes the given data to this file.

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • buffer: TBuffer

      The data to write.

    • Optionaloffset: number

      The part of the buffer to be written. If not supplied, defaults to 0.

    • Optionallength: number

      The number of bytes to write. If not supplied, defaults to buffer.length - offset.

    • Optionalposition: number

      The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

    Returns Promise<{
        buffer: TBuffer;
        bytesWritten: number;
    }>

  • Asynchronously writes the given contents to a file, replacing any old contents.

    The underlying file will not be closed automatically.

    It is unsafe to call writeFile() multiple times on the same file without waiting for the Promise to be resolved (or rejected).

    Parameters

    • data: ArrayBufferView

    Returns Promise<void>

  • Asynchronously writes the given contents to a file, replacing any old contents.

    The underlying file will not be closed automatically.

    It is unsafe to call writeFile() multiple times on the same file without waiting for the Promise to be resolved (or rejected).

    Parameters

    Returns Promise<void>