From acdfac872b657776d32f1bfd346726c422a199f0 Mon Sep 17 00:00:00 2001 From: Shachar Itzhaky Date: Wed, 15 Jan 2020 14:09:29 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20handle=20opening=20direct?= =?UTF-8?q?ories=20with=20O=5FDIRECTORY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #494. --- src/volume.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/volume.ts b/src/volume.ts index d5e67c896..77409c61d 100644 --- a/src/volume.ts +++ b/src/volume.ts @@ -25,6 +25,7 @@ const { O_TRUNC, O_APPEND, O_SYNC, + O_DIRECTORY, F_OK, COPYFILE_EXCL, COPYFILE_FICLONE_FORCE, @@ -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)) {