]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: fs::path-ify core::ensure_dir_exists
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 3 Aug 2023 17:24:41 +0000 (19:24 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 4 Aug 2023 15:03:07 +0000 (17:03 +0200)
src/core/common.cpp
src/core/common.hpp
src/fmtmacros.hpp

index 27a2fbbc6bb6a053e2081248b06d9552e88e4c8f..b7560976e1829089c8af897fc40a8cf842695c1d 100644 (file)
@@ -113,7 +113,7 @@ rewrite_stderr_to_absolute_paths(std::string_view text)
 namespace core {
 
 void
-ensure_dir_exists(std::string_view dir)
+ensure_dir_exists(const fs::path& dir)
 {
   if (auto result = fs::create_directories(dir); !result) {
     throw core::Fatal(
index 4247d77ccb278439126af44c7e7a05a3338ef631..fc8dcfd806ff028984b645dea5793d4ac119e5b7 100644 (file)
@@ -18,6 +18,7 @@
 
 #pragma once
 
+#include <filesystem>
 #include <string>
 #include <string_view>
 
@@ -26,7 +27,7 @@ class Context;
 namespace core {
 
 // Like std::filesystem::create_directories but throws core::Fatal on error.
-void ensure_dir_exists(std::string_view dir);
+void ensure_dir_exists(const std::filesystem::path& dir);
 
 // Send `text` to file descriptor `fd` (typically stdout or stderr, which
 // potentially is connected to a console), optionally stripping ANSI color
index 6f396fd262c34cdb06c4b796fd0304cb329255e1..78ded2b9f0b8beb3fd4fbd2c1774fdb4832ae085 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2022 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2023 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -20,6 +20,7 @@
 
 #include <third_party/fmt/core.h>
 #include <third_party/fmt/format.h>
+#include <third_party/fmt/std.h>
 
 // Convenience macro for calling `fmt::format` with `FMT_STRING` around the
 // format string literal.