X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fcdriso.c;h=f7359ce94136f0918736c9fa070287eeeaf1535b;hb=4295c49158ad9ce6a20235d5ea5d45139ff63fe9;hp=36ff40556db2c35562b6bf76781169ed96da627c;hpb=92f43ab07c8daf13c89a96f61e0c8a2ccce8f32a;p=pcsx_rearmed.git diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 36ff4055..f7359ce9 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -329,8 +329,8 @@ static int parsetoc(const char *isofile) { } // check if it's really a TOC named as a .cue fgets(linebuf, sizeof(linebuf), fi); - token = strtok(tmp, " "); - if (strncmp(token, "CD", 2) != 0 && strcmp(token, "CATALOG") != 0) { + token = strtok(linebuf, " "); + if (token && strncmp(token, "CD", 2) != 0 && strcmp(token, "CATALOG") != 0) { fclose(fi); return -1; } @@ -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);