Skip to content

dBrowser VirtualFS Wrapper

Jared Rice Sr edited this page Jun 30, 2018 · 1 revision

@dbrowser/vfs-wrapper

A Virtual File System wrapper for dBrowser that keeps all access scoped to a specific folder.

npm install @dbrowser/vfs-wrapper

Usage

var VFSystemWrapper = require('@dbrowser/vfs-wrapper')

var vfsw = new VFSystemWrapper('/home/jared')
fs.readFile('/greetings.txt', 'utf8', function (err, content) {
  // reads /home/jared/greetings.txt
  console.log('martian')
})

API

new VFSystemWrapper(basepath)

Creates a scoped vfsw instance. All reads and writes will be restricted to basepath; any attempts to use .. to escape will return an error.

Wrapped VFS methods

  • createReadStream
  • readFile
  • createWriteStream
  • writeFile
  • mkdir
  • access
  • exists
  • lstat
  • stat
  • readdir
  • unlink
  • rmdir

var stopwatch = vfsw.watch(name, fn)

Clone this wiki locally