From aa721d61a94c7ad7870ccd0b197d9db610872f99 Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Tue, 15 Jun 2021 14:06:09 +0300 Subject: [PATCH] More informative error messages --- src/drivers/win/archive.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/drivers/win/archive.cpp b/src/drivers/win/archive.cpp index 3f610059..4253b080 100644 --- a/src/drivers/win/archive.cpp +++ b/src/drivers/win/archive.cpp @@ -390,10 +390,11 @@ TFormatRecords formatRecords; static bool archiveSystemInitialized=false; #ifdef WIN64 -static LibRef libref("7z_64.dll"); +#define _7Z_DLL "7z_64.dll" #else -static LibRef libref("7z.dll"); +#define _7Z_DLL "7z.dll" #endif +static LibRef libref(_7Z_DLL); void initArchiveSystem() { @@ -475,10 +476,17 @@ static std::string wstringFromPROPVARIANT(BSTR bstr, bool& success) 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) { 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(); } @@ -576,7 +584,7 @@ static FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, s FCEUFILE* fp = 0; 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; } @@ -584,7 +592,7 @@ static FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, s CreateObjectFunc CreateObject = (CreateObjectFunc)GetProcAddress(libref.hmod,"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; }