From: Joel Rosdahl Date: Fri, 7 Jun 2024 14:29:08 +0000 (+0200) Subject: refactor: Use fs::path for Context::register_pending_tmp_file X-Git-Tag: v4.11~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=068db210636733870864e59692dc86ab6f292b92;p=thirdparty%2Fccache.git refactor: Use fs::path for Context::register_pending_tmp_file --- diff --git a/src/ccache/Context.cpp b/src/ccache/Context.cpp index 1e4a88a4..4f23268d 100644 --- a/src/ccache/Context.cpp +++ b/src/ccache/Context.cpp @@ -78,7 +78,7 @@ Context::~Context() } void -Context::register_pending_tmp_file(const std::string& path) +Context::register_pending_tmp_file(const fs::path& path) { SignalHandlerBlocker signal_handler_blocker; @@ -92,7 +92,7 @@ Context::unlink_pending_tmp_files_signal_safe() ++it) { // Don't call util::remove or std::filesystem::remove since they are not // signal safe. - unlink(it->c_str()); + unlink(util::pstr(*it).c_str()); } // Don't clear m_pending_tmp_files since this method must be signal safe. } diff --git a/src/ccache/Context.hpp b/src/ccache/Context.hpp index 144d135b..83ed89e3 100644 --- a/src/ccache/Context.hpp +++ b/src/ccache/Context.hpp @@ -116,7 +116,7 @@ public: bool auto_depend_mode = false; // Register a temporary file to remove at program exit. - void register_pending_tmp_file(const std::string& path); + void register_pending_tmp_file(const std::filesystem::path& path); private: // Options to ignore for the hash. @@ -125,7 +125,7 @@ private: // [Start of variables touched by the signal handler] // Temporary files to remove at program exit. - std::vector m_pending_tmp_files; + std::vector m_pending_tmp_files; // [End of variables touched by the signal handler] diff --git a/src/ccache/ccache.cpp b/src/ccache/ccache.cpp index 33efd3f3..d26d7632 100644 --- a/src/ccache/ccache.cpp +++ b/src/ccache/ccache.cpp @@ -725,7 +725,7 @@ get_tmp_fd(Context& ctx, auto tmp_stdout = util::value_or_throw(util::TemporaryFile::create( FMT("{}/{}", ctx.config.temporary_dir(), description))); - ctx.register_pending_tmp_file(util::pstr(tmp_stdout.path)); + ctx.register_pending_tmp_file(tmp_stdout.path); return {std::move(tmp_stdout.fd), std::move(tmp_stdout.path)}; } else { const auto dev_null_path = util::get_dev_null_path();