summaryrefslogtreecommitdiff
path: root/src/utils/cpp/path.hpp
blob: 045ece0ed74851fcf637859163b6498054d0d01a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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