Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pfrazee/scoped-fs
An FS wrapper that keeps all access scoped to a specific folder.
https://github.com/pfrazee/scoped-fs
Last synced: 2 months ago
JSON representation
An FS wrapper that keeps all access scoped to a specific folder.
- Host: GitHub
- URL: https://github.com/pfrazee/scoped-fs
- Owner: pfrazee
- Created: 2017-04-22T22:23:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-29T23:09:31.000Z (almost 2 years ago)
- Last Synced: 2024-10-17T17:37:08.043Z (2 months ago)
- Language: JavaScript
- Size: 326 KB
- Stars: 13
- Watchers: 3
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# scoped-fs
An FS wrapper that keeps all access scoped to a specific folder.
```
npm install scoped-fs
```## Usage
```js
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](https://github.com/mafintosh/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).