Some minor reformatting, JLOG instrumentation of the zip file loading.
This commit is contained in:
@@ -42,7 +42,8 @@ void JFileSystem::preloadZip(string filename){
|
||||
JZipCache * cache = new JZipCache();
|
||||
mZipCache[filename] = cache;
|
||||
|
||||
if (!mZipAvailable || !mZipFile) {
|
||||
if (!mZipAvailable || !mZipFile)
|
||||
{
|
||||
AttachZipFile(filename);
|
||||
if (!mZipAvailable || !mZipFile) return;
|
||||
}
|
||||
@@ -143,8 +144,14 @@ void JFileSystem::DetachZipFile()
|
||||
{
|
||||
if (mZipAvailable && mZipFile != NULL)
|
||||
{
|
||||
unzCloseCurrentFile(mZipFile);
|
||||
unzClose(mZipFile);
|
||||
JLOG("DetachZipFile");
|
||||
int error = unzCloseCurrentFile(mZipFile);
|
||||
if (error < 0 )
|
||||
JLOG("error calling unzCloseCurrentFile");
|
||||
|
||||
error = unzClose(mZipFile);
|
||||
if (error < 0)
|
||||
JLOG("Error calling unzClose");
|
||||
}
|
||||
|
||||
mZipFile = NULL;
|
||||
@@ -154,22 +161,25 @@ void JFileSystem::DetachZipFile()
|
||||
|
||||
bool JFileSystem::OpenFile(const string &filename)
|
||||
{
|
||||
|
||||
string path = mResourceRoot + filename;
|
||||
JLOG("JFileSystem::OpenFile");
|
||||
JLOG(path.c_str());
|
||||
|
||||
if (mZipAvailable && mZipFile != NULL)
|
||||
{
|
||||
JLOG("zip available, calling preload")
|
||||
preloadZip(mZipFileName);
|
||||
map<string,JZipCache *>::iterator it = mZipCache.find(mZipFileName);
|
||||
if (it == mZipCache.end()){
|
||||
if (it == mZipCache.end())
|
||||
{
|
||||
JLOG("zip cache miss, detaching & calling open again");
|
||||
DetachZipFile();
|
||||
return OpenFile(filename);
|
||||
}
|
||||
JZipCache * zc = it->second;
|
||||
map<string,unz_file_pos *>::iterator it2 = zc->dir.find(filename);
|
||||
if (it2 == zc->dir.end()){
|
||||
if (it2 == zc->dir.end())
|
||||
{
|
||||
JLOG("directory miss, detaching & calling open again");
|
||||
DetachZipFile();
|
||||
return OpenFile(filename);
|
||||
}
|
||||
@@ -177,6 +187,7 @@ bool JFileSystem::OpenFile(const string &filename)
|
||||
char filenameInzip[256];
|
||||
unz_file_info fileInfo;
|
||||
|
||||
JLOG("calling unzGetCurrentFileInfo");
|
||||
if (unzGetCurrentFileInfo(mZipFile, &fileInfo, filenameInzip, sizeof(filenameInzip), NULL, 0, NULL, 0) == UNZ_OK)
|
||||
mFileSize = fileInfo.uncompressed_size;
|
||||
else
|
||||
@@ -186,7 +197,7 @@ bool JFileSystem::OpenFile(const string &filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (WIN32) || defined (LINUX)|| defined (IOS)
|
||||
#if defined (WIN32) || defined (LINUX)|| defined (IOS)
|
||||
mFile = fopen(path.c_str(), "rb");
|
||||
if (mFile != NULL)
|
||||
{
|
||||
@@ -195,21 +206,20 @@ bool JFileSystem::OpenFile(const string &filename)
|
||||
fseek(mFile, 0, SEEK_SET);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
JLOG("calling sceIOpen");
|
||||
mFile = sceIoOpen(path.c_str(), PSP_O_RDONLY, 0777);
|
||||
if (mFile > 0)
|
||||
{
|
||||
JLOG("calling sceIoSeek");
|
||||
mFileSize = sceIoLseek(mFile, 0, PSP_SEEK_END);
|
||||
sceIoLseek(mFile, 0, PSP_SEEK_SET);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user