Skip to content

Commit

Permalink
fix: πŸ› handle opening directories with O_DIRECTORY
Browse files Browse the repository at this point in the history
Fixes #494.
  • Loading branch information
corwin-of-amber committed Jan 15, 2020
1 parent ccc8f90 commit acdfac8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/volume.ts
Expand Up @@ -25,6 +25,7 @@ const {
O_TRUNC,
O_APPEND,
O_SYNC,
O_DIRECTORY,
F_OK,
COPYFILE_EXCL,
COPYFILE_FICLONE_FORCE,
Expand Down Expand Up @@ -912,7 +913,13 @@ export class Volume {
if (!realLink) throw createError(ENOENT, 'open', link.getPath());

const node = realLink.getNode();
if (node.isDirectory() && flagsNum !== FLAGS.r) throw createError(EISDIR, 'open', link.getPath());

// Check whether node is a directory
if (node.isDirectory()) {
if ((flagsNum & (O_RDONLY | O_RDWR | O_WRONLY)) !== O_RDONLY) throw createError(EISDIR, 'open', link.getPath());
} else {
if (flagsNum & O_DIRECTORY) throw createError(ENOTDIR, 'open', link.getPath());
}

// Check node permissions
if (!(flagsNum & O_WRONLY)) {
Expand Down

0 comments on commit acdfac8

Please sign in to comment.