if (('' + path).indexOf('\u0000') !== -1) {
var er = new Error('Path must be a string without null bytes.');
er.code = 'ENOENT';
- if (!callback)
+ if (typeof callback !== 'function')
throw er;
process.nextTick(function() {
callback(er);
});
fs.access = function(path, mode, callback) {
- if (!nullCheck(path, callback))
- return;
-
if (typeof mode === 'function') {
callback = mode;
mode = fs.F_OK;
throw new TypeError('callback must be a function');
}
+ if (!nullCheck(path, callback))
+ return;
+
mode = mode | 0;
var req = new FSReqWrap();
req.oncomplete = makeCallback(callback);
fs.access(__filename, fs.F_OK);
}, /callback must be a function/);
+assert.throws(function() {
+ fs.access(__filename, fs.F_OK, {});
+}, /callback must be a function/);
+
assert.doesNotThrow(function() {
fs.accessSync(__filename);
});
async.apply(null, argsAsync);
}
+check(fs.access, fs.accessSync, 'foo\u0000bar');
+check(fs.access, fs.accessSync, 'foo\u0000bar', fs.F_OK);
check(fs.appendFile, fs.appendFileSync, 'foo\u0000bar');
check(fs.chmod, fs.chmodSync, 'foo\u0000bar', '0644');
check(fs.chown, fs.chownSync, 'foo\u0000bar', 12, 34);
assert(!exists);
});
assert(!fs.existsSync('foo\u0000bar'));
-