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