Make streamed roms working for non-windows systems.

This commit is contained in:
thelemonman 2013-10-30 11:32:11 +00:00
parent 8edec83002
commit e692e05e94
3 changed files with 6 additions and 69 deletions

View File

@ -423,8 +423,6 @@ void GameInfo::populate()
}
#ifdef _WINDOWS
static std::vector<char> buffer;
static std::vector<char> v;
@ -528,7 +526,7 @@ static int rom_init_path(const char *filename, const char *physicalName, const c
{
int type = ROM_NDS;
path.init(logicalFilename);
path.init(logicalFilename? logicalFilename : filename);
if ( path.isdsgba(path.path)) {
type = ROM_DSGBA;
@ -564,69 +562,6 @@ static int rom_init_path(const char *filename, const char *physicalName, const c
return 1;
}
#else
static int rom_init_path(const char *filename, const char *physicalName, const char *logicalFilename)
{
int ret;
int type;
ROMReader_struct *reader;
void *file;
u32 size;
char *noext;
noext = strdup(filename);
reader = ROMReaderInit(&noext);
free(noext);
if (logicalFilename)
path.init(logicalFilename);
else
path.init(filename);
if (!strcasecmp(path.extension().c_str(), "zip"))
type = ROM_NDS;
else if (!strcasecmp(path.extension().c_str(), "nds"))
type = ROM_NDS;
else if (path.isdsgba(path.path))
type = ROM_DSGBA;
else
type = ROM_NDS;
file = reader->Init(filename);
if (!file)
{
reader->DeInit(file);
return -1;
}
size = reader->Size(file);
if(type == ROM_DSGBA)
{
reader->Seek(file, DSGBA_LOADER_SIZE, SEEK_SET);
size -= DSGBA_LOADER_SIZE;
}
//check that size is at least the size of the header
if (size < 352) {
reader->DeInit(file);
return -1;
}
// Make sure old ROM is freed first(at least this way we won't be eating
// up a ton of ram before the old ROM is freed)
if(MMU.CART_ROM != MMU.UNUSED_RAM)
NDS_FreeROM();
gameInfo.resize(size);
ret = reader->Read(file, gameInfo.romdata, size);
gameInfo.fillGap();
reader->DeInit(file);
return ret;
}
#endif
int NDS_LoadROM(const char *filename, const char *physicalName, const char *logicalFilename)
{

View File

@ -180,4 +180,4 @@ void FCEUD_MakePathDirs(const char *fname)
} while(1);
}
#endif
//------------------------------
//------------------------------

View File

@ -118,8 +118,8 @@ public:
char pathToLua[MAX_PATH];
char pathToSlot1D[MAX_PATH];
void init(const char *filename) {
void init(const char *filename)
{
path = std::string(filename);
//extract the internal part of the logical rom name
@ -430,6 +430,8 @@ public:
std::string GetRomNameWithoutExtension()
{
if (RomName.c_str() == NULL)
return "";
return Path::GetFileNameWithoutExt(RomName);
}