From: Joel Rosdahl Date: Tue, 13 Jan 2026 20:08:10 +0000 (+0100) Subject: refactor: Improve util::add_exe_suffix signature X-Git-Tag: v4.13~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63cf2dcc84b751eb12f62f1892c8082ec4c7cec8;p=thirdparty%2Fccache.git refactor: Improve util::add_exe_suffix signature --- diff --git a/src/ccache/util/path.cpp b/src/ccache/util/path.cpp index 4c4ae7ed..d4136e26 100644 --- a/src/ccache/util/path.cpp +++ b/src/ccache/util/path.cpp @@ -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 diff --git a/src/ccache/util/path.hpp b/src/ccache/util/path.hpp index 919aa203..4df77a3c 100644 --- a/src/ccache/util/path.hpp +++ b/src/ccache/util/path.hpp @@ -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).