From d1e1c14dc3c5292a48818f3132ec53967352306c Mon Sep 17 00:00:00 2001 From: Eladash Date: Fri, 1 Jan 2021 12:07:14 +0200 Subject: [PATCH] VFS: Escape path components which end with space or period --- rpcs3/Emu/VFS.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index dcacef1c42..8ec32d504d 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -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(u8"."); break; + case ' ': result += reinterpret_cast(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 += '.';