* IsValidROM * * Checks if the specified file is a valid ROM * For now we will just check the file extension and file size * If the file is a zip, we will check the file extension / file size of the * first file inside ***************************************************************************/
| 402 | * first file inside |
| 403 | ***************************************************************************/ |
| 404 | static bool IsValidROM() |
| 405 | { |
| 406 | if (strlen(browserList[browser.selIndex].filename) > 4) |
| 407 | { |
| 408 | char * p = strrchr(browserList[browser.selIndex].filename, '.'); |
| 409 | |
| 410 | if (p != NULL) |
| 411 | { |
| 412 | if(strcasecmp(p, ".gba") == 0) |
| 413 | { |
| 414 | // File will be checked for GBA ROMs later. |
| 415 | return true; |
| 416 | } |
| 417 | |
| 418 | char * zippedFilename = NULL; |
| 419 | |
| 420 | if(strcasecmp(p, ".zip") == 0 && !inSz) |
| 421 | { |
| 422 | // we need to check the file extension of the first file in the archive |
| 423 | zippedFilename = GetFirstZipFilename (); |
| 424 | |
| 425 | if(zippedFilename && strlen(zippedFilename) > 4) |
| 426 | p = strrchr(zippedFilename, '.'); |
| 427 | else |
| 428 | p = NULL; |
| 429 | } |
| 430 | |
| 431 | if(p != NULL) |
| 432 | { |
| 433 | if ( |
| 434 | strcasecmp(p, ".nes") == 0 || |
| 435 | strcasecmp(p, ".fds") == 0 || |
| 436 | strcasecmp(p, ".nsf") == 0 || |
| 437 | strcasecmp(p, ".unf") == 0 || |
| 438 | strcasecmp(p, ".nez") == 0 || |
| 439 | strcasecmp(p, ".unif") == 0 |
| 440 | ) |
| 441 | { |
| 442 | if(zippedFilename) free(zippedFilename); |
| 443 | return true; |
| 444 | } |
| 445 | } |
| 446 | if(zippedFilename) free(zippedFilename); |
| 447 | } |
| 448 | } |
| 449 | ErrorPrompt("Unknown file type!"); |
| 450 | return false; |
| 451 | } |
| 452 | |
| 453 | /**************************************************************************** |
| 454 | * IsSz |
no test coverage detected