diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-04-28 18:02:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-04-28 18:02:23 +0200 |
commit | 4790f24757cf9a038d7cd37b370bac1807fb2d8c (patch) | |
tree | 19ae0399df13ab340068f6041a41c77156f6eb96 | |
parent | 085493111005770ed33beeba07d317b6eba0c851 (diff) |
Improve rmsymlink() interface
-rw-r--r-- | libbutl/filesystem.cxx | 13 | ||||
-rw-r--r-- | libbutl/filesystem.mxx | 6 |
2 files changed, 9 insertions, 10 deletions
diff --git a/libbutl/filesystem.cxx b/libbutl/filesystem.cxx index 7ee4c2c..28412d6 100644 --- a/libbutl/filesystem.cxx +++ b/libbutl/filesystem.cxx @@ -363,9 +363,9 @@ namespace butl } rmfile_status - rmsymlink (const path& link, bool) + try_rmsymlink (const path& link, bool, bool io) { - return try_rmfile (link); + return try_rmfile (link, io); } void @@ -503,20 +503,19 @@ namespace butl } rmfile_status - rmsymlink (const path& link, bool dir) + try_rmsymlink (const path& link, bool dir, bool io) { if (!dir) throw_generic_error (ENOSYS, "file symlinks not supported"); - switch (try_rmdir (path_cast<dir_path> (link))) + switch (try_rmdir (path_cast<dir_path> (link, io))) { case rmdir_status::success: return rmfile_status::success; case rmdir_status::not_exist: return rmfile_status::not_exist; - case rmdir_status::not_empty: throw_generic_error (ENOTEMPTY); + case rmdir_status::not_empty: if (io) return rmfile_status::success; } - assert (false); // Can't be here. - return rmfile_status::success; + throw_generic_error (ENOTEMPTY); } void diff --git a/libbutl/filesystem.mxx b/libbutl/filesystem.mxx index 8d99fdc..fbfc0aa 100644 --- a/libbutl/filesystem.mxx +++ b/libbutl/filesystem.mxx @@ -268,15 +268,15 @@ LIBBUTL_MODEXPORT namespace butl // is true). Throw std::system_error on failures. // LIBBUTL_SYMEXPORT rmfile_status - rmsymlink (const path&, bool dir = false); + try_rmsymlink (const path&, bool dir = false, bool ignore_error = false); // Remove a symbolic link to a directory. Throw std::system_error on // failures. // inline rmfile_status - rmsymlink (const dir_path& link) + try_rmsymlink (const dir_path& link, bool ignore_error = false) { - return rmsymlink (link, true); + return try_rmsymlink (link, true, ignore_error); } // Create a hard link to a file (default) or directory (third argument is |