diff --git a/lib/binding.js b/lib/binding.js index 9dbcb9c1..a9b56d1b 100644 --- a/lib/binding.js +++ b/lib/binding.js @@ -953,8 +953,9 @@ Binding.prototype.readdir = function( if (!(dir instanceof Directory)) { throw new FSError('ENOTDIR', dirpath); } - - this.access(dirpath, parseInt('0002', 8)); + if (!dir.canRead()) { + throw new FSError('EACCES', dirpath); + } let list = dir.list(); if (encoding === 'buffer') { diff --git a/test/lib/fs.readdir.spec.js b/test/lib/fs.readdir.spec.js index 0dbe2153..a96ed463 100644 --- a/test/lib/fs.readdir.spec.js +++ b/test/lib/fs.readdir.spec.js @@ -244,10 +244,4 @@ describe('fs.readdirSync(path)', function() { fs.readdirSync('denied'); }); }); - - it('throws when access refused', function() { - assert.throws(function() { - fs.readdirSync('denied'); - }); - }); });