| 122 | namespace Core { |
| 123 | |
| 124 | FileSys::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 | |
| 163 | struct System::Impl { |
| 164 | explicit Impl(System& system) |
no test coverage detected