diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/vfs_real.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp index e21300a7c..96ce5957c 100644 --- a/src/core/file_sys/vfs_real.cpp +++ b/src/core/file_sys/vfs_real.cpp | |||
| @@ -112,19 +112,26 @@ VirtualFile RealVfsFilesystem::MoveFile(std::string_view old_path_, std::string_ | |||
| 112 | const auto new_path = | 112 | const auto new_path = |
| 113 | FileUtil::SanitizePath(new_path_, FileUtil::DirectorySeparator::PlatformDefault); | 113 | FileUtil::SanitizePath(new_path_, FileUtil::DirectorySeparator::PlatformDefault); |
| 114 | 114 | ||
| 115 | if (!FileUtil::Exists(old_path) || FileUtil::Exists(new_path) || | ||
| 116 | FileUtil::IsDirectory(old_path) || !FileUtil::Rename(old_path, new_path)) | ||
| 117 | return nullptr; | ||
| 118 | |||
| 119 | if (cache.find(old_path) != cache.end()) { | 115 | if (cache.find(old_path) != cache.end()) { |
| 120 | auto cached = cache[old_path]; | 116 | auto file = cache[old_path].lock(); |
| 121 | if (!cached.expired()) { | 117 | |
| 122 | auto file = cached.lock(); | 118 | if (!cache[old_path].expired()) { |
| 123 | file->Open(new_path, "r+b"); | 119 | file->Close(); |
| 124 | cache.erase(old_path); | 120 | } |
| 125 | cache[new_path] = file; | 121 | |
| 122 | if (!FileUtil::Exists(old_path) || FileUtil::Exists(new_path) || | ||
| 123 | FileUtil::IsDirectory(old_path) || !FileUtil::Rename(old_path, new_path)) { | ||
| 124 | return nullptr; | ||
| 126 | } | 125 | } |
| 126 | |||
| 127 | cache.erase(old_path); | ||
| 128 | file->Open(new_path, "r+b"); | ||
| 129 | cache[new_path] = file; | ||
| 130 | } else { | ||
| 131 | UNREACHABLE(); | ||
| 132 | return nullptr; | ||
| 127 | } | 133 | } |
| 134 | |||
| 128 | return OpenFile(new_path, Mode::ReadWrite); | 135 | return OpenFile(new_path, Mode::ReadWrite); |
| 129 | } | 136 | } |
| 130 | 137 | ||