VFS: Escape path components which end with space or period

This commit is contained in:
Eladash 2021-01-01 12:07:14 +02:00 committed by Ivan
parent 11db3151ae
commit d1e1c14dc3
1 changed files with 23 additions and 0 deletions

View File

@ -450,6 +450,24 @@ std::string vfs::escape(std::string_view name, bool escape_slash)
result += c;
break;
}
case '.':
case ' ':
{
if (!get_char(i + 1))
{
switch (c)
{
// Directory name ended with a space or a period, not allowed on Windows.
case '.': result += reinterpret_cast<const char*>(u8""); break;
case ' ': result += reinterpret_cast<const char*>(u8"_"); break;
}
break;
}
result += c;
break;
}
case char2{u8""[0]}:
{
// Escape full-width characters 0xFF01..0xFF5e with (0xFF01)
@ -585,6 +603,11 @@ std::string vfs::unescape(std::string_view name)
i += 3;
continue;
}
case char2{u8"_"[2]}:
{
result += ' ';
break;
}
case char2{u8""[2]}:
{
result += '.';