+ fseeko(cdHandle, 0, SEEK_END);
+
+ // maybe user selected metadata file instead of main .bin ..
+ bin_filename = GetIsoFile();
+ if (ftello(cdHandle) < 2352 * 0x10) {
+ static const char *exts[] = { ".bin", ".BIN", ".img", ".IMG" };
+ FILE *tmpf = NULL;
+ size_t i;
+ char *p;
+
+ 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(alt_bin_filename, "rb");
+ if (tmpf != NULL)
+ break;
+ }
+ }
+ if (tmpf != NULL) {
+ bin_filename = alt_bin_filename;
+ fclose(cdHandle);
+ cdHandle = tmpf;
+ fseeko(cdHandle, 0, SEEK_END);
+ }
+ }
+