sf
scoped-fs
npm i scoped-fs
sf

scoped-fs

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

by Paul Frazee

1.4.1 (see all)License:MITTypeScript:Not Found
npm i scoped-fs
Readme

scoped-fs

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

npm install scoped-fs

Usage

var ScopedFS = require('scoped-fs')

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).

Downloads/wk

39

GitHub Stars

13

LAST COMMIT

3yrs ago

MAINTAINERS

2

CONTRIBUTORS

1

OPEN ISSUES

0

OPEN PRs

5
VersionTagPublished
1.4.1
latest
3yrs ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate