VFS: escape multidot names like ...

This commit is contained in:
Nekotekina 2020-03-14 12:18:29 +03:00
parent 5d78d81c00
commit 0c65a1721d

View File

@ -280,6 +280,16 @@ using char2 = char;
std::string vfs::escape(std::string_view path, bool escape_slash)
{
std::string result;
if (path.size() > 2 && path.find_first_not_of('.') == umax)
{
// Path contains only dots, not allowed on Windows.
result.reserve(path.size() + 2);
result += reinterpret_cast<const char*>(u8"");
result += path.substr(1);
return result;
}
result.reserve(path.size());
for (std::size_t i = 0, s = path.size(); i < s; i++)
@ -493,6 +503,11 @@ std::string vfs::unescape(std::string_view path)
result += c;
continue;
}
case char2{u8""[2]}:
{
result += '.';
break;
}
case char2{u8""[2]}:
{
result += '<';