summaryrefslogtreecommitdiff
path: root/src/core/core.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-08-15 23:11:58 -0400
committerGravatar GitHub2018-08-15 23:11:58 -0400
commitc594ec341768a54dc2577c64fd15a6c0041456cd (patch)
tree3814f831fd8207598c342341e56997a0b3123cd0 /src/core/core.cpp
parentMerge pull request #1078 from lioncash/message (diff)
parentregistration: Various style and documentation improvements (diff)
downloadyuzu-c594ec341768a54dc2577c64fd15a6c0041456cd.tar.gz
yuzu-c594ec341768a54dc2577c64fd15a6c0041456cd.tar.xz
yuzu-c594ec341768a54dc2577c64fd15a6c0041456cd.zip
Merge pull request #1005 from DarkLordZach/registered-fmt
file_sys: Add support for registration format
Diffstat (limited to 'src/core/core.cpp')
-rw-r--r--src/core/core.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 83d4d742b..28038ff6f 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -5,6 +5,7 @@
5#include <memory> 5#include <memory>
6#include <utility> 6#include <utility>
7#include "common/logging/log.h" 7#include "common/logging/log.h"
8#include "common/string_util.h"
8#include "core/core.h" 9#include "core/core.h"
9#include "core/core_timing.h" 10#include "core/core_timing.h"
10#include "core/gdbstub/gdbstub.h" 11#include "core/gdbstub/gdbstub.h"
@@ -17,6 +18,7 @@
17#include "core/hle/service/sm/sm.h" 18#include "core/hle/service/sm/sm.h"
18#include "core/loader/loader.h" 19#include "core/loader/loader.h"
19#include "core/settings.h" 20#include "core/settings.h"
21#include "file_sys/vfs_concat.h"
20#include "file_sys/vfs_real.h" 22#include "file_sys/vfs_real.h"
21#include "video_core/renderer_base.h" 23#include "video_core/renderer_base.h"
22#include "video_core/video_core.h" 24#include "video_core/video_core.h"
@@ -88,8 +90,39 @@ System::ResultStatus System::SingleStep() {
88 return RunLoop(false); 90 return RunLoop(false);
89} 91}
90 92
93static FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
94 const std::string& path) {
95 // To account for split 00+01+etc files.
96 std::string dir_name;
97 std::string filename;
98 Common::SplitPath(path, &dir_name, &filename, nullptr);
99 if (filename == "00") {
100 const auto dir = vfs->OpenDirectory(dir_name, FileSys::Mode::Read);
101 std::vector<FileSys::VirtualFile> concat;
102 for (u8 i = 0; i < 0x10; ++i) {
103 auto next = dir->GetFile(fmt::format("{:02X}", i));
104 if (next != nullptr)
105 concat.push_back(std::move(next));
106 else {
107 next = dir->GetFile(fmt::format("{:02x}", i));
108 if (next != nullptr)
109 concat.push_back(std::move(next));
110 else
111 break;
112 }
113 }
114
115 if (concat.empty())
116 return nullptr;
117
118 return FileSys::ConcatenateFiles(concat, dir->GetName());
119 }
120
121 return vfs->OpenFile(path, FileSys::Mode::Read);
122}
123
91System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) { 124System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) {
92 app_loader = Loader::GetLoader(virtual_filesystem->OpenFile(filepath, FileSys::Mode::Read)); 125 app_loader = Loader::GetLoader(GetGameFileFromPath(virtual_filesystem, filepath));
93 126
94 if (!app_loader) { 127 if (!app_loader) {
95 LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); 128 LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath);