- Zip file support for card pictures
- TODO : linux, update JGFX.cpp for zip support
- TODO : make sure there is no leak in the PSP version
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-05-10 11:10:53 +00:00
parent 69903af2c8
commit 62f6b92332
6 changed files with 120 additions and 29 deletions

View File

@@ -68,8 +68,7 @@ JFileSystem::JFileSystem()
JFileSystem::~JFileSystem()
{
if (mZipAvailable && mZipFile != NULL)
unzCloseCurrentFile(mZipFile);
DetachZipFile();
}
@@ -78,7 +77,9 @@ bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL
if (mZipAvailable && mZipFile != NULL)
{
if (mZipFileName != zipfile)
unzCloseCurrentFile(mZipFile); // close the previous zip file
DetachZipFile(); // close the previous zip file
else
return true;
}
mZipFileName = zipfile;
@@ -101,6 +102,7 @@ void JFileSystem::DetachZipFile()
if (mZipAvailable && mZipFile != NULL)
{
unzCloseCurrentFile(mZipFile);
unzClose(mZipFile);
}
mZipFile = NULL;
@@ -115,9 +117,10 @@ bool JFileSystem::OpenFile(const string &filename)
if (mZipAvailable && mZipFile != NULL)
{
if (unzLocateFile(mZipFile, path.c_str(), 0) != UNZ_OK)
return false;
if (unzLocateFile(mZipFile, filename.c_str(), 0) != UNZ_OK){
DetachZipFile();
return OpenFile(filename);
}
char filenameInzip[256];
unz_file_info fileInfo;
@@ -159,8 +162,10 @@ bool JFileSystem::OpenFile(const string &filename)
void JFileSystem::CloseFile()
{
if (mZipAvailable && mZipFile != NULL)
if (mZipAvailable && mZipFile != NULL){
unzCloseCurrentFile(mZipFile);
return;
}
#if defined (WIN32) || defined (LINUX)
if (mFile != NULL)