Options
All
  • Public
  • Public/Protected
  • All
Menu

The MountableFileSystem allows you to mount multiple backend types or multiple instantiations of the same backend into a single file system tree. The file systems do not need to know about each other; all interactions are automatically facilitated through this interface.

For example, if a file system is mounted at /mnt/blah, and a request came in for /mnt/blah/foo.txt, the file system would see a request for /foo.txt.

You can mount file systems when you configure the file system:

BrowserFS.configure({
  fs: "MountableFileSystem",
  options: {
    '/data': { fs: 'XmlHttpRequest', options: { index: "http://mysite.com/files/index.json" } },
    '/home': { fs: 'LocalStorage' }
  }
}, function(e) {

});

For advanced users, you can also mount file systems after MFS is constructed:

BrowserFS.FileSystem.XmlHttpRequest.Create({
  index: "http://mysite.com/files/index.json"
}, function(e, xhrfs) {
  BrowserFS.FileSystem.MountableFileSystem.Create({
    '/data': xhrfs
  }, function(e, mfs) {
    BrowserFS.initialize(mfs);

    // Added after-the-fact...
    BrowserFS.FileSystem.LocalStorage.Create(function(e, lsfs) {
      mfs.mount('/home', lsfs);
    });
  });
});

Since MountableFileSystem simply proxies requests to mounted file systems, it supports all of the operations that the mounted file systems support.

With no mounted file systems, MountableFileSystem acts as a simple InMemory filesystem.

Hierarchy

Implements

Index

Constructors

constructor

Methods

_getFs

  • _getFs(path: string): object

appendFile

appendFileSync

  • appendFileSync(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number): void

chmod

chmodSync

  • chmodSync(p: string, isLchmod: boolean, mode: number): void

chown

  • chown(p: string, isLchown: boolean, uid: number, gid: number, cb: BFSOneArgCallback): void

chownSync

  • chownSync(p: string, isLchown: boolean, uid: number, gid: number): void

createFile

createFileSync

  • createFileSync(p: string, flag: FileFlag, mode: number): File

diskSpace

  • diskSpace(path: string, cb: function): void

exists

  • exists(p: string, cb: function): void

existsSync

  • existsSync(p: string): boolean

getName

  • getName(): string

isReadOnly

  • isReadOnly(): boolean

link

linkSync

  • linkSync(srcpath: string, dstpath: string): void

mkdir

mkdirSync

  • mkdirSync(p: string, mode: number): void

mount

open

openFile

openFileSync

  • openFileSync(p: string, flag: FileFlag, mode: number): File
  • Opens the file at path p with the given flag. The file must exist.

    Parameters

    • p: string

      The path to open.

    • flag: FileFlag

      The flag to use when opening the file.

    • mode: number

    Returns File

    A File object corresponding to the opened file.

openSync

readFile

  • readFile(fname: string, encoding: string | null, flag: FileFlag, cb: BFSCallback<string | Buffer>): void

readFileSync

  • readFileSync(fname: string, encoding: string | null, flag: FileFlag): any

readdir

readdirSync

  • readdirSync(p: string): string[]

readlink

readlinkSync

  • readlinkSync(p: string): string

realpath

  • realpath(p: string, cache: object, cb: BFSCallback<string>): void

realpathSync

  • realpathSync(p: string, cache: object): string

rename

renameSync

  • renameSync(oldPath: string, newPath: string): void

rmdir

rmdirSync

  • rmdirSync(p: string): void

standardizeError

  • Fixes up error messages so they mention the mounted file location relative to the MFS root, not to the particular FS's root. Mutates the input error, and returns it.

    Parameters

    • err: ApiError
    • path: string
    • realPath: string

    Returns ApiError

stat

statSync

  • statSync(p: string, isLstat: boolean | null): Stats

supportsLinks

  • supportsLinks(): boolean

supportsProps

  • supportsProps(): boolean

supportsSynch

  • supportsSynch(): boolean

symlink

  • symlink(srcpath: string, dstpath: string, type: string, cb: BFSOneArgCallback): void

symlinkSync

  • symlinkSync(srcpath: string, dstpath: string, type: string): void

truncate

truncateSync

  • truncateSync(p: string, len: number): void

umount

  • umount(mountPoint: string): void

unlink

unlinkSync

  • unlinkSync(p: string): void

utimes

utimesSync

  • utimesSync(p: string, atime: Date, mtime: Date): void

writeFile

writeFileSync

  • writeFileSync(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number): void

Static Create

Static isAvailable

  • isAvailable(): boolean

Generated using TypeDoc