Class SyncKeyValueFileSystem

A "Synchronous key-value file system". Stores data to/retrieves data from an underlying key-value store.

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

Todo

Introduce Node ID caching.

Todo

Check modes.

Hierarchy

Constructors

Properties

_ready: Promise<SyncKeyValueFileSystem> = ...
Name: string = ...

Accessors

Methods

  • Helper function for findINode.

    Parameters

    • tx: SyncKeyValueROTransaction
    • 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 string

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

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

    Parameters

    Returns string

    The GUID that the data was stored under.

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

    Parameters

    • tx: SyncKeyValueRWTransaction
    • p: 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.

    • cred: Cred
    • data: Uint8Array

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

    Returns default

    The Inode for the new file.

  • Test whether or not the given path exists by checking with the file system. Then call the callback argument with either true or false.

    Parameters

    • p: string
    • cred: Cred

    Returns Promise<boolean>

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

    Parameters

    Returns {
        [fileName: string]: string;
    }

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

    Parameters

    • tx: SyncKeyValueROTransaction

      The transaction to use.

    • p: string

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

    • id: string

      The ID to look up.

    Returns default

  • Asynchronous mkdir.

    Parameters

    • p: string
    • mode: number

      Mode to make the directory using. Can be ignored if the filesystem doesn't support permissions.

    • cred: Cred

    Returns Promise<void>

  • Asynchronous readdir. Reads the contents of a directory.

    The callback gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.

    Parameters

    • p: string
    • cred: Cred

    Returns Promise<string[]>

  • Asynchronous realpath. The callback gets two arguments (err, resolvedPath).

    Note that the Node API will resolve path to an absolute path.

    Parameters

    • p: string
    • cred: Cred

    Returns Promise<string>

  • Remove all traces of the given path from the file system.

    Parameters

    • p: string

      The path to remove from the file system.

    • isDir: boolean

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

    • cred: Cred

    Returns void

    Todo

    Update mtime.

  • Asynchronous rename. No arguments other than a possible exception are given to the completion callback.

    Parameters

    • oldPath: string
    • newPath: string
    • cred: Cred

    Returns Promise<void>

  • Asynchronous symlink.

    Parameters

    • srcpath: string
    • dstpath: string
    • type: string

      can be either 'dir' or 'file'

    • cred: Cred

    Returns Promise<void>

  • Change file timestamps of the file referenced by the supplied path.

    Parameters

    • p: string
    • atime: Date
    • mtime: Date
    • cred: Cred

    Returns Promise<void>

  • Asynchronously writes data to a file, replacing the file if it already exists.

    The encoding option is ignored if data is a buffer.

    Parameters

    • fname: string
    • data: Uint8Array
    • flag: FileFlag
    • mode: number
    • cred: Cred

    Returns Promise<void>

  • Synchronously writes data to a file, replacing the file if it already exists.

    The encoding option is ignored if data is a buffer.

    Parameters

    • fname: string
    • data: Uint8Array
    • flag: FileFlag
    • mode: number
    • cred: Cred

    Returns void

Generated using TypeDoc