File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -226,19 +226,29 @@ pub fn sigint_to_signal_name(si int) string {
226226
227227// rmdir_all recursively removes the specified directory.
228228pub fn rmdir_all (path string ) ! {
229- mut ret_err := ''
229+ mut err_msg := ''
230+ mut err_code := - 1
230231 items := ls (path)!
231232 for item in items {
232233 fullpath := join_path_single (path, item)
233234 if is_dir (fullpath) && ! is_link (fullpath) {
234- rmdir_all (fullpath) or { ret_err = err.msg () }
235+ rmdir_all (fullpath) or {
236+ err_msg = err.msg ()
237+ err_code = err.code ()
238+ }
235239 } else {
236- rm (fullpath) or { ret_err = err.msg () }
240+ rm (fullpath) or {
241+ err_msg = err.msg ()
242+ err_code = err.code ()
243+ }
237244 }
238245 }
239- rmdir (path) or { ret_err = err.msg () }
240- if ret_err.len > 0 {
241- return error (ret_err)
246+ rmdir (path) or {
247+ err_msg = err.msg ()
248+ err_code = err.code ()
249+ }
250+ if err_msg != '' {
251+ return error_with_code (err_msg, err_code)
242252 }
243253}
244254
Original file line number Diff line number Diff line change @@ -282,10 +282,9 @@ pub fn ls(path string) ![]string {
282282 mut res := []string {cap: 50 }
283283 dir := unsafe { C.opendir (& char (path.str)) }
284284 if isnil (dir) {
285- return error ( 'ls() couldnt open dir "${path }"' )
285+ return error_posix (msg: 'ls() couldnt open dir "${path }"' )
286286 }
287287 mut ent := & C.dirent (unsafe { nil })
288- // mut ent := &C.dirent{!}
289288 for {
290289 ent = C.readdir (dir)
291290 if isnil (ent) {
You can’t perform that action at this time.
0 commit comments