int file_open(const char *fname1, const char *fname2, const UINT32 crc, char *fname) { int found = 0, res = -1; struct zip_find_t file; char path[MAX_PATH]; file_close(); sprintf(path, "%s%c%s.zip", zip_dir, delimiter, fname1); if (zip_open(path, "rb") != -1) { if (zip_findfirst(&file)) { if (file.crc32 == crc) { found = 1; } else { while (zip_findnext(&file)) { if (file.crc32 == crc) { found = 1; break; } } } } if (!found) { if ((rom_fd = zopen(fname)) != -1) { file_close(); res = -2; } zip_close(); } } if (!found && fname2 != NULL) { sprintf(path, "%s%c%s.zip", zip_dir, delimiter, fname2); if (zip_open(path, "rb") != -1) { if (zip_findfirst(&file)) { if (file.crc32 == crc) { found = 2; } else { while (zip_findnext(&file)) { if (file.crc32 == crc) { found = 2; break; } } } } if (!found) { if ((rom_fd = zopen(fname)) != -1) { file_close(); res = -2; } zip_close(); } } } if (found) { if (fname) strcpy(fname, file.name); rom_fd = zopen(file.name); return rom_fd; } return res; }
int file_open(const char *fname1, const char *fname2, const u32 crc, char *fname) { int found = 0; struct zip_find_t file; char path[MAX_PATH]; sprintf(path, "%s/%s.zip", game_dir, fname1); if (zip_open(path) != -1) { if (zip_findfirst(&file)) { if (file.crc32 == crc) { found = 1; } else { while (zip_findnext(&file)) { if (file.crc32 == crc) { found = 1; break; } } } } if (!found) zip_close(); } if (!found && fname2 != NULL) { sprintf(path, "%s/%s.zip", game_dir, fname2); if (zip_open(path) != -1) { if (zip_findfirst(&file)) { if (file.crc32 == crc) { found = 1; } else { while (zip_findnext(&file)) { if (file.crc32 == crc) { found = 1; break; } } } } if (!found) zip_close(); } } if (found) { if (fname) strcpy(fname, file.name); rom_fd = zopen(file.name); return rom_fd; } return -1; }