From 5797673daada281e8b60fa6467bd10ecd4792a7e Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sat, 26 Feb 2022 11:30:16 +0100 Subject: [PATCH] fix vfs::host::rename. - resolve_path requires the path to be valid and can only be used before the call to fs::rename, not after. --- rpcs3/Emu/VFS.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index 966214a31e..6ca8b2072a 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -752,9 +752,11 @@ bool vfs::host::rename(const std::string& from, const std::string& to, const lv2 return path.starts_with(from) && (path.size() == from.size() || path[from.size()] == fs::delim[0] || path[from.size()] == fs::delim[1]); }; - idm::select([&](u32 /*id*/, lv2_file& file) + std::map escaped_real; + idm::select([&](u32 id, lv2_file& file) { - if (check_path(Emu.GetCallbacks().resolve_path(file.real_path))) + escaped_real[id] = Emu.GetCallbacks().resolve_path(file.real_path); + if (check_path(escaped_real[id])) { ensure(file.mp == mp); @@ -794,11 +796,9 @@ bool vfs::host::rename(const std::string& from, const std::string& to, const lv2 const auto fs_error = fs::g_tls_error; - idm::select([&](u32 /*id*/, lv2_file& file) + idm::select([&](u32 id, lv2_file& file) { - const auto escaped_real = Emu.GetCallbacks().resolve_path(file.real_path); - - if (check_path(escaped_real)) + if (check_path(escaped_real[id])) { if (file.restore_data.seek_pos == umax) { @@ -808,7 +808,7 @@ bool vfs::host::rename(const std::string& from, const std::string& to, const lv2 // Update internal path if (res) { - file.real_path = to + (escaped_real != escaped_from ? '/' + file.real_path.substr(from0.size()) : ""s); + file.real_path = to + (escaped_real[id] != escaped_from ? '/' + file.real_path.substr(from0.size()) : ""s); } // Reopen with ignored TRUNC, APPEND, CREATE and EXCL flags