mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-29 05:54:17 +01:00
more small bugfixes
This commit is contained in:
parent
47bb000985
commit
2c59c29222
@ -32,6 +32,7 @@ typedef struct
|
||||
int isdir; // 0 - file, 1 - directory
|
||||
char filename[MAXJOLIET + 1]; // full filename
|
||||
char displayname[MAXJOLIET + 1]; // name for browser display
|
||||
int filenum; // file # (for 7z support)
|
||||
int icon; // icon to display
|
||||
} BROWSERENTRY;
|
||||
|
||||
|
@ -663,7 +663,7 @@ LoadSzFile(char * filepath, unsigned char * rbuffer)
|
||||
file = fopen (filepath, "rb");
|
||||
if (file > 0)
|
||||
{
|
||||
size = SzExtractFile(atoi(browserList[browser.selIndex].filename), rbuffer);
|
||||
size = SzExtractFile(browserList[browser.selIndex].filenum, rbuffer);
|
||||
fclose (file);
|
||||
}
|
||||
else
|
||||
|
@ -21,10 +21,8 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include "vba.h"
|
||||
#include "networkop.h"
|
||||
#include "fileop.h"
|
||||
#include "filebrowser.h"
|
||||
#include "video.h"
|
||||
#include "menu.h"
|
||||
#include "gcunzip.h"
|
||||
|
||||
@ -99,19 +97,19 @@ IsZipFile (char *buffer)
|
||||
* UnZipBuffer
|
||||
******************************************************************************/
|
||||
|
||||
int
|
||||
size_t
|
||||
UnZipBuffer (unsigned char *outbuffer)
|
||||
{
|
||||
PKZIPHEADER pkzip;
|
||||
int zipoffset = 0;
|
||||
int zipchunk = 0;
|
||||
size_t zipoffset = 0;
|
||||
size_t zipchunk = 0;
|
||||
char out[ZIPCHUNK];
|
||||
z_stream zs;
|
||||
int res;
|
||||
int bufferoffset = 0;
|
||||
int have = 0;
|
||||
size_t bufferoffset = 0;
|
||||
size_t have = 0;
|
||||
char readbuffer[ZIPCHUNK];
|
||||
int sizeread = 0;
|
||||
size_t sizeread = 0;
|
||||
|
||||
// Read Zip Header
|
||||
fseek(file, 0, SEEK_SET);
|
||||
@ -349,6 +347,18 @@ static SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
|
||||
return SZ_OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* SzClose
|
||||
*
|
||||
* Closes a 7z file
|
||||
***************************************************************************/
|
||||
|
||||
void SzClose()
|
||||
{
|
||||
if(SzDb.Database.NumFiles > 0)
|
||||
SzArDbExFree(&SzDb, SzAllocImp.Free);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* SzParse
|
||||
*
|
||||
@ -418,9 +428,12 @@ int SzParse(char * filepath)
|
||||
ResetBrowser();
|
||||
|
||||
// add '..' folder in case the user wants exit the 7z
|
||||
AddBrowserEntry();
|
||||
|
||||
sprintf(browserList[0].displayname, "Up One Level");
|
||||
browserList[0].isdir = 1;
|
||||
browserList[0].length = filelen;
|
||||
browserList[0].icon = ICON_FOLDER;
|
||||
|
||||
// get contents and parse them into file list structure
|
||||
unsigned int SzI, SzJ;
|
||||
@ -433,34 +446,28 @@ int SzParse(char * filepath)
|
||||
if (SzF->IsDirectory)
|
||||
continue;
|
||||
|
||||
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (SzJ+1) * sizeof(BROWSERENTRY));
|
||||
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
if(!AddBrowserEntry())
|
||||
{
|
||||
ResetBrowser();
|
||||
ErrorPrompt("Out of memory: too many files!");
|
||||
nbfiles = 0;
|
||||
SzClose();
|
||||
SzJ = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
browserList = newBrowserList;
|
||||
}
|
||||
memset(&(browserList[SzJ]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
// parse information about this file to the file list structure
|
||||
sprintf(browserList[SzJ].filename, "%d", SzI); // the extraction function identifies the file with this number
|
||||
StripExt(browserList[SzJ].displayname, SzF->Name);
|
||||
strncpy(browserList[SzJ].filename, SzF->Name, MAXJOLIET);
|
||||
StripExt(browserList[SzJ].displayname, browserList[SzJ].filename);
|
||||
browserList[SzJ].length = SzF->Size; // filesize
|
||||
browserList[SzJ].isdir = 0; // only files will be displayed (-> no flags)
|
||||
browserList[SzJ].filenum = SzI; // the extraction function identifies the file with this number
|
||||
SzJ++;
|
||||
}
|
||||
|
||||
nbfiles = SzJ;
|
||||
}
|
||||
else
|
||||
{
|
||||
SzArDbExFree(&SzDb, SzAllocImp.Free);
|
||||
SzClose();
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,18 +478,6 @@ int SzParse(char * filepath)
|
||||
return nbfiles;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* SzClose
|
||||
*
|
||||
* Closes a 7z file
|
||||
***************************************************************************/
|
||||
|
||||
void SzClose()
|
||||
{
|
||||
if(SzDb.Database.NumFiles > 0)
|
||||
SzArDbExFree(&SzDb, SzAllocImp.Free);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* SzExtractFile
|
||||
*
|
||||
@ -490,7 +485,7 @@ void SzClose()
|
||||
* Must parse the 7z BEFORE running this function
|
||||
***************************************************************************/
|
||||
|
||||
int SzExtractFile(int i, unsigned char *buffer)
|
||||
size_t SzExtractFile(int i, unsigned char *buffer)
|
||||
{
|
||||
// prepare some variables
|
||||
SzBlockIndex = 0xFFFFFFFF;
|
||||
|
@ -12,9 +12,9 @@
|
||||
|
||||
int IsZipFile (char *buffer);
|
||||
char * GetFirstZipFilename();
|
||||
int UnZipBuffer (unsigned char *outbuffer);
|
||||
size_t UnZipBuffer (unsigned char *outbuffer);
|
||||
int SzParse(char * filepath);
|
||||
int SzExtractFile(int i, unsigned char *buffer);
|
||||
size_t SzExtractFile(int i, unsigned char *buffer);
|
||||
void SzClose();
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user