diff options
author | bunnei <bunneidev@gmail.com> | 2020-11-28 02:23:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-28 02:23:00 +0100 |
commit | 1fde40b2c7222bc560ed8e9c6a87453cc9dd573f (patch) | |
tree | 1ac2f73e34756dba0a2b5d6fd9a9fee520d27391 | |
parent | Merge pull request #5014 from comex/xx-invalid-offsetof (diff) | |
parent | core: Reduce string copies in GetGameFileFromPath() (diff) | |
download | yuzu-1fde40b2c7222bc560ed8e9c6a87453cc9dd573f.tar yuzu-1fde40b2c7222bc560ed8e9c6a87453cc9dd573f.tar.gz yuzu-1fde40b2c7222bc560ed8e9c6a87453cc9dd573f.tar.bz2 yuzu-1fde40b2c7222bc560ed8e9c6a87453cc9dd573f.tar.lz yuzu-1fde40b2c7222bc560ed8e9c6a87453cc9dd573f.tar.xz yuzu-1fde40b2c7222bc560ed8e9c6a87453cc9dd573f.tar.zst yuzu-1fde40b2c7222bc560ed8e9c6a87453cc9dd573f.zip |
-rw-r--r-- | src/core/core.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index f4bbc9ec3..76a38ea2a 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -91,33 +91,43 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, std::string dir_name; std::string filename; Common::SplitPath(path, &dir_name, &filename, nullptr); + if (filename == "00") { const auto dir = vfs->OpenDirectory(dir_name, FileSys::Mode::Read); std::vector<FileSys::VirtualFile> concat; - for (u8 i = 0; i < 0x10; ++i) { - auto next = dir->GetFile(fmt::format("{:02X}", i)); - if (next != nullptr) + + for (u32 i = 0; i < 0x10; ++i) { + const auto file_name = fmt::format("{:02X}", i); + auto next = dir->GetFile(file_name); + + if (next != nullptr) { concat.push_back(std::move(next)); - else { - next = dir->GetFile(fmt::format("{:02x}", i)); - if (next != nullptr) - concat.push_back(std::move(next)); - else + } else { + next = dir->GetFile(file_name); + + if (next == nullptr) { break; + } + + concat.push_back(std::move(next)); } } - if (concat.empty()) + if (concat.empty()) { return nullptr; + } - return FileSys::ConcatenatedVfsFile::MakeConcatenatedFile(concat, dir->GetName()); + return FileSys::ConcatenatedVfsFile::MakeConcatenatedFile(std::move(concat), + dir->GetName()); } - if (Common::FS::IsDirectory(path)) - return vfs->OpenFile(path + "/" + "main", FileSys::Mode::Read); + if (Common::FS::IsDirectory(path)) { + return vfs->OpenFile(path + "/main", FileSys::Mode::Read); + } return vfs->OpenFile(path, FileSys::Mode::Read); } + struct System::Impl { explicit Impl(System& system) : kernel{system}, fs_controller{system}, memory{system}, |