Skip to content

Commit b959b5b

Browse files
committed
Rename option and add comment
1 parent a16bafd commit b959b5b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/library_fs.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ FS.staticInit();
200200
try {
201201
current = FS.lookupNode(current, parts[i]);
202202
} catch (e) {
203-
if ((e?.errno === {{{ cDefs.ENOENT }}}) && islast && opts.handleBrokenLink) {
203+
// if noent_okay is true, suppress a ENOENT in the last component
204+
// and return an object with an undefined node. This is needed for
205+
// resolving symlinks in the path when creating a file.
206+
if ((e?.errno === {{{ cDefs.ENOENT }}}) && islast && opts.noent_okay) {
204207
return { path: current_path };
205208
}
206209
throw e;
@@ -1022,9 +1025,12 @@ FS.staticInit();
10221025
node = path;
10231026
} else {
10241027
path = PATH.normalize(path);
1028+
// noent_okay makes it so that if the final component of the path
1029+
// doesn't exist, lookupPath returns `node: undefined`. `path` will be
1030+
// updated to point to the target of all symlinks.
10251031
var lookup = FS.lookupPath(path, {
10261032
follow: !(flags & {{{ cDefs.O_NOFOLLOW }}}),
1027-
handleBrokenLink: true
1033+
noent_okay: true
10281034
});
10291035
node = lookup.node;
10301036
path = lookup.path;

0 commit comments

Comments
 (0)