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();
1060
1060
mode = 0 ;
1061
1061
}
1062
1062
var node ;
1063
+ var isDirPath ;
1063
1064
if ( typeof path = = 'object' ) {
1064
1065
node = path ;
1065
1066
} else {
1067
+ isDirPath = path . endsWith ( "/" ) ;
1066
1068
// noent_okay makes it so that if the final component of the path
1067
1069
// doesn't exist, lookupPath returns `node: undefined`. `path` will be
1068
1070
// updated to point to the target of all symlinks.
@@ -1081,6 +1083,8 @@ FS.staticInit();
1081
1083
if ( ( flags & { { { cDefs . O_EXCL } } } ) ) {
1082
1084
throw new FS . ErrnoError ( { { { cDefs . EEXIST } } } ) ;
1083
1085
}
1086
+ } else if ( isDirPath ) {
1087
+ throw new FS . ErrnoError ( { { { cDefs . EISDIR } } } ) ;
1084
1088
} else {
1085
1089
// node doesn't exist, try to create it
1086
1090
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):
5756
5756
5757
5757
@no_windows ('https://github.com/emscripten-core/emscripten/issues/8882' )
5758
5758
@crossplatform
5759
- @also_with_noderawfs
5759
+ @also_with_nodefs_both
5760
5760
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' )
5762
5764
5763
5765
@also_with_noderawfs
5764
5766
def test_fs_append (self ):
You can’t perform that action at this time.
0 commit comments