compiles again under win32 & systems without gzip, added checks for invalid file ptrs
This commit is contained in:
parent
c984c44a84
commit
d53e9a93d2
|
@ -197,6 +197,7 @@ int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize)
|
|||
type = ROM_DSGBA;
|
||||
|
||||
file = reader->Init(filename);
|
||||
if (!file) return -1 ;
|
||||
size = reader->Size(file);
|
||||
|
||||
if(type == ROM_DSGBA)
|
||||
|
@ -273,6 +274,8 @@ void NDS_Reset(void)
|
|||
u32 dst;
|
||||
NDS_header * header = NDS_getROMHeader();
|
||||
|
||||
if (!header) return ;
|
||||
|
||||
execute = FALSE;
|
||||
|
||||
MMU_clearMem();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
ROMReader_struct * ROMReaderInit(const char ** filename)
|
||||
{
|
||||
#ifdef HAVE_LIBZ
|
||||
if(!strcasecmp(".gz", *filename + (strlen(*filename) - 3)))
|
||||
{
|
||||
*filename -= 3;
|
||||
|
@ -13,6 +14,9 @@ ROMReader_struct * ROMReaderInit(const char ** filename)
|
|||
{
|
||||
return &STDROMReader;
|
||||
}
|
||||
#else
|
||||
return &STDROMReader;
|
||||
#endif
|
||||
}
|
||||
|
||||
void * STDROMReaderInit(const char * filename);
|
||||
|
@ -39,6 +43,7 @@ void * STDROMReaderInit(const char * filename)
|
|||
|
||||
void STDROMReaderDeInit(void * file)
|
||||
{
|
||||
if (!file) return ;
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
|
@ -46,6 +51,8 @@ u32 STDROMReaderSize(void * file)
|
|||
{
|
||||
u32 size;
|
||||
|
||||
if (!file) return 0 ;
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
@ -55,11 +62,13 @@ u32 STDROMReaderSize(void * file)
|
|||
|
||||
int STDROMReaderSeek(void * file, int offset, int whence)
|
||||
{
|
||||
if (!file) return 0 ;
|
||||
return fseek(file, offset, whence);
|
||||
}
|
||||
|
||||
int STDROMReaderRead(void * file, void * buffer, u32 size)
|
||||
{
|
||||
if (!file) return 0 ;
|
||||
return fread(buffer, 1, size, file);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue