Welcome | |
---|---|
Welcome to a320
You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today! |
Moderator: Moderators
#include "../zlib/unzip/unzip.h"
#define UNZIP_OK 0
#define UNZIP_ERROPEN 1
#define UNZIP_ERRNOTFOUND 2
#define UNZIP_ERRCREATE 3
#define UNZIP_ERRREAD 4
#define UNZIP_ERRWRITE 5
bool GameEngine::loadfromZipFile( const char * name, unsigned char * buf, int len, bool showErrorMsg = false )
{
unzFile uf = 0;
int result, bytes;
char string[120];
sprintf( string, "load file '%s' from zip!\n", name );
LOG(_LS(string));
uf = unzOpen( zipfile_path );
if( !uf )
{
sprintf( string, "Cannot open file '%s' !\n", zipfile_path );
LOG(_LS(string));
return false;
}
LOG(_LS("unzLocateFile\n"));
if( unzLocateFile( uf, name, 0 ) != UNZ_OK )
{
sprintf( string, "Can not find '%s' inside the zipfile !\n", name );
LOG(_LS(string));
unzCloseCurrentFile(uf);
return false;
}
LOG(_LS("unzOpenCurrentFile\n"));
if( unzOpenCurrentFile( uf) != UNZ_OK )
{
sprintf( string, "Can not open '%s' inside the zipfile !\n", name );
LOG(_LS(string));
unzCloseCurrentFile(uf);
return false;
}
result = UNZIP_OK;
LOG(_LS("unzReadCurrentFile\n"));
bytes = unzReadCurrentFile( uf, buf, len );
if( bytes < 0 )
{
sprintf( string, "Error reading %s %d!\n", name, bytes );
LOG(_LS(string));
return false;
}
LOG(_LS("unzCloseCurrentFile\n"));
unzCloseCurrentFile( uf );
LOG(_LS("End_UnzipFile=true\n"));
return true;
}
//for example:
unsigned char color[0x100];
loadfromZipFile( "filetoLoad.sms", color, sizeof(color), true)
public:
bool loadfromZipFile( const char * name, unsigned char * buf, int len, bool showErrorMsg );
//### data members:
public:
char *pac_rom_path;
Users browsing this forum: No registered users and 0 guests