This commit is contained in:
Scott E. Graves 2024-08-02 16:04:04 -05:00
parent b647053fb9
commit 73ee70a862

View File

@ -227,11 +227,11 @@ get_parent_api_path(std::wstring_view path) -> std::wstring;
[[nodiscard]] auto unmake_file_uri(std::wstring_view uri) -> std::wstring;
inline auto absolute(std::string_view path) -> std::string {
return finalize(std::filesystem::absolute(path).lexically_normal().string());
return std::filesystem::absolute(finalize(path)).lexically_normal().string();
}
inline auto absolute(std::wstring_view path) -> std::wstring {
return finalize(std::filesystem::absolute(path).lexically_normal().wstring());
return std::filesystem::absolute(finalize(path)).lexically_normal().wstring();
}
template <typename string_t>
@ -239,6 +239,8 @@ template <typename string_t>
string_t path,
const std::vector<std::basic_string_view<typename string_t::value_type>>
&paths) -> string_t {
format_path(path, get_directory_seperator<typename string_t::value_type>(),
get_not_directory_seperator<typename string_t::value_type>());
return absolute(std::accumulate(
paths.begin(), paths.end(), path, [](auto next_path, auto &&path_part) {
if (next_path.empty()) {
@ -341,6 +343,9 @@ template <typename string_t>
[[nodiscard]] inline auto finalize_t(
std::basic_string_view<typename string_t::value_type> path) -> string_t {
string_t fmt_path{path};
format_path(fmt_path,
get_directory_seperator<typename string_t::value_type>(),
get_not_directory_seperator<typename string_t::value_type>());
#if defined(_WIN32)
if ((fmt_path.size() >= 2U) && (fmt_path.at(1U) == ':')) {
@ -368,7 +373,7 @@ format_path(string_t &path,
-> string_t & {
utils::string::replace(path, not_sep, sep);
string_t double_sep{2, sep.at(0U)};
string_t double_sep{2U, sep.at(0U)};
while (utils::string::contains(path, double_sep)) {
utils::string::replace(path, double_sep, sep);
}