From 39714825086c40c43345379c95f181a1957d6080 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 6 May 2022 14:31:02 +0200 Subject: Move path normalisation to a separate library ... as it will be required outside the target map. --- src/utils/cpp/TARGETS | 6 ++++++ src/utils/cpp/path.hpp | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/utils/cpp/path.hpp (limited to 'src/utils/cpp') diff --git a/src/utils/cpp/TARGETS b/src/utils/cpp/TARGETS index 35a53a68..7268f10a 100644 --- a/src/utils/cpp/TARGETS +++ b/src/utils/cpp/TARGETS @@ -37,4 +37,10 @@ , "hdrs": ["hex_string.hpp"] , "stage": ["src", "utils", "cpp"] } +, "path": + { "type": ["@", "rules", "CC", "library"] + , "name": ["path"] + , "hdrs": ["path.hpp"] + , "stage": ["src", "utils", "cpp"] + } } diff --git a/src/utils/cpp/path.hpp b/src/utils/cpp/path.hpp new file mode 100644 index 00000000..045ece0e --- /dev/null +++ b/src/utils/cpp/path.hpp @@ -0,0 +1,15 @@ +#ifndef INCLUDED_SRC_UTILS_CPP_PATH_HPP +#define INCLUDED_SRC_UTILS_CPP_PATH_HPP + +#include + +[[nodiscard]] static inline auto ToNormalPath(std::filesystem::path const& p) + -> std::filesystem::path { + auto n = p.lexically_normal(); + if (not n.has_filename()) { + return n.parent_path(); + } + return n; +} + +#endif -- cgit v1.2.3