File tree Expand file tree Collapse file tree 5 files changed +32
-20
lines changed Expand file tree Collapse file tree 5 files changed +32
-20
lines changed Original file line number Diff line number Diff line change @@ -1060,9 +1060,11 @@ FS.staticInit();
10601060 mode = 0 ;
10611061 }
10621062 var node ;
1063+ var isDirPath ;
10631064 if ( typeof path = = 'object' ) {
10641065 node = path ;
10651066 } else {
1067+ isDirPath = path . endsWith ( "/" ) ;
10661068 // noent_okay makes it so that if the final component of the path
10671069 // doesn't exist, lookupPath returns `node: undefined`. `path` will be
10681070 // updated to point to the target of all symlinks.
@@ -1081,6 +1083,8 @@ FS.staticInit();
10811083 if ( ( flags & { { { cDefs . O_EXCL } } } ) ) {
10821084 throw new FS . ErrnoError ( { { { cDefs . EEXIST } } } ) ;
10831085 }
1086+ } else if ( isDirPath ) {
1087+ throw new FS . ErrnoError ( { { { cDefs . EISDIR } } } ) ;
10841088 } else {
10851089 // node doesn't exist, try to create it
10861090 node = FS . mknod ( path , mode , 0 ) ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #include <errno.h>
2+ #include <fcntl.h>
3+ #include <stdio.h>
4+ #include <string.h>
5+ #include <unistd.h>
6+ #include <sys/stat.h>
7+ #include <assert.h>
8+
9+ int main () {
10+ {
11+ int src_fd = open ("file" , O_CREAT | O_WRONLY , 0777 );
12+ assert (src_fd >= 0 );
13+ assert (close (src_fd ) == 0 );
14+ }
15+ {
16+ assert (mkdir ("file/blah" , 0777 ) == -1 );
17+ assert (errno == ENOTDIR );
18+ }
19+ {
20+ assert (open ("./does-not-exist/" , O_CREAT ) == -1 );
21+ assert (errno == EISDIR );
22+ }
23+ printf ("success\n" );
24+ }
Original file line number Diff line number Diff line change @@ -5756,9 +5756,11 @@ def test_fs_emptyPath(self):
57565756
57575757 @no_windows ('https://github.com/emscripten-core/emscripten/issues/8882' )
57585758 @crossplatform
5759- @also_with_noderawfs
5759+ @also_with_nodefs_both
57605760 def test_fs_enotdir (self ):
5761- self .do_run_in_out_file_test ('fs/test_enotdir.c' )
5761+ if MACOS and '-DNODERAWFS' in self .emcc_args :
5762+ self .skipTest ('BSD libc sets a different errno' )
5763+ self .do_runf ('fs/test_fs_enotdir.c' , 'success' )
57625764
57635765 @also_with_noderawfs
57645766 def test_fs_append (self ):
You can’t perform that action at this time.
0 commit comments