Options
All
  • Public
  • Public/Protected
  • All
Menu

Class VirtualFileSystem

Create a JavaScript virtual file system in memory.

Hierarchy

  • VirtualFileSystem

Index

Constructors

constructor

Properties

Private Readonly adapter

adapter: Adapter

The file system adapter for this instance.

Private Readonly rmCache

rmCache: Map<string, ItemType>

An internal cache of paths removed from root.

Private Readonly root

root: Root

The root of the file system tree.

Accessors

separator

  • get separator(): "/"

Methods

Private addRmCache

  • addRmCache(path: string, type: ItemType): void

commit

  • commit(): Promise<void>

delete

  • delete(path: string): boolean
  • Delete a file; if the target is a hardlink, also deletes the link contents. Returns false if the item does not exist.

    Parameters

    • path: string

    Returns boolean

exists

  • exists(path: string): boolean

Private isRmCached

  • isRmCached(path: string): boolean

link

  • link(from: string, to: string, type?: LinkType): boolean

mkdir

  • mkdir(path: string): void

read

  • read(path: string): Promise<Buffer>
  • Read the contents of a file. If the adapter supports pass-through read, the file will be read from persistent storage if it is not in the virtual dile system.

    Parameters

    • path: string

    Returns Promise<Buffer>

readdir

  • readdir(path: string): string[]
  • readdir(path: string, long: true): Item[]
  • readdir(path: string, long: boolean): string[] | Item[]

rmdir

  • rmdir(path: string): boolean
  • Remove a directory and it's contents. If the path is a folder link, both the link and the link target will be removed.

    Parameters

    • path: string

    Returns boolean

snapshot

  • snapshot(): Promise<void>

unlink

  • unlink(path: string): boolean

write

  • write(path: string, contents?: string | String | Buffer, append?: boolean): void
  • Write the contents of a file; creating directories in the tree as needed. Optionally append to the file.

    Parameters

    • path: string
    • Optional contents: string | String | Buffer
    • append: boolean = false

    Returns void

Generated using TypeDoc