mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
refs #33, fix for lexically_normal
This commit is contained in:
parent
cf5188899b
commit
9db85faf14
@ -2621,6 +2621,7 @@ GHC_INLINE bool path::is_relative() const
|
||||
GHC_INLINE path path::lexically_normal() const
|
||||
{
|
||||
path dest;
|
||||
bool lastDotDot = false;
|
||||
for (const string_type& s : *this) {
|
||||
if (s == ".") {
|
||||
dest /= "";
|
||||
@ -2639,17 +2640,14 @@ GHC_INLINE path path::lexically_normal() const
|
||||
continue;
|
||||
}
|
||||
}
|
||||
dest /= s;
|
||||
if (!(s.empty() && lastDotDot)) {
|
||||
dest /= s;
|
||||
}
|
||||
lastDotDot = s == "..";
|
||||
}
|
||||
if (dest.empty()) {
|
||||
dest = ".";
|
||||
}
|
||||
else {
|
||||
static const path suffix[2] = {"", ".."};
|
||||
if(std::equal(std::reverse_iterator<path::const_iterator>(dest.end()), std::reverse_iterator<path::const_iterator>(dest.begin()), suffix)) {
|
||||
dest._path.pop_back();
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user