commit 0f62df1d2e42ab935d3d375236ed764d3672e1c3 parent ac05f088301ccc547204c3bb1c803b4448436798 Author: cfillion <cfillion@users.noreply.github.com> Date: Tue, 19 Jan 2016 08:13:51 -0800 fix empty directory removal on windows Diffstat:
M | src/task.cpp | | | 12 | ++++++++++-- |
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/task.cpp b/src/task.cpp @@ -25,6 +25,10 @@ #include <cerrno> #include <cstdio> +#ifdef _WIN32 +#include <windows.h> +#endif + using namespace std; Task::Task(Transaction *transaction) @@ -53,10 +57,14 @@ void Task::commit() int Task::removeFile(const Path &path) const { - const string &fullPath = m_transaction->prefixPath(path).join(); + const auto_string &fullPath = + make_autostring(m_transaction->prefixPath(path).join()); #ifdef _WIN32 - return _wremove(make_autostring(fullPath).c_str()); + if(GetFileAttributes(fullPath.c_str()) & FILE_ATTRIBUTE_DIRECTORY) + return !RemoveDirectory(fullPath.c_str()); + else + return _wremove(fullPath.c_str()); #else return remove(fullPath.c_str()); #endif