From 70b18790931562648a5e990e73434261d8e9f08f Mon Sep 17 00:00:00 2001 From: "wagic.the.homebrew" Date: Sun, 4 Dec 2011 07:14:16 +0000 Subject: [PATCH] - [PSP] Fix for issue 768 : PSP cannot read zipped images from zipped files. This was a lowercase/uppercase issue - [PSP] added last log message in exception log --- JGE/src/main.cpp | 4 +++- JGE/src/zipFS/fileio.h | 8 ++++++-- JGE/src/zipFS/zfsystem.cpp | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/JGE/src/main.cpp b/JGE/src/main.cpp index 4061789ff..093eee39b 100644 --- a/JGE/src/main.cpp +++ b/JGE/src/main.cpp @@ -169,7 +169,9 @@ void ExceptionHandler(PspDebugRegBlock * regs) FILE *log = fopen("exception.log", "w"); if (log != NULL) { - char testo[512]; + char testo[1024]; + pspDebugScreenPrintf("Last Log Message: \n%s\n\n", JLogger::lastLog.c_str()); + fwrite(testo, 1, strlen(testo), log); sprintf(testo, "Exception details:\n\n"); fwrite(testo, 1, strlen(testo), log); sprintf(testo, "Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]); diff --git a/JGE/src/zipFS/fileio.h b/JGE/src/zipFS/fileio.h index 0a7ae967e..61edfd953 100644 --- a/JGE/src/zipFS/fileio.h +++ b/JGE/src/zipFS/fileio.h @@ -197,6 +197,7 @@ inline search_iterator & search_iterator::begin(const char * FileSpec) { DirectoryName.assign(FileSpec + 0, FileSpec + i++); m_Extension = FileSpec + i + 1; + std::transform(m_Extension.begin(), m_Extension.end(), m_Extension.begin(), ::tolower); m_Valid = ((m_Directory = opendir(DirectoryName.c_str())) != NULL); if (! m_Valid) @@ -225,8 +226,11 @@ inline search_iterator & search_iterator::next() { Found = false; else if (FileName.size() <= m_Extension.size()) Found = false; - else if (std::equal(m_Extension.rbegin(), m_Extension.rend(), FileName.rbegin())) - Found = true; + else { + std::transform(FileName.begin(), FileName.end(), FileName.begin(), ::tolower); + if (std::equal(m_Extension.rbegin(), m_Extension.rend(), FileName.rbegin())) + Found = true; + } } else break; diff --git a/JGE/src/zipFS/zfsystem.cpp b/JGE/src/zipFS/zfsystem.cpp index 9a4c0ae95..522d5ce02 100644 --- a/JGE/src/zipFS/zfsystem.cpp +++ b/JGE/src/zipFS/zfsystem.cpp @@ -12,6 +12,9 @@ #include "stdafx.h" #include "zfsystem.h" +// Debug +#include "../../include/JLogger.h" + #include "fileio.h" // I/O facilities @@ -58,6 +61,9 @@ filesystem::filesystem(const char * BasePath, const char * FileExt, bool Default } // Search all *.zip files (or whatever the ZipExt specify as the file extension) + // Search is case insensitive (see fileio.h for details) + // The case insensitive state is mostly because some of the filesystems we support such as FAT32 are case insensitive + // Being case sensitive would lead to weird bugs on these systems. vector ZipFiles; for (search_iterator ZSrch = (m_BasePath + "*." + m_FileExt).c_str(); ZSrch != ZSrch.end(); ++ZSrch) @@ -285,12 +291,16 @@ void filesystem::InsertZip(const char * Filename, const size_t PackID) // Open zip ifstream File(ZipPath.c_str(), ios::binary); + LOG(("opening zip:" + ZipPath).c_str()); + if (! File) return; // Find the start of the central directory if (! File.seekg(CentralDir(File))) return; + LOG("open zip ok"); + // Check every headers within the zip file file_header FileHdr;