Allow 7z files to actually work through "Open ROM". Removes the codes assumption it is being handed the ROM name its looking for in the file.

This commit is contained in:
Emmet Young 2015-05-02 00:53:57 +10:00
parent f75a6e489c
commit 312de4d2a4
2 changed files with 10 additions and 5 deletions

View File

@ -490,7 +490,7 @@ stdstr CN64System::ChooseFileToOpen ( HWND hParent )
openfilename.lStructSize = sizeof( openfilename ); openfilename.lStructSize = sizeof( openfilename );
openfilename.hwndOwner = (HWND)hParent; openfilename.hwndOwner = (HWND)hParent;
openfilename.lpstrFilter = "N64 ROMs (*.zip, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; openfilename.lpstrFilter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
openfilename.lpstrFile = FileName; openfilename.lpstrFile = FileName;
openfilename.lpstrInitialDir = Directory; openfilename.lpstrInitialDir = Directory;
openfilename.nMaxFile = MAX_PATH; openfilename.nMaxFile = MAX_PATH;

View File

@ -276,7 +276,8 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
_splitpath(FileLoc,drive,dir,fname,ext); _splitpath(FileLoc,drive,dir,fname,ext);
bool Loaded7zFile = false; bool Loaded7zFile = false;
if (strstr(FileLoc,"?") != NULL || strcmp(ext,".z7") == 0)
if (strstr(FileLoc,"?") != NULL || strcmp(ext,".7z") == 0)
{ {
char FullPath[MAX_PATH + 100]; char FullPath[MAX_PATH + 100];
strcpy(FullPath,FileLoc); strcpy(FullPath,FileLoc);
@ -287,7 +288,7 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
{ {
//Pop up a dialog and select file //Pop up a dialog and select file
//allocate memory for sub name and copy selected file name to var //allocate memory for sub name and copy selected file name to var
return false; //remove once dialog is done //return false; //remove once dialog is done
} else { } else {
*SubFile = '\0'; *SubFile = '\0';
SubFile += 1; SubFile += 1;
@ -302,11 +303,15 @@ bool CN64Rom::LoadN64Image ( const char * FileLoc, bool LoadBootCodeOnly ) {
{ {
continue; continue;
} }
stdstr ZipFileName; stdstr ZipFileName;
ZipFileName.FromUTF16(ZipFile.FileNameIndex(i).c_str()); ZipFileName.FromUTF16(ZipFile.FileNameIndex(i).c_str());
if (_stricmp(ZipFileName.c_str(), SubFile) != 0) if (SubFile != NULL)
{ {
continue; if (_stricmp(ZipFileName.c_str(), SubFile) != 0)
{
continue;
}
} }
//Get the size of the rom and try to allocate the memory needed. //Get the size of the rom and try to allocate the memory needed.