]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Use fs::path for Context::register_pending_tmp_file
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 7 Jun 2024 14:29:08 +0000 (16:29 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 30 Jun 2024 15:18:51 +0000 (17:18 +0200)
src/ccache/Context.cpp
src/ccache/Context.hpp
src/ccache/ccache.cpp

index 1e4a88a4be9e2f8a0f9715bb234685bc8b9bab3a..4f23268df0e2a435ca833b77b6f7e43661dbd22f 100644 (file)
@@ -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.
 }
index 144d135b3ad084d0fef62182f95b3a6f88295983..83ed89e3c0fb5fed2a140d469b691f987e5b5a97 100644 (file)
@@ -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<std::string> m_pending_tmp_files;
+  std::vector<std::filesystem::path> m_pending_tmp_files;
 
   // [End of variables touched by the signal handler]
 
index 33efd3f32f9af0bf5f671bc6051f35d720a295bf..d26d763257610297e08cc72407a1209d78be84cc 100644 (file)
@@ -725,7 +725,7 @@ get_tmp_fd(Context& ctx,
     auto tmp_stdout =
       util::value_or_throw<core::Fatal>(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();