Class DeviceFile

The base class for device files This class only does some simple things: It implements truncate using write and it has non-device methods throw. It is up to device drivers to implement the rest of the functionality.

Hierarchy (view full)

Constructors

Properties

device: Device<any>

The file system that created the file

path: string
position: number = 0

Get the current file position.

Accessors

Methods

  • Default implementation maps to sync.

    Returns Promise<void>

  • Read data from the file.

    Type Parameters

    • TBuffer extends ArrayBufferView

    Parameters

    • buffer: TBuffer

      The buffer that the data will be written to.

    • Optionaloffset: number

      The offset within the buffer where writing will start.

    • Optionallength: number

      An integer specifying the number of bytes to read.

    Returns Promise<FileReadResult<TBuffer>>

    Promise resolving to the new length of the buffer

  • Read data from the file.

    Parameters

    • buffer: ArrayBufferView

      The buffer that the data will be written to.

    • Optionaloffset: number

      The offset within the buffer where writing will start.

    • Optionallength: number

      An integer specifying the number of bytes to read.

    • Optionalposition: number

      An integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position.

    Returns number

  • Write buffer to the file.

    Parameters

    • buffer: Uint8Array

      Uint8Array containing the data to write to the file.

    • Optionaloffset: number

      Offset in the buffer to start reading data from.

    • Optionallength: number

      The amount of bytes to write to the file.

    • Optionalposition: number

      Offset from the beginning of the file where this data should be written. If position is null, the data will be written at the current position.

    Returns Promise<number>

    Promise resolving to the new length of the buffer

  • Write buffer to the file.

    Parameters

    • buffer: Uint8Array

      Uint8Array containing the data to write to the file.

    • offset: number = 0

      Offset in the buffer to start reading data from.

    • length: number = buffer.length

      The amount of bytes to write to the file.

    • Optionalposition: number

      Offset from the beginning of the file where this data should be written. If position is null, the data will be written at the current position.

    Returns number