Skip to content

Commit 0b4dfb8

Browse files
authored
Merge pull request #18924 from hrydgard/chd-detection-fixes
Fix a bunch of cases where we forgot to check for CHD files
2 parents a0aaab9 + 55974f6 commit 0b4dfb8

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

Core/FileSystems/DirectoryFileSystem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(const std::string &p
830830
entry.name = file.name;
831831
}
832832
if (hideISOFiles) {
833-
if (endsWithNoCase(entry.name, ".cso") || endsWithNoCase(entry.name, ".iso")) {
833+
if (endsWithNoCase(entry.name, ".cso") || endsWithNoCase(entry.name, ".iso") || endsWithNoCase(entry.name, ".chd")) { // chd not really necessary, but let's hide them too.
834834
// Workaround for DJ Max Portable, see compat.ini.
835835
continue;
836836
} else if (file.isDirectory) {

Core/Loaders.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader, std::string *errorStrin
9292
// maybe it also just happened to have that size, let's assume it's a PSP ISO and error out later if it's not.
9393
}
9494
return IdentifiedFileType::PSP_ISO;
95-
} else if (extension == ".cso") {
96-
return IdentifiedFileType::PSP_ISO;
97-
} else if (extension == ".chd") {
95+
} else if (extension == ".cso" || extension == ".chd") {
9896
return IdentifiedFileType::PSP_ISO;
9997
} else if (extension == ".ppst") {
10098
return IdentifiedFileType::PPSSPP_SAVESTATE;
@@ -170,6 +168,11 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader, std::string *errorStrin
170168
// CISO are not used for many other kinds of ISO so let's just guess it's a PSP one and let it
171169
// fail later...
172170
return IdentifiedFileType::PSP_ISO;
171+
} else if (!memcmp(&_id, "MCom", 4)) {
172+
size_t readSize = fileLoader->ReadAt(4, 4, 1, &_id);
173+
if (!memcmp(&_id, "prHD", 4)) {
174+
return IdentifiedFileType::PSP_ISO; // CHD file
175+
}
173176
}
174177

175178
if (id == 'FLE\x7F') {

Core/Util/GameManager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ ZipFileContents DetectZipFileContents(struct zip *z, ZipFileInfo *info) {
244244
} else {
245245
INFO_LOG(HLE, "Wrong number of slashes (%i) in '%s'", slashCount, fn);
246246
}
247-
} else if (endsWith(zippedName, ".iso") || endsWith(zippedName, ".cso")) {
247+
} else if (endsWith(zippedName, ".iso") || endsWith(zippedName, ".cso") || endsWith(zippedName, ".chd")) {
248248
int slashCount = 0;
249249
int slashLocation = -1;
250250
countSlashes(zippedName, &slashLocation, &slashCount);
@@ -304,7 +304,7 @@ bool GameManager::InstallGame(const Path &url, const Path &fileName, bool delete
304304

305305
std::string extension = url.GetFileExtension();
306306
// Examine the URL to guess out what we're installing.
307-
if (extension == ".cso" || extension == ".iso") {
307+
if (extension == ".cso" || extension == ".iso" || extension == ".chd") {
308308
// It's a raw ISO or CSO file. We just copy it to the destination.
309309
std::string shortFilename = url.GetFilename();
310310
bool success = InstallRawISO(fileName, shortFilename, deleteAfter);

UWP/PPSSPP_UWPMain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
502502
std::vector<std::string> supportedExtensions = {};
503503
switch ((BrowseFileType)param3) {
504504
case BrowseFileType::BOOTABLE:
505-
supportedExtensions = { ".cso", ".bin", ".iso", ".elf", ".pbp", ".zip" };
505+
supportedExtensions = { ".cso", ".iso", ".chd", ".elf", ".pbp", ".zip", ".prx", ".bin" }; // should .bin even be here?
506506
break;
507507
case BrowseFileType::INI:
508508
supportedExtensions = { ".ini" };

0 commit comments

Comments
 (0)