diff options
Diffstat (limited to 'src/buildtool/file_system/file_system_manager.hpp')
-rw-r--r-- | src/buildtool/file_system/file_system_manager.hpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/buildtool/file_system/file_system_manager.hpp b/src/buildtool/file_system/file_system_manager.hpp index fe316451..a6d15c84 100644 --- a/src/buildtool/file_system/file_system_manager.hpp +++ b/src/buildtool/file_system/file_system_manager.hpp @@ -44,6 +44,7 @@ #include <string> #include <string_view> #include <system_error> +#include <tuple> #include <unordered_set> #include <utility> #include <variant> @@ -510,9 +511,9 @@ class FileSystemManager { } } - [[nodiscard]] static auto RemoveDirectory(std::filesystem::path const& dir, - bool recursively = false) noexcept - -> bool { + /// \brief Remove directory recursively. + [[nodiscard]] static auto RemoveDirectory( + std::filesystem::path const& dir) noexcept -> bool { try { auto status = std::filesystem::symlink_status(dir); if (not std::filesystem::exists(status)) { @@ -521,11 +522,9 @@ class FileSystemManager { if (not std::filesystem::is_directory(status)) { return false; } - if (recursively) { - return (std::filesystem::remove_all(dir) != - static_cast<uintmax_t>(-1)); - } - return std::filesystem::remove(dir); + // If it doesn't throw, it succeeds: + std::ignore = std::filesystem::remove_all(dir); + return true; } catch (std::exception const& e) { Logger::Log(LogLevel::Error, "removing directory {}:\n{}", |