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

index 83ed89e3c0fb5fed2a140d469b691f987e5b5a97..aad606b961552fa14e4a579d713f8ff300ae5ece 100644 (file)
@@ -74,7 +74,7 @@ public:
   bool diagnostics_color_failed = false;
 
   // The name of the temporary preprocessed file.
-  std::string i_tmpfile;
+  std::filesystem::path i_tmpfile;
 
   // The preprocessor's stderr output.
   util::Bytes cpp_stderr_data;
index d26d763257610297e08cc72407a1209d78be84cc..b9c2df317ddc3be43de3abc88741b2a55c94fd9a 100644 (file)
@@ -463,7 +463,7 @@ print_included_files(const Context& ctx, FILE* fp)
 //   when computing the hash sum.
 // - Stores the paths and hashes of included files in ctx.included_files.
 static tl::expected<void, Failure>
-process_preprocessed_file(Context& ctx, Hash& hash, const std::string& path)
+process_preprocessed_file(Context& ctx, Hash& hash, const fs::path& path)
 {
   auto data = util::read_file<std::string>(path);
   if (!data) {
@@ -1285,13 +1285,13 @@ to_cache(Context& ctx,
 static tl::expected<Hash::Digest, Failure>
 get_result_key_from_cpp(Context& ctx, Args& args, Hash& hash)
 {
-  std::string preprocessed_path;
+  fs::path preprocessed_path;
   util::Bytes cpp_stderr_data;
 
   if (ctx.args_info.direct_i_file) {
     // We are compiling a .i or .ii file - that means we can skip the cpp stage
     // and directly form the correct i_tmpfile.
-    preprocessed_path = util::pstr(ctx.args_info.input_file);
+    preprocessed_path = ctx.args_info.input_file;
   } else {
     // Run cpp on the input file to obtain the .i.
 
@@ -1301,7 +1301,7 @@ get_result_key_from_cpp(Context& ctx, Args& args, Hash& hash)
       util::value_or_throw<core::Fatal>(util::TemporaryFile::create(
         FMT("{}/cpp_stdout", ctx.config.temporary_dir()),
         FMT(".{}", ctx.config.cpp_extension())));
-    preprocessed_path = tmp_stdout.path.string();
+    preprocessed_path = tmp_stdout.path;
     tmp_stdout.fd.close(); // We're only using the path.
     ctx.register_pending_tmp_file(preprocessed_path);