Skip to content

dBrowser/dbrowser-sfs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dbrowser-sfs

An FS wrapper that keeps all access scoped to a specific folder.

npm install dbrowser-sfs

Usage

var ScopedFS = require('dbrowser-sfs')

var fs = new ScopedFS('/home/bob')
fs.readFile('/hello.txt', 'utf8', function (err, content) {
  // reads /home/bob/hello.txt
  console.log('world')
})

API

new ScopedFS(basepath)

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

Wrapped FS methods

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

var stopwatch = sfs.watch(name, fn)

Create a recursive-watch instance.

sfs.setFilter(fn)

Set a filtering function which causes files & folders to be hidden if the function returns false. Attempts to read a filtered file will give a not found error (ENOENT) while attempts to write will give a permissions error (EPERM).

About

An FS wrapper that keeps all access scoped to a specific folder.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%