Class AsyncKeyValueFile

An implementation of the File interface that operates on a file that is completely in-memory. PreloadFiles are backed by a Uint8Array.

This is also an abstract class, as it lacks an implementation of 'sync' and 'close'. Each filesystem that wishes to use this file representation must extend this class and implement those two methods.

Todo

'close' lever that disables functionality once closed.

Hierarchy

Implements

Constructors

Properties

_buffer: Uint8Array
_dirty: boolean = false
_flag: FileFlag
_path: string
_pos: number = 0
_stat: Stats

Methods

  • Advance the current file position by the indicated number of positions.

    Parameters

    • delta: number

    Returns number

  • NONSTANDARD: Get the underlying buffer for this file. !!DO NOT MUTATE!! Will mess up dirty tracking.

    Returns Uint8Array

  • Get the current file position.

    We emulate the following bug mentioned in the Node documentation:

    On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file.

    Returns number

    [Number] The current file position.

  • Read data from the file.

    Parameters

    • buffer: Uint8Array
    • offset: number
    • length: number
    • position: number

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

  • Read data from the file.

    Parameters

    • buffer: Uint8Array
    • offset: number
    • length: number
    • position: number

    Returns number

    [Number]

  • Resets the dirty bit. Should only be called after a sync has completed successfully.

    Returns void

  • Optional: Change the file timestamps of the file.

    Parameters

    • atime: Date
    • mtime: Date

    Returns Promise<void>

  • Write buffer to the file. Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback.

    Parameters

    • buffer: Uint8Array
    • offset: number
    • length: number
    • position: number

    Returns Promise<number>

  • Write buffer to the file. Note that it is unsafe to use fs.writeSync multiple times on the same file without waiting for the callback.

    Parameters

    • buffer: Uint8Array
    • offset: number
    • length: number
    • position: number

    Returns number

    [Number]

Generated using TypeDoc