var fs = require('fs'),
path = require('path'),
assert = require('assert'),
dir = 'tmp_'+Date.now(),
file = dir+'/file.txt';
var existsSync = fs.existsSync || path.existsSync;
console.log('working on dir:', dir);
fs.mkdirSync(dir);
console.log('Folder created')
fs.writeFileSync(file, 'asdf');
console.log('File created')
fs.chmodSync(file, '0444'); // -r--r--r--
console.log('Rights modified')
fs.unlinkSync(file);
console.log('Delete file')
assert.equal(existsSync(file), false); // file should be erased since dir is writeable
Last active
October 9, 2019 10:07
-
-
Save Ugarz/81bb71e4b7041d1751a6e3f00b8a4520 to your computer and use it in GitHub Desktop.
Manage folder and file rights
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment