fs-lock是Node.js的文件限制,用纯JavaScript写成,用户可以加载其他方法获取访问。
示例代码:
//Do your startup code here, then lock it down with:require('fs-lock')({ 'file_accessdir': [ __dirname, '/tmp' ], 'open_basedir': [ '/usr/local/share/node_modules', __dirname ]});var fs = require('fs');fs.readFile('/etc/passwd', function(err, data) { //this will throw an Access Denied error});
评论