]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Improve util::add_exe_suffix signature
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 13 Jan 2026 20:08:10 +0000 (21:08 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 13 Jan 2026 20:39:38 +0000 (21:39 +0100)
src/ccache/util/path.cpp
src/ccache/util/path.hpp

index 4c4ae7edc94a04d4f8a1262fb7327efc740d758a..d4136e26bf80809c9d0525f4f040db0a5a0f15b1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021-2025 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2026 Joel Rosdahl and other contributors
 //
 // See doc/authors.adoc for a complete list of contributors.
 //
@@ -33,10 +33,11 @@ namespace fs = util::filesystem;
 
 namespace util {
 
-std::string
-add_exe_suffix(const std::string& program)
+fs::path
+add_exe_suffix(const fs::path& program)
 {
-  return fs::path(program).has_extension() ? program : program + ".exe";
+  return program.has_extension() ? program
+                                 : util::with_extension(program, ".exe");
 }
 
 fs::path
index 919aa203554618735cfbada7050d1e8eb8392797..4df77a3c737057afe94c2d6ba5847db87cdcc4e7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021-2025 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2026 Joel Rosdahl and other contributors
 //
 // See doc/authors.adoc for a complete list of contributors.
 //
@@ -33,7 +33,7 @@ namespace util {
 // --- Interface ---
 
 // Add ".exe" suffix to `program` if it doesn't already have an extension.
-std::string add_exe_suffix(const std::string& program);
+std::filesystem::path add_exe_suffix(const std::filesystem::path& program);
 
 // Return a new path with `extension` added to `path` (keeping any existing
 // extension).