From ebadbc5ff0cb66170cce94d60efb4289b733f3d2 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Thu, 3 Aug 2023 19:24:41 +0200 Subject: [PATCH] refactor: fs::path-ify core::ensure_dir_exists --- src/core/common.cpp | 2 +- src/core/common.hpp | 3 ++- src/fmtmacros.hpp | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/common.cpp b/src/core/common.cpp index 27a2fbbc6..b7560976e 100644 --- a/src/core/common.cpp +++ b/src/core/common.cpp @@ -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( diff --git a/src/core/common.hpp b/src/core/common.hpp index 4247d77cc..fc8dcfd80 100644 --- a/src/core/common.hpp +++ b/src/core/common.hpp @@ -18,6 +18,7 @@ #pragma once +#include #include #include @@ -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 diff --git a/src/fmtmacros.hpp b/src/fmtmacros.hpp index 6f396fd26..78ded2b9f 100644 --- a/src/fmtmacros.hpp +++ b/src/fmtmacros.hpp @@ -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 #include +#include // Convenience macro for calling `fmt::format` with `FMT_STRING` around the // format string literal. -- 2.47.2