diff options
Diffstat (limited to 'src/lib/util/zippath.cpp')
-rw-r--r-- | src/lib/util/zippath.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp index 9d2e51a6833..6fad365d6fc 100644 --- a/src/lib/util/zippath.cpp +++ b/src/lib/util/zippath.cpp @@ -48,7 +48,7 @@ int is_path_separator(char c) bool is_root(std::string_view path) { -#if defined(WIN32) +#if defined(_WIN32) // FIXME: don't assume paths are DOS-like - UNC paths, \\?\ long path prefix, etc. complicate this // skip drive letter @@ -58,8 +58,7 @@ bool is_root(std::string_view path) // skip path separators return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos; #else - // FIXME: handle multiple successive path separators, current directory references, parent directory references - return (path.length() == 1) && (path[0] == '/'); + return path.find_first_not_of(PATH_SEPARATOR) == std::string_view::npos; #endif } @@ -208,14 +207,11 @@ std::error_condition zippath_resolve(std::string_view path, osd::directory::entr bool went_up = false; do { - if (!is_root(apath)) - { - // trim the path of trailing path separators - auto i = apath.find_last_not_of(PATH_SEPARATOR); - if (i == std::string::npos) - break; - apath = apath.substr(0, i + 1); - } + // trim the path of trailing path separators + auto i = apath.find_last_not_of(PATH_SEPARATOR); + if (i == std::string::npos) + break; + apath = apath.erase(std::min<decltype(i)>(i + 1, 2)); apath_trimmed = apath; @@ -613,7 +609,7 @@ std::string &zippath_combine(std::string &dst, const std::string &path1, const s { dst.assign(path2); } - else if (!path1.empty() && !is_path_separator(*path1.rbegin())) + else if (!path1.empty() && !is_path_separator(path1.back())) { dst.assign(path1).append(PATH_SEPARATOR).append(path2); } |