Options
All
  • Public
  • Public/Protected
  • All
Menu

File system utilizing local storage as a storage backing.

LocalStorageFS has the same feature set as the IndexedFileSystem, with the exception that all writes are synchronous and blocking, due to the use of localStorage. Base64 has been used to represent binary data, as binary strings are not properly encoded/decoded with the default TextEncoder/TextDecoder API.

Hierarchy

Index

Constructors

constructor

  • new LocalStorageFileSystem(prefix: string): any

Properties

_fileTable

_fileTable: { /: { dateAccessed: Number; dateCreated: Number; dateModified: Number; length: Number; readOnly: Boolean; recordId: String; type: Number } }

Type declaration

  • /: { dateAccessed: Number; dateCreated: Number; dateModified: Number; length: Number; readOnly: Boolean; recordId: String; type: Number }
    • dateAccessed: Number
    • dateCreated: Number
    • dateModified: Number
    • length: Number
    • readOnly: Boolean
    • recordId: String
    • type: Number

_fsSort

_fsSort: boolean

driverName

driverName: "idbfs"

The unique driver name.

features

features: []

An array which contains the supported file system features.

prefix

prefix: string

The prefix (aka drive letter) for the current file system instance.

This is managed by the OS.

remote

remote: boolean

Whether the file system has resources to be accessed remotely.

store

Storage backing store.

volumeLabel

volumeLabel: string

The volume label.

Methods

_fTableExists

  • _fTableExists(path: string): Boolean
  • Check if an entity exists in the file table.

    Parameters

    • path: string

      The path to check for.

    Returns Boolean

_getItem

  • _getItem(_k: String): Promise<Uint8Array>
  • Retrieves a value from the specified IDB key.

    Parameters

    • _k: String

      The key to retrieve.

    Returns Promise<Uint8Array>

_intmkf

  • _intmkf(): Promise<boolean>
  • [undocumented function] unsafe mkdir.

    Returns Promise<boolean>

_pauseSync

  • _pauseSync(): void

_pushFtableRecord

  • _pushFtableRecord(path: String, size: Number, type: Number, readOnly: Boolean): void
  • Pushes a file table record.

    Parameters

    • path: String

      The path of the entity to push.

    • size: Number

      The entity size.

    • type: Number

      The entity type.

    • readOnly: Boolean

      Whether the entity is read only.

    Returns void

_resumeSync

  • _resumeSync(): void

_setItem

  • _setItem(k: String, v: any): void
  • Sets a key value in IDB.

    Parameters

    • k: String

      The key to use.

    • v: any

      The value to set.

    Returns void

_sync

  • _sync(): Promise<void>
  • Syncs the file table to IDB.

    Returns Promise<void>

cpdir

  • cpdir(src: string, dest: string): Promise<boolean>
  • Copies a directory to a new destination.

    Parameters

    • src: string

      The source path to copy from.

    • dest: string

      The destination path to place copied files.

    Returns Promise<boolean>

cpfile

  • cpfile(src: string, dest: string): Promise<boolean>
  • Copies a file to a new destination.

    Parameters

    • src: string

      The source path to copy from.

    • dest: string

      The destination path to place the copied file.

    Returns Promise<boolean>

exists

  • exists(path: string): boolean
  • Checks if an entity exists.

    Parameters

    • path: string

      The path to check for.

    Returns boolean

filetype

  • filetype(path: string): 0 | 1 | -1
  • Returns the file type of a node. This can be a binary or text file.

    Parameters

    • path: string

      The path to check for.

    Returns 0 | 1 | -1

    A number representing the file type.

init

  • init(): Promise<void>
  • Initializes the file system.

    Returns Promise<void>

isEmpty

  • isEmpty(path: string): Promise<boolean>
  • Checks if a file is empty.

    Parameters

    • path: string

      The path to check for.

    Returns Promise<boolean>

isFile

  • isFile(path: string): Promise<boolean>
  • Checks if the specified entity is a file.

    Parameters

    • path: string

      The path to check for.

    Returns Promise<boolean>

mkdir

  • mkdir(path: string): Promise<boolean>
  • Creates a new directory (and subdirectories if they do not exist).

    Parameters

    • path: string

      The path of the directory to create.

    Returns Promise<boolean>

mvdir

  • mvdir(src: string, dest: string): Promise<boolean>
  • Moves a directory to a new destination.

    Parameters

    • src: string

      The source path to move from.

    • dest: string

      The destination path to place moved files.

    Returns Promise<boolean>

mvfile

  • mvfile(src: string, dest: string): Promise<boolean>
  • Moves a file to a new destination.

    Parameters

    • src: string

      The source path to move from.

    • dest: string

      The destination path to place the moved file.

    Returns Promise<boolean>

readbin

  • readbin(path: string): Promise<Uint8Array>
  • Reads the specified file as binary.

    Parameters

    • path: string

      The path of the file to read.

    Returns Promise<Uint8Array>

readdir

  • readdir(path: string): string[]
  • Returns a list of entities contained in the specified path.

    Parameters

    • path: string

      The directory path to read.

    Returns string[]

readstr

  • readstr(path: string): Promise<string>
  • Reads the specified file as a string.

    Parameters

    • path: string

      The path of the file to read.

    Returns Promise<string>

rm

  • rm(path: string): Promise<boolean>
  • Deletes the specified file.

    Parameters

    • path: string

      The path of the file to remove.

    Returns Promise<boolean>

rmdir

  • rmdir(path: string): Promise<boolean>
  • Removes a directory and its contents.

    Parameters

    • path: string

      The path of the directory to remove.

    Returns Promise<boolean>

stat

  • Retrieves information about a file system entry.

    Parameters

    • path: string

      The path to retrieve information for.

    Returns Promise<FSBasicStat>

touch

  • touch(path: string): Promise<boolean>
  • Creates a new file.

    Parameters

    • path: string

      The path of the file to create.

    Returns Promise<boolean>

uninit

  • uninit(): Promise<void>
  • Called when the file system is being unmounted.

    Returns Promise<void>

writebin

  • writebin(path: string, data: Uint8Array | number[]): Promise<boolean>
  • Truncates and writes data to the specified file.

    Parameters

    • path: string

      The path of the file to write to.

    • data: Uint8Array | number[]

      The data to write.

    Returns Promise<boolean>

writestr

  • writestr(path: string, data: string): Promise<boolean>
  • Truncates and writes a UTF-8 encoded string to the specified file.

    Parameters

    • path: string

      The path of the file to write to.

    • data: string

      The string to write.

    Returns Promise<boolean>

Generated using TypeDoc