+ // No filename extension == YUO FAIL IT (it is loading the file).
+ // This is naive, but it works. But should probably come up with something a little
+ // more robust, to prevent problems with dopes trying to exploit this.
+ if (ext == NULL)
- WriteLog("VJ: Loading \"%s\"...", path);
-
- if (strcasecmp(ext, ".zip") == 0)
- {
- // Handle ZIP file loading here...
- WriteLog("(ZIPped)...");
+ WriteLog("FAILED!\n");
+ return 0;
+ }
- if (load_zipped_file(0, 0, path, NULL, &rom, &romSize) == -1)
- {
- WriteLog("Failed!\n");
- return 0;
- }
- }
- else
- {
-/* FILE * fp = fopen(path, "rb");
+ WriteLog("Succeeded in finding extension (%s)!\n", ext);
+ WriteLog("VJ: Loading \"%s\"...", path);
- fseek(fp, 0, SEEK_END);
- romSize = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- fread(rom, 1, romSize, fp);
- fclose(fp);*/
+ uint8_t * buffer = NULL;
+ romSize = GetFileFromZIP(path, FT_SOFTWARE, buffer);
- gzFile fp = gzopen(path, "rb");
+ memcpy(rom, buffer, romSize);
+ delete[] buffer;
+ }
+ else
+ {
+ // Handle gzipped files transparently [Adam Green]...
- romSize = gzfilelength(fp);
- gzseek(fp, 0, SEEK_SET);
- gzread(fp, rom, romSize);
- gzclose(fp);
+ if (fp == NULL)
+ {
+ WriteLog("Failed!\n");
+ return 0;
- WriteLog("OK (%i bytes)\n", romSize);
+ romSize = gzfilelength(fp);
+ gzseek(fp, 0, SEEK_SET);
+ gzread(fp, rom, romSize);
+ gzclose(fp);
char * ext = strrchr(path, '.'); // Get the file's extension for non-cartridge checking
//NOTE: Should fix JaguarLoadROM() to replace .zip with what's *in* the zip (.abs, .j64, etc.)
char * ext = strrchr(path, '.'); // Get the file's extension for non-cartridge checking
//NOTE: Should fix JaguarLoadROM() to replace .zip with what's *in* the zip (.abs, .j64, etc.)
if (strcasecmp(ext, ".rom") == 0)
{
// File extension ".ROM": Alpine image that loads/runs at $802000
if (strcasecmp(ext, ".rom") == 0)
{
// File extension ".ROM": Alpine image that loads/runs at $802000
#warning "!!! FIX !!! Should have sanity checking for ROM size to prevent buffer overflow!"
const char ftStrings[5][32] = { "Software", "EEPROM", "Label", "Box Art", "Controller Overlay" };
ZIP * zip = openzip(0, 0, zipFile);
#warning "!!! FIX !!! Should have sanity checking for ROM size to prevent buffer overflow!"
const char ftStrings[5][32] = { "Software", "EEPROM", "Label", "Box Art", "Controller Overlay" };
ZIP * zip = openzip(0, 0, zipFile);
+ // Here we simply rely on the file extension to tell the truth, but we know
+ // that extensions lie like sons-a-bitches. So this is naive, we need to do
+ // something a little more robust to keep bad things from happening here.
+#warning "!!! Checking for image by extension can be fooled !!!"
if ((type == FT_LABEL) && (CheckExtension(ze->name, ".png") || CheckExtension(ze->name, ".jpg") || CheckExtension(ze->name, ".gif")))
{
found = true;
if ((type == FT_LABEL) && (CheckExtension(ze->name, ".png") || CheckExtension(ze->name, ".jpg") || CheckExtension(ze->name, ".gif")))
{
found = true;
buffer = new uint8[ze->uncompressed_size];
if (readuncompresszip(zip, ze, (char *)buffer) == 0)
{
WriteLog("success! (%u bytes)\n", ze->uncompressed_size);
buffer = new uint8[ze->uncompressed_size];
if (readuncompresszip(zip, ze, (char *)buffer) == 0)
{
WriteLog("success! (%u bytes)\n", ze->uncompressed_size);