File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,10 +115,7 @@ FS.createPreloadedFile = FS_createPreloadedFile;
115115 } ,
116116 // TODO: mkdirTree
117117 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 ) ) ) ) ;
122119 } ,
123120 open: ( path , flags , mode ) => {
124121 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() {
111111 assert (ex .name == = 'ErrnoError' && ex .errno == 8 /* EBADF */ );
112112 );
113113
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+
114166 /********** test FS.close() **********/
115167 EM_ASM (
116168 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):
59515951 self .set_setting ('LINKABLE' , linkable )
59525952 self .do_core_test ('test_istream.cpp' )
59535953
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-
59595954 def test_fs_base (self ):
59605955 self .set_setting ('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE' , ['$FS' ])
59615956 self .uses_es6 = True
You can’t perform that action at this time.
0 commit comments