mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-22 02:29:16 +01:00
avoid using file stat when possible. it's slow.
This commit is contained in:
parent
b738b86176
commit
16181ef6b9
1895
source/fileop.cpp
1895
source/fileop.cpp
File diff suppressed because it is too large
Load Diff
100
source/fileop.h
100
source/fileop.h
@ -1,52 +1,48 @@
|
||||
/****************************************************************************
|
||||
* Visual Boy Advance GX
|
||||
*
|
||||
* Tantric September 2008
|
||||
*
|
||||
* fileop.h
|
||||
*
|
||||
* File operations
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _FILEOP_H_
|
||||
#define _FILEOP_H_
|
||||
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ogcsys.h>
|
||||
#include <fat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define SAVEBUFFERSIZE (1024 * 1024 * 2) // leave room for IPS/UPS files and larger images
|
||||
|
||||
void InitDeviceThread();
|
||||
void ResumeDeviceThread();
|
||||
void HaltDeviceThread();
|
||||
void HaltParseThread();
|
||||
void MountAllFAT();
|
||||
void UnmountAllFAT();
|
||||
bool FindDevice(char * filepath, int * device);
|
||||
char * StripDevice(char * path);
|
||||
bool ChangeInterface(int device, bool silent);
|
||||
bool ChangeInterface(char * filepath, bool silent);
|
||||
void CreateAppPath(char * origpath);
|
||||
bool GetFileSize(int i);
|
||||
void FindAndSelectLastLoadedFile();
|
||||
int ParseDirectory(bool waitParse = false, bool filter = true);
|
||||
bool CreateDirectory(char * path);
|
||||
void AllocSaveBuffer();
|
||||
void FreeSaveBuffer();
|
||||
size_t LoadFile(char * rbuffer, char *filepath, size_t length, bool silent);
|
||||
size_t LoadFile(char * filepath, bool silent);
|
||||
size_t LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||
size_t SaveFile(char * buffer, char *filepath, size_t datasize, bool silent);
|
||||
size_t SaveFile(char * filepath, size_t datasize, bool silent);
|
||||
|
||||
extern unsigned char *savebuffer;
|
||||
extern FILE * file;
|
||||
extern bool unmountRequired[];
|
||||
extern bool isMounted[];
|
||||
extern int selectLoadedFile;
|
||||
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Visual Boy Advance GX
|
||||
*
|
||||
* Tantric September 2008
|
||||
*
|
||||
* fileop.h
|
||||
*
|
||||
* File operations
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _FILEOP_H_
|
||||
#define _FILEOP_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define SAVEBUFFERSIZE (1024 * 1024 * 2) // leave room for IPS/UPS files and larger images
|
||||
|
||||
void InitDeviceThread();
|
||||
void ResumeDeviceThread();
|
||||
void HaltDeviceThread();
|
||||
void HaltParseThread();
|
||||
void MountAllFAT();
|
||||
void UnmountAllFAT();
|
||||
bool FindDevice(char * filepath, int * device);
|
||||
char * StripDevice(char * path);
|
||||
bool ChangeInterface(int device, bool silent);
|
||||
bool ChangeInterface(char * filepath, bool silent);
|
||||
void CreateAppPath(char * origpath);
|
||||
void FindAndSelectLastLoadedFile();
|
||||
int ParseDirectory(bool waitParse = false, bool filter = true);
|
||||
bool CreateDirectory(char * path);
|
||||
void AllocSaveBuffer();
|
||||
void FreeSaveBuffer();
|
||||
size_t LoadFile(char * rbuffer, char *filepath, size_t length, size_t buffersize, bool silent);
|
||||
size_t LoadFile(char * filepath, bool silent);
|
||||
size_t LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||
size_t SaveFile(char * buffer, char *filepath, size_t datasize, bool silent);
|
||||
size_t SaveFile(char * filepath, size_t datasize, bool silent);
|
||||
|
||||
extern unsigned char *savebuffer;
|
||||
extern FILE * file;
|
||||
extern bool unmountRequired[];
|
||||
extern bool isMounted[];
|
||||
extern int selectLoadedFile;
|
||||
|
||||
#endif
|
||||
|
1055
source/gcunzip.cpp
1055
source/gcunzip.cpp
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@
|
||||
|
||||
int IsZipFile (char *buffer);
|
||||
char * GetFirstZipFilename();
|
||||
size_t UnZipBuffer (unsigned char *outbuffer);
|
||||
size_t UnZipBuffer (unsigned char *outbuffer, size_t buffersize);
|
||||
int SzParse(char * filepath);
|
||||
size_t SzExtractFile(int i, unsigned char *buffer);
|
||||
void SzClose();
|
||||
|
@ -420,7 +420,7 @@ bool SaveBatteryOrState(char * filepath, int action, bool silent)
|
||||
const char* generic_goomba_error = "Cannot save SRAM in Goomba format (did not load correctly.)";
|
||||
// check for goomba sram format
|
||||
char* old_sram = (char*)malloc(GOOMBA_COLOR_SRAM_SIZE);
|
||||
size_t br = LoadFile(old_sram, filepath, GOOMBA_COLOR_SRAM_SIZE, true);
|
||||
size_t br = LoadFile(old_sram, filepath, GOOMBA_COLOR_SRAM_SIZE, GOOMBA_COLOR_SRAM_SIZE, true);
|
||||
if (br >= GOOMBA_COLOR_SRAM_SIZE && goomba_is_sram(old_sram)) {
|
||||
void* cleaned = goomba_cleanup(old_sram);
|
||||
if (cleaned == NULL) {
|
||||
@ -1005,12 +1005,12 @@ void LoadPNGBorder(const char* fallback)
|
||||
char error[1024]; error[1023] = 0;
|
||||
int r;
|
||||
|
||||
bool borderLoaded = LoadFile((char*)png_tmp_buf, borderPath, 1024*1024, SILENT);
|
||||
bool borderLoaded = LoadFile((char*)png_tmp_buf, borderPath, 0, 1024*1024, SILENT);
|
||||
if (!borderLoaded) {
|
||||
// Try default border.png
|
||||
free(borderPath);
|
||||
borderPath = AllocAndGetPNGBorderPath(fallback);
|
||||
borderLoaded = LoadFile((char*)png_tmp_buf, borderPath, 1024*1024, SILENT);
|
||||
borderLoaded = LoadFile((char*)png_tmp_buf, borderPath, 0, 1024*1024, SILENT);
|
||||
}
|
||||
if (!borderLoaded) goto cleanup;
|
||||
|
||||
@ -1060,12 +1060,7 @@ bool LoadGBROM()
|
||||
{
|
||||
gbEmulatorType = GCSettings.GBHardware;
|
||||
|
||||
if (browserList[browser.selIndex].length > 1024*1024*8)
|
||||
{
|
||||
InfoPrompt("ROM size is too large (> 8 MB)");
|
||||
return false;
|
||||
}
|
||||
gbRom = (u8 *)malloc(1024*1024*8); // 32 MB is too much for sure
|
||||
gbRom = (u8 *)malloc(1024*1024*8);
|
||||
if (!gbRom)
|
||||
{
|
||||
InfoPrompt("Unable to allocate 8 MB of memory");
|
||||
@ -1082,7 +1077,7 @@ bool LoadGBROM()
|
||||
if(!MakeFilePath(filepath, FILE_ROM))
|
||||
return false;
|
||||
|
||||
gbRomSize = LoadFile ((char *)gbRom, filepath, browserList[browser.selIndex].length, NOTSILENT);
|
||||
gbRomSize = LoadFile ((char *)gbRom, filepath, 0, (1024*1024*8), NOTSILENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1174,12 +1169,6 @@ bool LoadVBAROM()
|
||||
ErrorPrompt("Unrecognized file extension!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!GetFileSize(browser.selIndex))
|
||||
{
|
||||
ErrorPrompt("Error loading game!");
|
||||
return false;
|
||||
}
|
||||
|
||||
srcWidth = 0;
|
||||
srcHeight = 0;
|
||||
|
@ -165,7 +165,7 @@ int VMCPULoadROM()
|
||||
if(!MakeFilePath(filepath, FILE_ROM))
|
||||
return 0;
|
||||
|
||||
GBAROMSize = LoadFile ((char *)rom, filepath, browserList[browser.selIndex].length, NOTSILENT);
|
||||
GBAROMSize = LoadFile ((char *)rom, filepath, 0, (1024*1024*32), NOTSILENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user