diff options
-rw-r--r-- | butl/filesystem | 6 | ||||
-rw-r--r-- | butl/filesystem.cxx | 8 | ||||
-rw-r--r-- | butl/filesystem.ixx | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/butl/filesystem b/butl/filesystem index 943a346..ab39f36 100644 --- a/butl/filesystem +++ b/butl/filesystem @@ -73,11 +73,11 @@ namespace butl try_rmdir_r (const dir_path&, bool ignore_error = false); // As above but throws rather than returns not_exist if the directory - // does not exist, so check before calling. If the second argument is - // false, the the directory itself is not removed. + // does not exist (unless ignore_error is true), so check before calling. + // If the second argument is false, then the directory itself is not removed. // void - rmdir_r (const dir_path&, bool dir = true); + rmdir_r (const dir_path&, bool dir = true, bool ignore_error = false); // Try to remove the file (or symlinks) returning not_exist if // it does not exist. Unless ignore_error is true, all other diff --git a/butl/filesystem.cxx b/butl/filesystem.cxx index 72e1812..a2d6434 100644 --- a/butl/filesystem.cxx +++ b/butl/filesystem.cxx @@ -111,7 +111,7 @@ namespace butl } void - rmdir_r (const dir_path& p, bool dir) + rmdir_r (const dir_path& p, bool dir, bool ignore_error) { // An nftw()-based implementation (for platforms that support it) // might be a faster way. @@ -121,16 +121,16 @@ namespace butl path ep (p / de.path ()); //@@ Would be good to reuse the buffer. if (de.ltype () == entry_type::directory) - rmdir_r (path_cast<dir_path> (ep)); + rmdir_r (path_cast<dir_path> (ep), true, ignore_error); else - try_rmfile (ep); + try_rmfile (ep, ignore_error); } if (dir) { rmdir_status r (try_rmdir (p)); - if (r != rmdir_status::success) + if (r != rmdir_status::success && !ignore_error) throw system_error (r == rmdir_status::not_empty ? ENOTEMPTY : ENOENT, system_category ()); } diff --git a/butl/filesystem.ixx b/butl/filesystem.ixx index 86f654c..c2bfa49 100644 --- a/butl/filesystem.ixx +++ b/butl/filesystem.ixx @@ -10,7 +10,7 @@ namespace butl bool e (dir_exists (p)); //@@ What if it exists but is not a directory? if (e) - rmdir_r (p, ignore_error); + rmdir_r (p, true, ignore_error); return e ? rmdir_status::success : rmdir_status::not_exist; } |