Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WorkerFS

WorkerFS lets you access a BrowserFS instance that is running in a different JavaScript context (e.g. access BrowserFS in one of your WebWorkers, or access BrowserFS running on the main page from a WebWorker).

For example, to have a WebWorker access files in the main browser thread, do the following:

MAIN BROWSER THREAD:

  // Listen for remote file system requests.
  BrowserFS.FileSystem.WorkerFS.attachRemoteListener(webWorkerObject);

WEBWORKER THREAD:

  // Set the remote file system as the root file system.
  BrowserFS.initialize(new BrowserFS.FileSystem.WorkerFS(self));

Note that synchronous operations are not permitted on the WorkerFS, regardless of the configuration option of the remote FS.

Hierarchy

Implements

Index

Constructors

constructor

  • new WorkerFS(worker: Worker): WorkerFS
  • Constructs a new WorkerFS instance that connects with BrowserFS running on the specified worker.

    Parameters

    • worker: Worker

    Returns WorkerFS

Methods

appendFile

appendFileSync

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

chmod

  • chmod(p: string, isLchmod: boolean, mode: number, cb: Function): void

chmodSync

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

chown

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

chownSync

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

createFile

createFileSync

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

diskSpace

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

exists

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

existsSync

  • existsSync(p: string): boolean

getName

  • getName(): string

initialize

  • initialize(cb: function): void
  • Called once both local and remote sides are set up.

    Parameters

    • cb: function
        • (): void
        • Returns void

    Returns void

isReadOnly

  • isReadOnly(): boolean

link

  • link(srcpath: string, dstpath: string, cb: Function): void

linkSync

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

mkdir

  • mkdir(p: string, mode: number, cb: Function): void

mkdirSync

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

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

readFileSync

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

readdir

readdirSync

  • readdirSync(p: string): string[]

readlink

  • readlink(p: string, cb: Function): void

readlinkSync

  • readlinkSync(p: string): string

realpath

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

realpathSync

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

rename

renameSync

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

rmdir

  • rmdir(p: string, cb: Function): void

rmdirSync

  • rmdirSync(p: string): void

stat

  • stat(p: string, isLstat: boolean, cb: BFSCallback): void

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: Function): void

symlinkSync

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

syncClose

truncate

  • truncate(p: string, len: number, cb: Function): void

truncateSync

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

unlink

  • unlink(p: string, cb: Function): void

unlinkSync

  • unlinkSync(p: string): void

utimes

  • utimes(p: string, atime: Date, mtime: Date, cb: Function): void

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 attachRemoteListener

  • attachRemoteListener(worker: Worker): void
  • Attaches a listener to the remote worker for file system requests.

    Parameters

    • worker: Worker

    Returns void

Static isAvailable

  • isAvailable(): boolean

Generated using TypeDoc