aboutsummaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
authornotaz2013-05-26 17:16:07 +0300
committernotaz2013-05-26 17:16:07 +0300
commit689e0447dd52128f79d4f3a6f90456e56cd459c0 (patch)
tree67f8ff621d3de7980f0fe0d379f8732ddefaed59 /libpcsxcore
parent4295c49158ad9ce6a20235d5ea5d45139ff63fe9 (diff)
downloadpcsx_rearmed-689e0447dd52128f79d4f3a6f90456e56cd459c0.tar.gz
pcsx_rearmed-689e0447dd52128f79d4f3a6f90456e56cd459c0.tar.bz2
pcsx_rearmed-689e0447dd52128f79d4f3a6f90456e56cd459c0.zip
cdriso: make sure to open correct file for cdda
Diffstat (limited to 'libpcsxcore')
-rw-r--r--libpcsxcore/cdriso.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
index f7359ce..bfa7d76 100644
--- a/libpcsxcore/cdriso.c
+++ b/libpcsxcore/cdriso.c
@@ -1213,6 +1213,8 @@ static void PrintTracks(void) {
// file for playback
static long CALLBACK ISOopen(void) {
boolean isMode1ISO = FALSE;
+ char alt_bin_filename[MAXPATHLEN];
+ const char *bin_filename;
if (cdHandle != NULL) {
return 0; // it's already open
@@ -1268,27 +1270,30 @@ static long CALLBACK ISOopen(void) {
fseek(cdHandle, 0, SEEK_END);
// maybe user selected metadata file instead of main .bin ..
+ bin_filename = GetIsoFile();
if (ftell(cdHandle) < 2352 * 0x10) {
static const char *exts[] = { ".bin", ".BIN", ".img", ".IMG" };
- char tmp[MAXPATHLEN], *p;
- FILE *tmpf;
+ FILE *tmpf = NULL;
size_t i;
+ char *p;
- strncpy(tmp, GetIsoFile(), sizeof(tmp));
- tmp[MAXPATHLEN - 1] = '\0';
- if (strlen(tmp) >= 4) {
- p = tmp + strlen(tmp) - 4;
+ strncpy(alt_bin_filename, bin_filename, sizeof(alt_bin_filename));
+ alt_bin_filename[MAXPATHLEN - 1] = '\0';
+ if (strlen(alt_bin_filename) >= 4) {
+ p = alt_bin_filename + strlen(alt_bin_filename) - 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);
+ tmpf = fopen(alt_bin_filename, "rb");
+ if (tmpf != NULL)
break;
- }
}
}
+ if (tmpf != NULL) {
+ bin_filename = alt_bin_filename;
+ fclose(cdHandle);
+ cdHandle = tmpf;
+ fseek(cdHandle, 0, SEEK_END);
+ }
}
// guess whether it is mode1/2048
@@ -1314,7 +1319,7 @@ static long CALLBACK ISOopen(void) {
// make sure we have another handle open for cdda
if (numtracks > 1 && ti[1].handle == NULL) {
- ti[1].handle = fopen(GetIsoFile(), "rb");
+ ti[1].handle = fopen(bin_filename, "rb");
}
cdda_cur_sector = 0;
cdda_file_offset = 0;