mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-12-25 18:51:50 +01:00
more small bugfixes
This commit is contained in:
parent
c18b452a00
commit
61f9a207c2
@ -35,6 +35,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;
|
||||||
|
|
||||||
|
@ -665,7 +665,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
|
||||||
|
@ -23,10 +23,8 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "snes9xGX.h"
|
#include "snes9xGX.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"
|
||||||
|
|
||||||
@ -101,19 +99,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);
|
||||||
@ -351,6 +349,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
|
||||||
*
|
*
|
||||||
@ -420,9 +430,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;
|
||||||
@ -435,34 +448,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,18 +480,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
|
||||||
*
|
*
|
||||||
@ -492,7 +487,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;
|
||||||
|
@ -14,9 +14,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