summaryrefslogtreecommitdiff
path: root/src/utils/cpp/path.hpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-05-06 14:31:02 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-05-09 14:55:40 +0200
commit39714825086c40c43345379c95f181a1957d6080 (patch)
tree699300769e26a28330a1d736e0abf4903150fcee /src/utils/cpp/path.hpp
parenteb1665fa084772cc4774019fc5a75dc6ddeac143 (diff)
downloadjustbuild-39714825086c40c43345379c95f181a1957d6080.tar.gz
Move path normalisation to a separate library
... as it will be required outside the target map.
Diffstat (limited to 'src/utils/cpp/path.hpp')
-rw-r--r--src/utils/cpp/path.hpp15
1 files changed, 15 insertions, 0 deletions
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 <filesystem>
+
+[[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