Skip to content

Commit

Permalink
Throw error when a directory is opened
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellgerber committed Jul 26, 2018
1 parent c1cdeec commit b3e86cb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/binding.js
Expand Up @@ -457,6 +457,12 @@ Binding.prototype.open = function(pathname, flags, mode, callback) {
if (descriptor.isWrite() && !item.canWrite()) {
throw new FSError('EACCES', pathname);
}
if (
item instanceof Directory &&
(descriptor.isTruncate() || descriptor.isAppend())
) {
throw new FSError('EISDIR', pathname);
}
if (descriptor.isTruncate()) {
item.setContent('');
}
Expand Down

0 comments on commit b3e86cb

Please sign in to comment.