MCPcopy Create free account
hub / github.com/citron-neo/emulator / GetGameFileFromPath

Function GetGameFileFromPath

src/core/core.cpp:124–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122namespace Core {
123
124FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
125 const std::string& path) {
126 // To account for split 00+01+etc files.
127 std::string dir_name;
128 std::string filename;
129 Common::SplitPath(path, &dir_name, &filename, nullptr);
130
131 if (filename == "00") {
132 const auto dir = vfs->OpenDirectory(dir_name, FileSys::OpenMode::Read);
133 std::vector<FileSys::VirtualFile> concat;
134
135 for (u32 i = 0; i < 0x10; ++i) {
136 const auto file_name = fmt::format("{:02X}", i);
137 auto next = dir->GetFile(file_name);
138
139 if (next != nullptr) {
140 concat.push_back(std::move(next));
141 } else {
142 next = dir->GetFile(file_name);
143
144 if (next == nullptr) {
145 break;
146 }
147
148 concat.push_back(std::move(next));
149 }
150 }
151
152 return FileSys::ConcatenatedVfsFile::MakeConcatenatedFile(dir->GetName(),
153 std::move(concat));
154 }
155
156 if (Common::FS::IsDir(path)) {
157 return vfs->OpenFile(path + "/main", FileSys::OpenMode::Read);
158 }
159
160 return vfs->OpenFile(path, FileSys::OpenMode::Read);
161}
162
163struct System::Impl {
164 explicit Impl(System& system)

Callers 7

LoadMethod · 0.85
CacheRomMetadataFunction · 0.85
BootGameMethod · 0.85
OnGameListOpenFolderMethod · 0.85

Calls 7

SplitPathFunction · 0.85
IsDirFunction · 0.50
OpenDirectoryMethod · 0.45
GetFileMethod · 0.45
push_backMethod · 0.45
GetNameMethod · 0.45
OpenFileMethod · 0.45

Tested by

no test coverage detected