Class StoreFS<T>Internal

A file system which uses a key-value store.

We use a unique ID for each node in the file system. The root node has a fixed ID.

Introduce Node ID caching.

Check modes.

Type Parameters

Hierarchy (view full)

Constructors

Properties

_disableSync?: boolean

Whether the sync cache should be disabled. Only affects async things.

store: T

Methods

  • Helper function for findINode.

    Parameters

    • tx: Transaction<Store>
    • parent: string

      The parent directory of the file we are attempting to find.

    • filename: string

      The filename of the inode we are attempting to find, minus the parent.

    • visited: Set<string> = ...

    Returns bigint

    string The ID of the file's inode in the file system.

  • Creates a new node under a random ID. Retries before giving up in the exceedingly unlikely chance that we try to reuse a random ino.

    Parameters

    Returns bigint

    The ino that the data was stored under.

  • Checks if the root directory exists. Creates it if it doesn't.

    Returns Promise<void>

  • Commits a new file (well, a FILE or a DIRECTORY) to the file system with mode. Note: This will commit the transaction.

    Parameters

    • path: string

      The path to the new file.

    • type: FileType

      The type of the new file.

    • mode: number

      The mode to create the new file with.

    • data: Uint8Array = ...

      The data to store at the file's data node.

    Returns Inode

    The Inode for the new file.

  • Delete all contents stored in the file system.

    Returns Promise<void>

  • Given the Inode of a directory, retrieves the corresponding directory listing.

    Parameters

    Returns {
        [fileName: string]: Ino;
    }

    • [fileName: string]: Ino
  • Given the ID of a node, retrieves the corresponding Inode.

    Parameters

    • tx: Transaction<Store>

      The transaction to use.

    • id: bigint

      The ID to look up.

    • path: string

      The corresponding path to the file (used for error messages).

    Returns Inode

  • Opens the file at path with flag. The file must exist.

    Parameters

    • path: string

      The path to open.

    • flag: string

      The flag to use when opening the file.

    Returns Promise<File>

  • Remove all traces of path from the file system.

    Parameters

    • path: string

      The path to remove from the file system.

    • isDir: boolean

      Does the path belong to a directory, or a file?

    Returns void

    Update mtime.

  • Updated the inode and data node at path

    Parameters

    • path: string
    • data: Uint8Array
    • stats: Readonly<Stats>

    Returns Promise<void>

    Ensure mtime updates properly, and use that to determine if a data update is required.

  • Updated the inode and data node at path

    Parameters

    • path: string
    • data: Uint8Array
    • stats: Readonly<Stats>

    Returns void

    Ensure mtime updates properly, and use that to determine if a data update is required.