More informative error messages

This commit is contained in:
Alexey 'Cluster' Avdyukhin 2021-06-15 14:06:09 +03:00
parent a50fdb64aa
commit aa721d61a9
1 changed files with 12 additions and 4 deletions

View File

@ -390,10 +390,11 @@ TFormatRecords formatRecords;
static bool archiveSystemInitialized=false; static bool archiveSystemInitialized=false;
#ifdef WIN64 #ifdef WIN64
static LibRef libref("7z_64.dll"); #define _7Z_DLL "7z_64.dll"
#else #else
static LibRef libref("7z.dll"); #define _7Z_DLL "7z.dll"
#endif #endif
static LibRef libref(_7Z_DLL);
void initArchiveSystem() void initArchiveSystem()
{ {
@ -475,10 +476,17 @@ static std::string wstringFromPROPVARIANT(BSTR bstr, bool& success)
return strret; return strret;
} }
static bool endsWith(const std::string& str, const std::string& suffix)
{
return (str.size() >= suffix.size()) && (str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0);
}
ArchiveScanRecord FCEUD_ScanArchive(std::string fname) ArchiveScanRecord FCEUD_ScanArchive(std::string fname)
{ {
if(!archiveSystemInitialized) if(!archiveSystemInitialized)
{ {
if (endsWith(fname, ".zip") || endsWith(fname, ".7z") || endsWith(fname, ".rar"))
MessageBox(hAppWnd, "Could not locate " _7Z_DLL, "Failure reading archive file", 0);
return ArchiveScanRecord(); return ArchiveScanRecord();
} }
@ -576,7 +584,7 @@ static FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, s
FCEUFILE* fp = 0; FCEUFILE* fp = 0;
if(!archiveSystemInitialized) { if(!archiveSystemInitialized) {
MessageBox(hAppWnd,"Could not locate 7z.dll","Failure launching archive browser",0); MessageBox(hAppWnd,"Could not locate " _7Z_DLL, "Failure launching archive browser", 0);
return 0; return 0;
} }
@ -584,7 +592,7 @@ static FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, s
CreateObjectFunc CreateObject = (CreateObjectFunc)GetProcAddress(libref.hmod,"CreateObject"); CreateObjectFunc CreateObject = (CreateObjectFunc)GetProcAddress(libref.hmod,"CreateObject");
if(!CreateObject) if(!CreateObject)
{ {
MessageBox(hAppWnd,"7z.dll was invalid","Failure launching archive browser",0); MessageBox(hAppWnd, _7Z_DLL " was invalid","Failure launching archive browser",0);
return 0; return 0;
} }