diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-08-10 02:48:41 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-08-12 04:50:48 +0200 |
commit | 95bb1067c1bd78bcd4c346f0445af9d9217743fc (patch) | |
tree | 51c460422b8d8319c795bd639e312cbcb40723a3 /src/core/core.cpp | |
parent | loader: Recognize filename '00' as NCA (diff) | |
download | yuzu-95bb1067c1bd78bcd4c346f0445af9d9217743fc.tar yuzu-95bb1067c1bd78bcd4c346f0445af9d9217743fc.tar.gz yuzu-95bb1067c1bd78bcd4c346f0445af9d9217743fc.tar.bz2 yuzu-95bb1067c1bd78bcd4c346f0445af9d9217743fc.tar.lz yuzu-95bb1067c1bd78bcd4c346f0445af9d9217743fc.tar.xz yuzu-95bb1067c1bd78bcd4c346f0445af9d9217743fc.tar.zst yuzu-95bb1067c1bd78bcd4c346f0445af9d9217743fc.zip |
Diffstat (limited to 'src/core/core.cpp')
-rw-r--r-- | src/core/core.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 83d4d742b..05af68f22 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -17,6 +17,7 @@ #include "core/hle/service/sm/sm.h" #include "core/loader/loader.h" #include "core/settings.h" +#include "file_sys/vfs_concat.h" #include "file_sys/vfs_real.h" #include "video_core/renderer_base.h" #include "video_core/video_core.h" @@ -88,8 +89,39 @@ System::ResultStatus System::SingleStep() { return RunLoop(false); } +static FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, + const std::string& path) { + // To account for split 00+01+etc files. + 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) + concat.push_back(std::move(next)); + else { + next = dir->GetFile(fmt::format("{:02x}", i)); + if (next != nullptr) + concat.push_back(std::move(next)); + else + break; + } + } + + if (concat.empty()) + return nullptr; + + return FileSys::ConcatenateFiles(concat, dir->GetName()); + } + + return vfs->OpenFile(path, FileSys::Mode::Read); +} + System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) { - app_loader = Loader::GetLoader(virtual_filesystem->OpenFile(filepath, FileSys::Mode::Read)); + app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath)); if (!app_loader) { LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); |