Skip to content

Commit b328d3b

Browse files
committed
Remove flat node file using std::filesystem::remove()
Use standard function instead of old unlink() function. Also add some error reporting.
1 parent b75bb94 commit b328d3b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/node-persistent-cache.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
* For a full list of authors see the git log.
88
*/
99

10-
#include "logging.hpp"
1110
#include "node-persistent-cache.hpp"
1211

12+
#include "logging.hpp"
13+
1314
#include <cassert>
1415
#include <cerrno>
16+
#include <filesystem>
1517
#include <system_error>
1618
#include <utility>
1719

@@ -55,9 +57,14 @@ node_persistent_cache::~node_persistent_cache() noexcept
5557
if (m_remove_file) {
5658
try {
5759
log_debug("Removing persistent node cache at '{}'.", m_file_name);
60+
std::error_code ec{};
61+
std::filesystem::remove(m_file_name, ec);
62+
if (ec) {
63+
log_warn("Failed to remove persistent node cache at '{}': {}.",
64+
m_file_name, ec.message());
65+
}
5866
} catch (...) {
5967
// exception ignored on purpose
6068
}
61-
unlink(m_file_name.c_str());
6269
}
6370
}

0 commit comments

Comments
 (0)