aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortwinaphex2013-04-05 01:50:52 +0200
committertwinaphex2013-04-05 01:50:52 +0200
commit09e6db4fb1165f1c6034c3e2f6637024bb368e7d (patch)
tree5385af1c4e1ba2f3b8c3c6b8371e5715423bce4a
parent98175912f3cf2989569feca57f71aa98889f2786 (diff)
parentc9e5423e97341d1c10c2bc2c5f770cdf2dbd58b4 (diff)
downloadpcsx_rearmed-09e6db4fb1165f1c6034c3e2f6637024bb368e7d.tar.gz
pcsx_rearmed-09e6db4fb1165f1c6034c3e2f6637024bb368e7d.tar.bz2
pcsx_rearmed-09e6db4fb1165f1c6034c3e2f6637024bb368e7d.zip
Merge git://github.com/notaz/pcsx_rearmed
-rw-r--r--libpcsxcore/cdriso.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
index dde21bc..9ca4172 100644
--- a/libpcsxcore/cdriso.c
+++ b/libpcsxcore/cdriso.c
@@ -327,6 +327,14 @@ static int parsetoc(const char *isofile) {
return -1;
}
}
+ // 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) {
+ fclose(fi);
+ return -1;
+ }
+ fseek(fi, 0, SEEK_SET);
}
memset(&ti, 0, sizeof(ti));
@@ -1227,10 +1235,7 @@ static long CALLBACK ISOopen(void) {
CDR_getBuffer = ISOgetBuffer;
cdimg_read_func = cdread_normal;
- if (parsecue(GetIsoFile()) == 0) {
- SysPrintf("[+cue]");
- }
- else if (parsetoc(GetIsoFile()) == 0) {
+ if (parsetoc(GetIsoFile()) == 0) {
SysPrintf("[+toc]");
}
else if (parseccd(GetIsoFile()) == 0) {
@@ -1239,6 +1244,9 @@ static long CALLBACK ISOopen(void) {
else if (parsemds(GetIsoFile()) == 0) {
SysPrintf("[+mds]");
}
+ else if (parsecue(GetIsoFile()) == 0) {
+ SysPrintf("[+cue]");
+ }
if (handlepbp(GetIsoFile()) == 0) {
SysPrintf("[pbp]");
CDR_getBuffer = ISOgetBuffer_compr;
@@ -1257,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);