Safe FS

Stop getting EMFILE errors! Open only as many files as the operating system supports.
Install
- Install Node.js
npm install --save safefs
Usage
var safefs = require('safefs');
The following file system methods are available (but wrapped in safe way to prevent EMFILE errors):
readFile(path, options?, next)
writeFile(path, data, options?, next)
- will also attempt to ensure the path existsappendFile(path, data, options?, next)
- will also attempt to ensure the path existsmkdir(path, mode?, next)
- mode defaults to 0o777 & (~process.umask())
stat(path, next)
readdir(path, next)
unlink(path, next)
rmdir(path, next)
exists(path, next)
For other file system interaction, you can do the following:
require('safefs').openFile(function(closeFile){
require('fs').someOtherMethod(a,b,c,function(err,a,b,c){
closeFile();
});
});
To make this possible we define a global variable called safefsGlobal
that manages the available slots for interacting with the file system.
History
You can discover the history inside the History.md file
License
Licensed under the incredibly permissive MIT License
Copyright © 2013+ Bevry Pty Ltd
Copyright © 2011-2012 Benjamin Arthur Lupton