Skip to content

Commit 10450a7

Browse files
committed
Check if isDir first
1 parent afaf1dc commit 10450a7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/library_fs.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,13 @@ FS.staticInit();
372372
return 0;
373373
},
374374
mayCreate(dir, name) {
375+
if (!FS.isDir(dir)) {
376+
return {{{ cDefs.ENOTDIR }}};
377+
}
375378
try {
376379
var node = FS.lookupNode(dir, name);
377380
return {{{ cDefs.EEXIST }}};
378-
} catch (e) {
379-
if (e.errno === {{{ cDefs.ENOTDIR }}}) {
380-
return {{{ cDefs.ENOTDIR }}};
381-
}
382-
}
381+
} catch (e) { }
383382
return FS.nodePermissions(dir, 'wx');
384383
},
385384
mayDelete(dir, name, isdir) {

0 commit comments

Comments
 (0)