File tree Expand file tree Collapse file tree 4 files changed +53
-58
lines changed Expand file tree Collapse file tree 4 files changed +53
-58
lines changed Original file line number Diff line number Diff line change @@ -115,10 +115,7 @@ FS.createPreloadedFile = FS_createPreloadedFile;
115
115
} ,
116
116
// TODO: mkdirTree
117
117
rmdir : ( path ) = > {
118
- return withStackSave ( ( ) => {
119
- var buffer = stringToUTF8OnStack ( path ) ;
120
- return __wasmfs_rmdir ( buffer ) ;
121
- } )
118
+ return FS . handleError ( withStackSave ( ( ) => __wasmfs_rmdir ( stringToUTF8OnStack ( path ) ) ) ) ;
122
119
} ,
123
120
open: ( path , flags , mode ) => {
124
121
flags = typeof flags == 'string' ? FS_modeStringToFlags ( flags ) : flags ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -111,6 +111,58 @@ int main() {
111
111
assert (ex .name == = 'ErrnoError' && ex .errno == 8 /* EBADF */ );
112
112
);
113
113
114
+ /********** test FS.rmdir() **********/
115
+ EM_ASM (
116
+ // Create multiple directories
117
+ FS .mkdir ('/dir1' );
118
+ FS .mkdir ('/dir2' );
119
+ );
120
+
121
+ struct stat s ;
122
+ stat ("/dir1" , & s );
123
+ assert (S_ISDIR (s .st_mode ));
124
+ stat ("/dir2" , & s );
125
+ assert (S_ISDIR (s .st_mode ));
126
+
127
+
128
+ EM_ASM (
129
+ // Remove the multiple directories
130
+ FS .rmdir ('/dir1' );
131
+ FS .rmdir ('/dir2' );
132
+ );
133
+
134
+ int err = open ("/dir1" , O_RDWR );
135
+ assert (err );
136
+ err = open ("/dir2" , O_RDWR );
137
+ assert (err );
138
+
139
+ EM_ASM (
140
+ // Create a directory with a file inside it
141
+ FS .mkdir ('/test_dir' );
142
+ FS .writeFile ('/test_dir/file.txt' , 'Hello World!' );
143
+
144
+ // Attempt to remove the directory (should fail)
145
+ var ex ;
146
+ try {
147
+ FS .rmdir ('/test_dir' );
148
+ } catch (err ) {
149
+ ex = err ;
150
+ }
151
+ assert (ex .name == = "ErrnoError" && ex .errno == = 55 /* ENOTEMPTY */ );
152
+
153
+ // Remove the file and then the directory
154
+ FS .unlink ('/test_dir/file.txt' );
155
+ FS .rmdir ('/test_dir' );
156
+
157
+ // Attempt to remove a non-existent directory (should fail)
158
+ try {
159
+ FS .rmdir ('/non_existent_dir' );
160
+ } catch (err ) {
161
+ ex = err ;
162
+ }
163
+ assert (ex .name == = "ErrnoError" && ex .errno == = 44 /* ENOEN */ );
164
+ );
165
+
114
166
/********** test FS.close() **********/
115
167
EM_ASM (
116
168
FS .writeFile ("closetestfile" , 'a=1\nb=2\n' );
Original file line number Diff line number Diff line change @@ -5951,11 +5951,6 @@ def test_istream(self):
5951
5951
self .set_setting ('LINKABLE' , linkable )
5952
5952
self .do_core_test ('test_istream.cpp' )
5953
5953
5954
- def test_fs_dir_wasmfs (self ):
5955
- self .emcc_args += ['-sWASMFS' ]
5956
- self .emcc_args += ['-sFORCE_FILESYSTEM' ]
5957
- self .do_runf (test_file ('fs/test_dir.c' ), 'success' )
5958
-
5959
5954
def test_fs_base (self ):
5960
5955
self .set_setting ('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE' , ['$FS' ])
5961
5956
self .uses_es6 = True
You can’t perform that action at this time.
0 commit comments