Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1053,9 +1053,11 @@ FS.staticInit();
mode = 0;
}
var node;
var isDirPath;
if (typeof path == 'object') {
node = path;
} else {
isDirPath = path.endsWith("/");
// noent_okay makes it so that if the final component of the path
// doesn't exist, lookupPath returns `node: undefined`. `path` will be
// updated to point to the target of all symlinks.
Expand All @@ -1074,6 +1076,8 @@ FS.staticInit();
if ((flags & {{{ cDefs.O_EXCL }}})) {
throw new FS.ErrnoError({{{ cDefs.EEXIST }}});
}
} else if (isDirPath) {
throw new FS.ErrnoError({{{ cDefs.EISDIR }}});
} else {
// node doesn't exist, try to create it
node = FS.mknod(path, mode, 0);
Expand Down
17 changes: 0 additions & 17 deletions test/fs/test_enotdir.c

This file was deleted.

1 change: 0 additions & 1 deletion test/fs/test_enotdir.out

This file was deleted.

24 changes: 24 additions & 0 deletions test/fs/test_fs_enotdir.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <assert.h>

int main() {
{
int src_fd = open("file", O_CREAT | O_WRONLY, 0777);
assert(src_fd >= 0);
assert(close(src_fd) == 0);
}
{
assert(mkdir("file/blah", 0777) == -1);
assert(errno == ENOTDIR);
}
{
assert(open("./does-not-exist/", O_CREAT) == -1);
assert(errno == EISDIR);
}
printf("success\n");
}
6 changes: 4 additions & 2 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5756,9 +5756,11 @@ def test_fs_emptyPath(self):

@no_windows('https://github.com/emscripten-core/emscripten/issues/8882')
@crossplatform
@also_with_noderawfs
@also_with_nodefs_both
def test_fs_enotdir(self):
self.do_run_in_out_file_test('fs/test_enotdir.c')
if MACOS and '-DNODERAWFS' in self.emcc_args:
self.skipTest('BSD libc sets a different errno')
self.do_runf('fs/test_fs_enotdir.c', 'success')

@also_with_noderawfs
def test_fs_append(self):
Expand Down
Loading