aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti2008-10-09 18:51:26 +0000
committerVicent Marti2008-10-09 18:51:26 +0000
commitf2f25aa84007402bbcea4b8ffc02d780a35d688d (patch)
treee5d7eb48c3b9e34c850e859bf2f8e7ec7fa18820
parentc3b1e3416371b8a54721c53a17920f1bc9458772 (diff)
downloadscummvm-rg350-f2f25aa84007402bbcea4b8ffc02d780a35d688d.tar.gz
scummvm-rg350-f2f25aa84007402bbcea4b8ffc02d780a35d688d.tar.bz2
scummvm-rg350-f2f25aa84007402bbcea4b8ffc02d780a35d688d.zip
Fixed warning when loading themes contained inside a folder.
svn-id: r34763
-rw-r--r--gui/ThemeEngine.cpp61
1 files changed, 33 insertions, 28 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 5ed142cb31..0dce3e5dd8 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -534,44 +534,49 @@ bool ThemeEngine::loadThemeXML(Common::String themeName) {
int parseCount = 0;
bool failed = false;
+ FSNode node(themeName);
+ if (!node.exists() || !node.isReadable())
+ return false;
+
#ifdef USE_ZLIB
- Common::ZipArchive zipFile(themeName.c_str());
- Common::ArchiveMemberList zipContents;
+ if (node.getPath().hasSuffix(".zip") && !node.isDirectory()) {
+ Common::ZipArchive zipFile(node);
+ Common::ArchiveMemberList zipContents;
- if (zipFile.isOpen() && zipFile.listMembers(zipContents)) {
-
-// for (uint i = 0; i < zipContents.size(); ++i) {
- for (Common::ArchiveMemberList::iterator za = zipContents.begin(); za != zipContents.end(); ++za) {
- if (!failed && matchString((*za)->getName().c_str(), "*.stx")) {
- if (parser()->loadStream((*za)->open()) == false) {
- warning("Failed to load stream for zipped file '%s'", fileNameBuffer);
- failed = true;
- }
+ if (zipFile.isOpen() && zipFile.listMembers(zipContents)) {
+ for (Common::ArchiveMemberList::iterator za = zipContents.begin(); za != zipContents.end(); ++za) {
+ if (!failed && matchString((*za)->getName().c_str(), "*.stx")) {
+ if (parser()->loadStream((*za)->open()) == false) {
+ warning("Failed to load stream for zipped file '%s'", fileNameBuffer);
+ failed = true;
+ }
- if (parser()->parse() == false) {
- warning("Theme parsing failed on zipped file '%s'.", fileNameBuffer);
- failed = true;
- }
+ if (parser()->parse() == false) {
+ warning("Theme parsing failed on zipped file '%s'.", fileNameBuffer);
+ failed = true;
+ }
- parser()->close();
- parseCount++;
- } else if ((*za)->getName() == "THEMERC") {
- Common::SeekableReadStream *stream = (*za)->open();
- stxHeader = stream->readLine();
+ parser()->close();
+ parseCount++;
+ } else if ((*za)->getName() == "THEMERC") {
+ Common::SeekableReadStream *stream = (*za)->open();
+ stxHeader = stream->readLine();
- if (!themeConfigParseHeader(stxHeader.c_str(), _themeName)) {
- warning("Corrupted 'THEMERC' file in theme '%s'", _themeFileName.c_str());
- failed = true;
- }
+ if (!themeConfigParseHeader(stxHeader.c_str(), _themeName)) {
+ warning("Corrupted 'THEMERC' file in theme '%s'", _themeFileName.c_str());
+ failed = true;
+ }
- delete stream;
+ delete stream;
+ }
}
+ } else {
+ warning("Failed to open Zip archive '%s'.\n", themeName.c_str());
+ return false;
}
} else {
#endif
-
- FSNode node(themeName);
- if (node.exists() && node.isReadable() && node.isDirectory()) {
+ if (node.isDirectory()) {
FSList fslist;
if (!node.getChildren(fslist, FSNode::kListFilesOnly))
return false;