From 02096e231ba0c18e210e73160215deb6dade6785 Mon Sep 17 00:00:00 2001 From: bugdea1er Date: Wed, 9 Oct 2024 02:10:50 +0300 Subject: [PATCH] Fix Windows specific rename behaviour --- src/entry.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/entry.cpp b/src/entry.cpp index 7048272..b0ba673 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -123,9 +123,17 @@ void entry::move(const fs::path& to) { throw_move_error(to, ec); } - if (fs::is_directory(*this) && !fs::is_directory(to)) { - ec = std::make_error_code(std::errc::not_a_directory); - throw_move_error(to, ec); + if (fs::is_directory(*this)) { + if (!fs::is_directory(to)) { + ec = std::make_error_code(std::errc::not_a_directory); + throw_move_error(to, ec); + } + +#ifdef WIN32 + if (!fs::equivalent(path(), to)) { + fs::remove_all(to); + } +#endif } }