diff options
author | Ameer <aj662@drexel.edu> | 2020-07-14 19:04:02 +0200 |
---|---|---|
committer | Ameer <aj662@drexel.edu> | 2020-07-14 19:04:02 +0200 |
commit | 93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3 (patch) | |
tree | c4ab9e3acff296733b00effd85371bf04db6491f /src/core/file_sys/vfs_real.cpp | |
parent | Break out of scan loop if can't find adapter on first run (diff) | |
parent | Merge pull request #4294 from MerryMage/cpu-opt-settings (diff) | |
download | yuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.tar yuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.tar.gz yuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.tar.bz2 yuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.tar.lz yuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.tar.xz yuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.tar.zst yuzu-93fe982a0c3a5bfb7fa5df97ebced0a7692ccaf3.zip |
Diffstat (limited to 'src/core/file_sys/vfs_real.cpp')
-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_ const auto new_path = FileUtil::SanitizePath(new_path_, FileUtil::DirectorySeparator::PlatformDefault); - if (!FileUtil::Exists(old_path) || FileUtil::Exists(new_path) || - FileUtil::IsDirectory(old_path) || !FileUtil::Rename(old_path, new_path)) - return nullptr; - if (cache.find(old_path) != cache.end()) { - auto cached = cache[old_path]; - if (!cached.expired()) { - auto file = cached.lock(); - file->Open(new_path, "r+b"); - cache.erase(old_path); - cache[new_path] = file; + auto file = cache[old_path].lock(); + + if (!cache[old_path].expired()) { + file->Close(); + } + + if (!FileUtil::Exists(old_path) || FileUtil::Exists(new_path) || + FileUtil::IsDirectory(old_path) || !FileUtil::Rename(old_path, new_path)) { + return nullptr; } + + cache.erase(old_path); + file->Open(new_path, "r+b"); + cache[new_path] = file; + } else { + UNREACHABLE(); + return nullptr; } + return OpenFile(new_path, Mode::ReadWrite); } |