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
|
* Visual Boy Advance GX
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric September 2008
|
||||||
*
|
*
|
||||||
* fileop.h
|
* fileop.h
|
||||||
*
|
*
|
||||||
* File operations
|
* File operations
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _FILEOP_H_
|
#ifndef _FILEOP_H_
|
||||||
#define _FILEOP_H_
|
#define _FILEOP_H_
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <stdio.h>
|
||||||
#include <stdio.h>
|
#include <string.h>
|
||||||
#include <string.h>
|
#include <unistd.h>
|
||||||
#include <ogcsys.h>
|
|
||||||
#include <fat.h>
|
#define SAVEBUFFERSIZE (1024 * 1024 * 2) // leave room for IPS/UPS files and larger images
|
||||||
#include <unistd.h>
|
|
||||||
|
void InitDeviceThread();
|
||||||
#define SAVEBUFFERSIZE (1024 * 1024 * 2) // leave room for IPS/UPS files and larger images
|
void ResumeDeviceThread();
|
||||||
|
void HaltDeviceThread();
|
||||||
void InitDeviceThread();
|
void HaltParseThread();
|
||||||
void ResumeDeviceThread();
|
void MountAllFAT();
|
||||||
void HaltDeviceThread();
|
void UnmountAllFAT();
|
||||||
void HaltParseThread();
|
bool FindDevice(char * filepath, int * device);
|
||||||
void MountAllFAT();
|
char * StripDevice(char * path);
|
||||||
void UnmountAllFAT();
|
bool ChangeInterface(int device, bool silent);
|
||||||
bool FindDevice(char * filepath, int * device);
|
bool ChangeInterface(char * filepath, bool silent);
|
||||||
char * StripDevice(char * path);
|
void CreateAppPath(char * origpath);
|
||||||
bool ChangeInterface(int device, bool silent);
|
void FindAndSelectLastLoadedFile();
|
||||||
bool ChangeInterface(char * filepath, bool silent);
|
int ParseDirectory(bool waitParse = false, bool filter = true);
|
||||||
void CreateAppPath(char * origpath);
|
bool CreateDirectory(char * path);
|
||||||
bool GetFileSize(int i);
|
void AllocSaveBuffer();
|
||||||
void FindAndSelectLastLoadedFile();
|
void FreeSaveBuffer();
|
||||||
int ParseDirectory(bool waitParse = false, bool filter = true);
|
size_t LoadFile(char * rbuffer, char *filepath, size_t length, size_t buffersize, bool silent);
|
||||||
bool CreateDirectory(char * path);
|
size_t LoadFile(char * filepath, bool silent);
|
||||||
void AllocSaveBuffer();
|
size_t LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||||
void FreeSaveBuffer();
|
size_t SaveFile(char * buffer, char *filepath, size_t datasize, bool silent);
|
||||||
size_t LoadFile(char * rbuffer, char *filepath, size_t length, bool silent);
|
size_t SaveFile(char * filepath, size_t datasize, bool silent);
|
||||||
size_t LoadFile(char * filepath, bool silent);
|
|
||||||
size_t LoadSzFile(char * filepath, unsigned char * rbuffer);
|
extern unsigned char *savebuffer;
|
||||||
size_t SaveFile(char * buffer, char *filepath, size_t datasize, bool silent);
|
extern FILE * file;
|
||||||
size_t SaveFile(char * filepath, size_t datasize, bool silent);
|
extern bool unmountRequired[];
|
||||||
|
extern bool isMounted[];
|
||||||
extern unsigned char *savebuffer;
|
extern int selectLoadedFile;
|
||||||
extern FILE * file;
|
|
||||||
extern bool unmountRequired[];
|
#endif
|
||||||
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);
|
int IsZipFile (char *buffer);
|
||||||
char * GetFirstZipFilename();
|
char * GetFirstZipFilename();
|
||||||
size_t UnZipBuffer (unsigned char *outbuffer);
|
size_t UnZipBuffer (unsigned char *outbuffer, size_t buffersize);
|
||||||
int SzParse(char * filepath);
|
int SzParse(char * filepath);
|
||||||
size_t SzExtractFile(int i, unsigned char *buffer);
|
size_t SzExtractFile(int i, unsigned char *buffer);
|
||||||
void SzClose();
|
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.)";
|
const char* generic_goomba_error = "Cannot save SRAM in Goomba format (did not load correctly.)";
|
||||||
// check for goomba sram format
|
// check for goomba sram format
|
||||||
char* old_sram = (char*)malloc(GOOMBA_COLOR_SRAM_SIZE);
|
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)) {
|
if (br >= GOOMBA_COLOR_SRAM_SIZE && goomba_is_sram(old_sram)) {
|
||||||
void* cleaned = goomba_cleanup(old_sram);
|
void* cleaned = goomba_cleanup(old_sram);
|
||||||
if (cleaned == NULL) {
|
if (cleaned == NULL) {
|
||||||
@ -1005,12 +1005,12 @@ void LoadPNGBorder(const char* fallback)
|
|||||||
char error[1024]; error[1023] = 0;
|
char error[1024]; error[1023] = 0;
|
||||||
int r;
|
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) {
|
if (!borderLoaded) {
|
||||||
// Try default border.png
|
// Try default border.png
|
||||||
free(borderPath);
|
free(borderPath);
|
||||||
borderPath = AllocAndGetPNGBorderPath(fallback);
|
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;
|
if (!borderLoaded) goto cleanup;
|
||||||
|
|
||||||
@ -1060,12 +1060,7 @@ bool LoadGBROM()
|
|||||||
{
|
{
|
||||||
gbEmulatorType = GCSettings.GBHardware;
|
gbEmulatorType = GCSettings.GBHardware;
|
||||||
|
|
||||||
if (browserList[browser.selIndex].length > 1024*1024*8)
|
gbRom = (u8 *)malloc(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
|
|
||||||
if (!gbRom)
|
if (!gbRom)
|
||||||
{
|
{
|
||||||
InfoPrompt("Unable to allocate 8 MB of memory");
|
InfoPrompt("Unable to allocate 8 MB of memory");
|
||||||
@ -1082,7 +1077,7 @@ bool LoadGBROM()
|
|||||||
if(!MakeFilePath(filepath, FILE_ROM))
|
if(!MakeFilePath(filepath, FILE_ROM))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
gbRomSize = LoadFile ((char *)gbRom, filepath, browserList[browser.selIndex].length, NOTSILENT);
|
gbRomSize = LoadFile ((char *)gbRom, filepath, 0, (1024*1024*8), NOTSILENT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1174,12 +1169,6 @@ bool LoadVBAROM()
|
|||||||
ErrorPrompt("Unrecognized file extension!");
|
ErrorPrompt("Unrecognized file extension!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GetFileSize(browser.selIndex))
|
|
||||||
{
|
|
||||||
ErrorPrompt("Error loading game!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
srcWidth = 0;
|
srcWidth = 0;
|
||||||
srcHeight = 0;
|
srcHeight = 0;
|
||||||
|
@ -165,7 +165,7 @@ int VMCPULoadROM()
|
|||||||
if(!MakeFilePath(filepath, FILE_ROM))
|
if(!MakeFilePath(filepath, FILE_ROM))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
GBAROMSize = LoadFile ((char *)rom, filepath, browserList[browser.selIndex].length, NOTSILENT);
|
GBAROMSize = LoadFile ((char *)rom, filepath, 0, (1024*1024*32), NOTSILENT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user