aboutsummaryrefslogtreecommitdiff
path: root/libpcsxcore/cdriso.c
diff options
context:
space:
mode:
authornotaz2013-04-05 02:09:24 +0300
committernotaz2013-04-05 02:40:19 +0300
commitc9e5423e97341d1c10c2bc2c5f770cdf2dbd58b4 (patch)
tree1f9048c994eb8545514dbf5a5b8b9ff57ded5a60 /libpcsxcore/cdriso.c
parent92f43ab07c8daf13c89a96f61e0c8a2ccce8f32a (diff)
downloadpcsx_rearmed-c9e5423e97341d1c10c2bc2c5f770cdf2dbd58b4.tar.gz
pcsx_rearmed-c9e5423e97341d1c10c2bc2c5f770cdf2dbd58b4.tar.bz2
pcsx_rearmed-c9e5423e97341d1c10c2bc2c5f770cdf2dbd58b4.zip
cdriso: look for data files if other one is selected
Diffstat (limited to 'libpcsxcore/cdriso.c')
-rw-r--r--libpcsxcore/cdriso.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
index 36ff405..9ca4172 100644
--- a/libpcsxcore/cdriso.c
+++ b/libpcsxcore/cdriso.c
@@ -1265,8 +1265,33 @@ static long CALLBACK ISOopen(void) {
SysPrintf("[+sbi]");
}
- // guess whether it is mode1/2048
fseek(cdHandle, 0, SEEK_END);
+
+ // maybe user selected metadata file instead of main .bin ..
+ if (ftell(cdHandle) < 2352 * 0x10) {
+ static const char *exts[] = { ".bin", ".BIN", ".img", ".IMG" };
+ char tmp[MAXPATHLEN], *p;
+ FILE *tmpf;
+ size_t i;
+
+ strncpy(tmp, GetIsoFile(), sizeof(tmp));
+ tmp[MAXPATHLEN - 1] = '\0';
+ if (strlen(tmp) >= 4) {
+ p = tmp + strlen(tmp) - 4;
+ for (i = 0; i < sizeof(exts) / sizeof(exts[0]); i++) {
+ strcpy(p, exts[i]);
+ tmpf = fopen(tmp, "rb");
+ if (tmpf != NULL) {
+ fclose(cdHandle);
+ cdHandle = tmpf;
+ fseek(cdHandle, 0, SEEK_END);
+ break;
+ }
+ }
+ }
+ }
+
+ // guess whether it is mode1/2048
if (ftell(cdHandle) % 2048 == 0) {
unsigned int modeTest = 0;
fseek(cdHandle, 0, SEEK_SET);