changeset 480:2c7cb5b936b4

Irccd: use boost::filesystem (fs::rmdir), #594
author David Demelier <markand@malikania.fr>
date Thu, 16 Feb 2017 12:56:24 +0100
parents 298cae7487dc
children fe39fc9700d0
files libcommon/irccd/fs.hpp libirccd-js/irccd/mod-directory.cpp
diffstat 2 files changed, 6 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/libcommon/irccd/fs.hpp	Thu Feb 16 12:52:23 2017 +0100
+++ b/libcommon/irccd/fs.hpp	Thu Feb 16 12:56:24 2017 +0100
@@ -222,15 +222,6 @@
 IRCCD_EXPORT std::vector<Entry> readdir(const std::string &path, int flags = 0);
 
 /**
- * Remove a directory recursively.
- *
- * If errors happens, they are silently discarded to remove as much as possible.
- *
- * \param path the path
- */
-IRCCD_EXPORT void rmdir(const std::string &path) noexcept;
-
-/**
  * Search an item recursively.
  *
  * The predicate must have the following signature:
--- a/libirccd-js/irccd/mod-directory.cpp	Thu Feb 16 12:52:23 2017 +0100
+++ b/libirccd-js/irccd/mod-directory.cpp	Thu Feb 16 12:56:24 2017 +0100
@@ -174,14 +174,13 @@
     if (!fs::isDirectory(path))
         dukx_throw(ctx, SystemError(EINVAL, "not a directory"));
 
+    boost::system::error_code ec;
+
     if (!recursive) {
-#if defined(_WIN32)
-        ::RemoveDirectory(path.c_str());
-#else
-        ::remove(path.c_str());
-#endif
-    } else
-        fs::rmdir(path.c_str());
+        boost::filesystem::remove(path, ec);
+    } else {
+        boost::filesystem::remove_all(path, ec);
+    }
 
     return 0;
 }