diff options
-rw-r--r-- | libbutl/filesystem.cxx | 25 | ||||
-rw-r--r-- | libbutl/filesystem.ixx | 4 |
2 files changed, 21 insertions, 8 deletions
diff --git a/libbutl/filesystem.cxx b/libbutl/filesystem.cxx index dcdc96f..1ebe379 100644 --- a/libbutl/filesystem.cxx +++ b/libbutl/filesystem.cxx @@ -308,19 +308,30 @@ namespace butl // An nftw()-based implementation (for platforms that support it) // might be a faster way. // - for (const dir_entry& de: dir_iterator (p, false /* ignore_dangling */)) + // @@ Get rid of these try/catch clauses when ignore_error flag is + // implemented for dir_iterator() constructor. + // + try { - path ep (p / de.path ()); //@@ Would be good to reuse the buffer. + for (const dir_entry& de: dir_iterator (p, false /* ignore_dangling */)) + { + path ep (p / de.path ()); //@@ Would be good to reuse the buffer. - if (de.ltype () == entry_type::directory) - rmdir_r (path_cast<dir_path> (move (ep)), true, ignore_error); - else - try_rmfile (ep, ignore_error); + if (de.ltype () == entry_type::directory) + rmdir_r (path_cast<dir_path> (move (ep)), true, ignore_error); + else + try_rmfile (ep, ignore_error); + } + } + catch (const system_error&) + { + if (!ignore_error) + throw; } if (dir) { - rmdir_status r (try_rmdir (p)); + rmdir_status r (try_rmdir (p, ignore_error)); if (r != rmdir_status::success && !ignore_error) throw_generic_error (r == rmdir_status::not_empty diff --git a/libbutl/filesystem.ixx b/libbutl/filesystem.ixx index 5ac5d97..c9e3997 100644 --- a/libbutl/filesystem.ixx +++ b/libbutl/filesystem.ixx @@ -29,7 +29,9 @@ namespace butl inline rmdir_status try_rmdir_r (const dir_path& p, bool ignore_error) { - bool e (dir_exists (p)); //@@ What if it exists but is not a directory? + //@@ What if it exists but is not a directory? + // + bool e (dir_exists (p, ignore_error)); if (e) rmdir_r (p, true, ignore_error); |