From 1f163694875801f5d2559ead1af65079cc9ba961 Mon Sep 17 00:00:00 2001 From: stephena Date: Tue, 29 Jan 2013 21:12:37 +0000 Subject: [PATCH] Fixed ZIP handling in Windows; the '/' vs. '\' curse strikes again. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2591 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- Changes.txt | 3 +++ src/emucore/FSNode.cxx | 6 ++++++ src/emucore/FSNode.hxx | 6 ++++++ src/emucore/OSystem.cxx | 9 +++++++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Changes.txt b/Changes.txt index de050f686..eb0a860b8 100644 --- a/Changes.txt +++ b/Changes.txt @@ -33,6 +33,9 @@ * Fixed regression in M6532 INTIM reads; at least one known ROM (Mr. Roboto Berzerk hack) wasn't working properly. + * Fixed ZIP file handling in Windows when the archive contained + multiple files; in several cases the ROM wasn't being loaded at all. + -Have fun! diff --git a/src/emucore/FSNode.cxx b/src/emucore/FSNode.cxx index 03bb3f6cb..9f8e92e6b 100644 --- a/src/emucore/FSNode.cxx +++ b/src/emucore/FSNode.cxx @@ -51,6 +51,12 @@ bool FilesystemNode::operator<(const FilesystemNode& node) const return BSPF_strcasecmp(getDisplayName().c_str(), node.getDisplayName().c_str()) < 0; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool FilesystemNode::operator==(const FilesystemNode& node) const +{ + return BSPF_strcasecmp(getDisplayName().c_str(), node.getDisplayName().c_str()) == 0; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FilesystemNode::exists() const { diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index b772ffc9a..37f6bfcc9 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -131,6 +131,12 @@ class FilesystemNode */ bool operator<(const FilesystemNode& node) const; + /** + * Compare the name of this node to the name of another, testing for + * equality + */ + bool operator==(const FilesystemNode& node) const; + /** * Indicates whether the object referred by this path exists in the filesystem or not. * diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 2e9792ced..7a028a780 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -849,7 +849,9 @@ bool OSystem::loadFromZIP(const string& filename, uInt8** image, uInt32& size) } // Open archive + FilesystemNode searchnode(fileinzip); unzFile tz; + bool found = false; if((tz = unzOpen(archive.c_str())) != NULL) { if(unzGoToFirstFile(tz) == UNZ_OK) @@ -875,8 +877,11 @@ bool OSystem::loadFromZIP(const string& filename, uInt8** image, uInt32& size) BSPF_equalsIgnoreCase(ext, ".rom")) { // Either match the first file or the one we're looking for - if(fileinzip.empty() || fileinzip == currfile) + if(fileinzip.empty() || searchnode == FilesystemNode(currfile)) + { + found = true; break; + } } } @@ -886,7 +891,7 @@ bool OSystem::loadFromZIP(const string& filename, uInt8** image, uInt32& size) } // Now see if we got a valid image - if(ufo.uncompressed_size <= 0) + if(!found || ufo.uncompressed_size <= 0) { unzClose(tz); return true;