This commit is contained in:
2024-10-18 07:36:52 -05:00
parent ae0a921ba8
commit a0a5ca3390
3 changed files with 87 additions and 21 deletions

View File

@@ -161,7 +161,7 @@ auto directory::create_directory(std::string_view path) const
std::string{abs_path} + '|' +
std::to_string(res));
}
#else // !defined(_WIN32)
#else // !defined(_WIN32)
auto ret{true};
auto paths =
utils::string::split(abs_path, utils::path::directory_seperator, false);
@@ -377,10 +377,16 @@ auto directory::remove() -> bool {
return utils::retry_action([this]() -> bool {
try {
#if defined(_WIN32)
return not exists() || (::RemoveDirectoryA(path_.c_str()) != 0);
auto ret = not exists() || (::RemoveDirectoryA(path_.c_str()) != 0);
#else // !defined(_WIN32)
return not exists() || (rmdir(path_.c_str()) == 0);
auto ret = not exists() || (rmdir(path_.c_str()) == 0);
#endif // defined(_WIN32)
if (not ret) {
utils::error::handle_error(function_name,
"failed to remove directory|" + path_);
}
return ret;
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
} catch (...) {