From: <sag...@us...> - 2013-02-12 16:10:24
|
Revision: 1522 http://sourceforge.net/p/modplug/code/1522 Author: saga-games Date: 2013-02-12 16:10:16 +0000 (Tue, 12 Feb 2013) Log Message: ----------- [Ref] Tried to unify the multiple lists of supported file formats a bit. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Tables.cpp trunk/OpenMPT/unlha/UNLHA32.H trunk/OpenMPT/unlha/Unlha.cpp trunk/OpenMPT/unrar/Unrar.cpp trunk/OpenMPT/unrar/Unrar32.h trunk/OpenMPT/unzip/unzip.cpp trunk/OpenMPT/unzip/unzip.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-02-12 16:10:16 UTC (rev 1522) @@ -1181,12 +1181,16 @@ void CTrackApp::OnFileOpen() //-------------------------- { + std::vector<const char *> modExtensions = CSoundFile::GetSupportedExtensions(true); + std::string exts; + for(size_t i = 0; i < modExtensions.size(); i++) + { + exts += std::string("*.") + modExtensions[i] + std::string(";"); + } + static int nFilterIndex = 0; FileDlgResult files = ShowOpenSaveFileDialog(true, "", "", - "All Modules|*.mod;*.nst;*.wow;*.s3m;*.stm;*.669;*.mtm;*.xm;*.it;*.itp;*.mptm;*.ult;*.mdz;*.s3z;*.xmz;*.itz;mod.*;*.far;*.mdl;*.okt;*.dmf;*.ptm;*.mdr;*.med;*.ams;*.dbm;*.dsm;*.mid;*.rmi;*.smf;*.umx;*.amf;*.psm;*.mt2;*.gdm;*.imf;*.j2b" -#ifndef NO_MO3_SUPPORT - ";*.mo3" -#endif + "All Modules|" + exts + "|" "Compressed Modules (*.mdz;*.s3z;*.xmz;*.itz" #ifndef NO_MO3_SUPPORT Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-02-12 16:10:16 UTC (rev 1522) @@ -422,11 +422,11 @@ { _splitpath(lpMidiLib->MidiMap[iPerc|0x80], NULL, NULL, szName, szExt); strncat(s, ": ", sizeof(s)); - s[sizeof(s)-1] = 0; + StringFixer::SetNullTerminator(s); strncat(s, szName, sizeof(s)); - s[sizeof(s)-1] = 0; + StringFixer::SetNullTerminator(s); strncat(s, szExt, sizeof(s)); - s[sizeof(s)-1] = 0; + StringFixer::SetNullTerminator(s); if (szName[0]) dwImage = IMAGE_SAMPLES; } if (!m_tiPerc[iPerc]) @@ -1562,6 +1562,18 @@ } +struct find_str +{ + find_str(const char *str): s1(str) { } + + bool operator() (const char *s2) const + { + return !strcmp(s1, s2); + } + + const char *s1; +}; + // Refresh Instrument Library void CModTree::FillInstrumentLibrary() //------------------------------------ @@ -1649,6 +1661,8 @@ if(strlen(szPath) >= CountOf(szPath) - 1) return; + std::vector<const char *> modExts = CSoundFile::GetSupportedExtensions(false); + // Enumerating Directories and samples/instruments if (szPath[strlen(szPath) - 1] != '\\') strcat(szPath, "\\"); @@ -1691,55 +1705,29 @@ strcpy(szFileName, m_szInstrLibPath); strncat(szFileName, wfd.cFileName, sizeof(szFileName)); _splitpath(szFileName, NULL, NULL, NULL, s); - // Instruments - if ((!lstrcmpi(s, ".xi")) - || (!lstrcmpi(s, ".iti")) - || (!lstrcmpi(s, ".pat")) ) + + if(s[0]) { + const size_t len = strlen(s); + for(size_t i = 0; i < len; i++) + { + s[i] = tolower(s[i + 1]); + } + } + + // Instruments + if ((!strcmp(s, "xi")) + || (!strcmp(s, "iti")) + || (!strcmp(s, "pat")) ) + { if (!m_pDataTree) { ModTreeBuildTVIParam(tvis, wfd.cFileName, IMAGE_INSTRUMENTS); InsertItem(&tvis); } - } else - // Songs - if(!lstrcmpi(s, ".mod") - || !lstrcmpi(s, ".s3m") - || !lstrcmpi(s, ".xm") - || !lstrcmpi(s, ".it") - || !lstrcmpi(s, ".mptm") - || !lstrcmpi(s, ".itp") - || !lstrcmpi(s, ".mdz") - || !lstrcmpi(s, ".s3z") - || !lstrcmpi(s, ".xmz") - || !lstrcmpi(s, ".itz") - || !lstrcmpi(s, ".669") - || !lstrcmpi(s, ".ams") - || !lstrcmpi(s, ".amf") - || !lstrcmpi(s, ".mdz") - || !lstrcmpi(s, ".dsm") - || !lstrcmpi(s, ".far") - || !lstrcmpi(s, ".mdl") - || !lstrcmpi(s, ".mtm") - || !lstrcmpi(s, ".nst") - || !lstrcmpi(s, ".okt") - || !lstrcmpi(s, ".stm") - || !lstrcmpi(s, ".ult") - || !lstrcmpi(s, ".psm") - || !lstrcmpi(s, ".dmf") - || !lstrcmpi(s, ".mt2") - || !lstrcmpi(s, ".med") - || !lstrcmpi(s, ".wow") - || !lstrcmpi(s, ".gdm") - || !lstrcmpi(s, ".imf") - || !lstrcmpi(s, ".j2b") - || !lstrcmpi(s, ".umx") - || !lstrcmpi(s, ".uax") -#ifndef NO_MO3_SUPPORT - || !lstrcmpi(s, ".mo3") -#endif // NO_MO3_SUPPORT - ) + } else if(std::find_if(modExts.begin(), modExts.end(), find_str(s)) != modExts.end()) { + // Songs if (m_pDataTree) { ModTreeBuildTVIParam(tvis, wfd.cFileName, IMAGE_FOLDERSONG); @@ -1747,34 +1735,34 @@ } } else // Samples - if(!lstrcmpi(s, ".wav") - || !lstrcmpi(s, ".flac") - || !lstrcmpi(s, ".smp") - || !lstrcmpi(s, ".raw") - || !lstrcmpi(s, ".s3i") - || !lstrcmpi(s, ".its") - || !lstrcmpi(s, ".aif") - || !lstrcmpi(s, ".aiff") - || !lstrcmpi(s, ".snd") - || !lstrcmpi(s, ".svx") - || !lstrcmpi(s, ".voc") - || !lstrcmpi(s, ".8sv") - || !lstrcmpi(s, ".8svx") - || !lstrcmpi(s, ".16sv") - || !lstrcmpi(s, ".16svx") + if(!strcmp(s, "wav") + || !strcmp(s, "flac") + || !strcmp(s, "smp") + || !strcmp(s, "raw") + || !strcmp(s, "s3i") + || !strcmp(s, "its") + || !strcmp(s, "aif") + || !strcmp(s, "aiff") + || !strcmp(s, "snd") + || !strcmp(s, "svx") + || !strcmp(s, "voc") + || !strcmp(s, "8sv") + || !strcmp(s, "8svx") + || !strcmp(s, "16sv") + || !strcmp(s, "16svx") || (m_bShowAllFiles // Exclude the extensions below - && lstrcmpi(s, ".txt") - && lstrcmpi(s, ".diz") - && lstrcmpi(s, ".nfo") - && lstrcmpi(s, ".doc") - && lstrcmpi(s, ".ini") - && lstrcmpi(s, ".pdf") - && lstrcmpi(s, ".zip") - && lstrcmpi(s, ".rar") - && lstrcmpi(s, ".lha") - && lstrcmpi(s, ".exe") - && lstrcmpi(s, ".dll") - && lstrcmpi(s, ".mol")) + && strcmp(s, "txt") + && strcmp(s, "diz") + && strcmp(s, "nfo") + && strcmp(s, "doc") + && strcmp(s, "ini") + && strcmp(s, "pdf") + && strcmp(s, "zip") + && strcmp(s, "rar") + && strcmp(s, "lha") + && strcmp(s, "exe") + && strcmp(s, "dll") + && strcmp(s, "mol")) ) { if (!m_pDataTree) Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-02-12 16:10:16 UTC (rev 1522) @@ -102,7 +102,10 @@ MOD_TYPE_MPT = 0x1000000, MOD_TYPE_IMF = 0x2000000, MOD_TYPE_AMS2 = 0x4000000, - MOD_TYPE_UMX = 0x80000000, // Fake type + // Container formats (not used at the moment) + MOD_TYPE_MO3 = 0x20000000, + MOD_TYPE_GDM = 0x40000000, + MOD_TYPE_UMX = 0x80000000, }; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-02-12 16:10:16 UTC (rev 1522) @@ -29,11 +29,6 @@ #define UNLHA_SUPPORT #define UNGZIP_SUPPORT #define ZIPPED_MOD_SUPPORT -LPCSTR glpszModExtensions = "mod|s3m|xm|it|itp|mptm|stm|nst|ult|669|wow|mtm|med|far|mdl|ams|dsm|amf|okt|dmf|ptm|psm|mt2|umx|uax|gdm|imf|j2b" -#ifndef NO_UNMO3_SUPPORT -"|mo3" -#endif -; #endif // NO_ARCHIVE_SUPPORT #else // NO_COPYRIGHT: EarSaver only loads mod/s3m/xm/it/wav #define MODPLUG_BASIC_SUPPORT @@ -548,8 +543,10 @@ { FileReader file(reinterpret_cast<const char*>(lpStream), dwMemLength); + const std::vector<const char *> modExtensions = GetSupportedExtensions(true); + #ifdef ZIPPED_MOD_SUPPORT - CZipArchive unzip(file, glpszModExtensions); + CZipArchive unzip(file, modExtensions); if(unzip.IsArchive() && unzip.ExtractFile()) { file = unzip.GetOutputFile(); @@ -558,7 +555,7 @@ } #endif #ifdef UNRAR_SUPPORT - CRarArchive unrar((LPBYTE)lpStream, dwMemLength, glpszModExtensions); + CRarArchive unrar((LPBYTE)lpStream, dwMemLength); if(unrar.IsArchive()) { if(unrar.ExtrFile() && unrar.GetOutputFile()) @@ -570,7 +567,7 @@ } #endif #ifdef UNLHA_SUPPORT - CLhaArchive unlha((LPBYTE)lpStream, dwMemLength, glpszModExtensions); + CLhaArchive unlha((LPBYTE)lpStream, dwMemLength); if(unlha.IsArchive()) { if(unlha.ExtractFile() && unlha.GetOutputFile()) Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-02-12 16:10:16 UTC (rev 1522) @@ -420,6 +420,8 @@ bool ReadJ2B(FileReader &file); bool ReadMID(const LPCBYTE lpStream, DWORD dwMemLength); + static std::vector<const char *> GetSupportedExtensions(bool otherFormats); + void UpgradeModFlags(); void UpgradeSong(); @@ -779,18 +781,6 @@ int _muldiv(long a, long b, long c); int _muldivr(long a, long b, long c); -/////////////////////////////////////////////////////////// -// File Formats Information (name, extension, etc) - -struct MODFORMATINFO -{ - MODTYPE mtFormatId; // MOD_TYPE_XXXX - LPCSTR lpszFormatName; // "ProTracker" - LPCSTR lpszExtension; // ".xxx" - DWORD dwPadding; -}; - - // Read instrument property with 'code' and 'size' from 'file' to instrument 'pIns'. void ReadInstrumentExtensionField(ModInstrument* pIns, const uint32 code, const uint16 size, FileReader &file); Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/soundlib/Tables.cpp 2013-02-12 16:10:16 UTC (rev 1522) @@ -18,39 +18,100 @@ // end rewbs.resamplerConf -/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +// File Formats Information (name, extension, etc) -/*MODFORMATINFO gModFormatInfo[] = +struct ModFormatInfo { - { MOD_TYPE_MOD, "ProTracker", ".mod", 0 }, - { MOD_TYPE_S3M, "ScreamTracker III", ".s3m", 0 }, - { MOD_TYPE_XM, "FastTracker II", ".xm", 0 }, - { MOD_TYPE_IT, "Impulse Tracker", ".it", 0 }, - { MOD_TYPE_MDL, "DigiTracker", ".mdl", 0 }, - { MOD_TYPE_MTM, "MultiTracker", ".mtm", 0 }, - { MOD_TYPE_STM, "ScreamTracker II", ".stm", 0 }, - { MOD_TYPE_OKT, "Oktalyzer", ".okt", 0 }, - { MOD_TYPE_MED, "OctaMed", ".med", 0 }, - { MOD_TYPE_669, "UNIS 669", ".669", 0 }, - { MOD_TYPE_FAR, "Farandole Composer", ".far", 0 }, - { MOD_TYPE_ULT, "UltraTracker", ".ult", 0 }, - { MOD_TYPE_PTM, "PolyTracker", ".ptm", 0 }, - { MOD_TYPE_WAV, "Wave", ".wav", 0 }, - { MOD_TYPE_MID, "Midi", ".mid", 0 }, - { MOD_TYPE_AMS, "Extreme's Tracker", ".ams", 0 }, - { MOD_TYPE_AMS2, "Velvet Studio", ".ams", 0 }, - { MOD_TYPE_AMF|MOD_TYPE_AMF0,"Asylum / DSMI", ".amf", 0 }, - { MOD_TYPE_DSM, "DSIK Format", ".dsm", 0 }, - { MOD_TYPE_DMF, "X-Tracker", ".dmf", 0 }, - { MOD_TYPE_DBM, "DigiBooster Pro", ".dbm", 0 }, - { MOD_TYPE_PSM, "Epic Megagames MASI", ".psm", 0 }, - { MOD_TYPE_UMX, "Unreal Music", ".umx", 0 }, - { MOD_TYPE_MT2, "MadTracker 2", ".mt2", 0 }, - { MOD_TYPE_MPT, "OpenMPT", ".mptm", 0 }, - { MOD_TYPE_J2B, "Galaxy Sound System", ".j2b", 0 }, - { MOD_TYPE_IMF, "Imago Orpheus", ".imf", 0 }, -};*/ + MODTYPE format; // MOD_TYPE_XXXX + char *name; // "ProTracker" + char *extension; // "mod" +}; +const ModFormatInfo modFormatInfo[] = +{ + { MOD_TYPE_MOD, "ProTracker", "mod" }, + { MOD_TYPE_S3M, "ScreamTracker III", "s3m" }, + { MOD_TYPE_XM, "FastTracker II", "xm" }, + { MOD_TYPE_IT, "Impulse Tracker", "it" }, + { MOD_TYPE_IT, "Impulse Tracker Project", "itp" }, + { MOD_TYPE_MPT, "OpenMPT", "mptm" }, + { MOD_TYPE_STM, "ScreamTracker II", "stm" }, + { MOD_TYPE_MOD, "NoiseTracker", "nst" }, + { MOD_TYPE_MOD, "Soundtracker", "m15" }, + { MOD_TYPE_MOD, "Soundtracker", "stk" }, + { MOD_TYPE_MOD, "Mod's Grave", "wow" }, + { MOD_TYPE_ULT, "UltraTracker", "ult" }, + { MOD_TYPE_669, "Composer 669 / UNIS 669", "669" }, + { MOD_TYPE_MTM, "MultiTracker", "mtm" }, + { MOD_TYPE_MED, "OctaMed", "med" }, + { MOD_TYPE_FAR, "Farandole Composer", "far" }, + { MOD_TYPE_MDL, "DigiTracker", "mdl" }, + { MOD_TYPE_AMS, "Extreme's Tracker", "ams" }, + { MOD_TYPE_AMS2, "Velvet Studio", "ams" }, + { MOD_TYPE_DSM, "DSIK Format", "dsm" }, + { MOD_TYPE_AMF, "DSMI", "amf" }, + { MOD_TYPE_AMF0, "ASYLUM", "amf" }, + { MOD_TYPE_OKT, "Oktalyzer", "okt" }, + { MOD_TYPE_DMF, "X-Tracker", "dmf" }, + { MOD_TYPE_PTM, "PolyTracker", "ptm" }, + { MOD_TYPE_PSM, "Epic Megagames MASI", "psm" }, + { MOD_TYPE_MT2, "MadTracker 2", "mt2" }, + { MOD_TYPE_DBM, "DigiBooster Pro", "dbm" }, + { MOD_TYPE_IMF, "Imago Orpheus", "imf" }, + { MOD_TYPE_J2B, "Galaxy Sound System", "j2b" }, + + // Container formats + { MOD_TYPE_GDM, "General Digital Music", "gdm" }, + { MOD_TYPE_UMX, "Unreal Music", "umx" }, + { MOD_TYPE_UMX, "Unreal Sounds", "uax" }, +#ifndef NO_MO3 + { MOD_TYPE_MO3, "MO3", "mo3" }, +#endif // NO_MO3 + + // Compressed modules + { MOD_TYPE_MOD, "ProTracker", "mdz" }, + { MOD_TYPE_MOD, "ProTracker", "mdr" }, + { MOD_TYPE_S3M, "ScreamTracker III", "s3z" }, + { MOD_TYPE_XM, "FastTracker II", "xmz" }, + { MOD_TYPE_IT, "Impulse Tracker", "itz" }, + { MOD_TYPE_MPT, "OpenMPT", "mptmz" }, +}; + +const ModFormatInfo otherFormatInfo[] = +{ + // Other stuff + { MOD_TYPE_WAV, "Wave", "wav" }, + { MOD_TYPE_MID, "MIDI", "mid" }, + { MOD_TYPE_MID, "MIDI", "rmi" }, + { MOD_TYPE_MID, "MIDI", "smf" }, +}; + + +std::vector<const char *> CSoundFile::GetSupportedExtensions(bool otherFormats) +//----------------------------------------------------------------------------- +{ + std::vector<const char *> exts; + exts.reserve(CountOf(modFormatInfo) + otherFormats ? CountOf(otherFormatInfo) : 0); + for(size_t i = 0; i < CountOf(modFormatInfo); i++) + { + // Avoid dupes in list + if(i == 0 || strcmp(modFormatInfo[i].extension, modFormatInfo[i - 1].extension)) + { + exts.push_back(modFormatInfo[i].extension); + } + } + if(otherFormats) + { + for(size_t i = 0; i < CountOf(otherFormatInfo); i++) + { + exts.push_back(otherFormatInfo[i].extension); + } + } + return exts; +} + + /////////////////////////////////////////////////////////////////////// #pragma data_seg(".tables") #pragma bss_seg(".modplug") Modified: trunk/OpenMPT/unlha/UNLHA32.H =================================================================== --- trunk/OpenMPT/unlha/UNLHA32.H 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/unlha/UNLHA32.H 2013-02-12 16:10:16 UTC (rev 1522) @@ -41,7 +41,7 @@ enum { NC = 255 + MAXMATCH + 2 - THRESHOLD }; public: - CLhaArchive(LPBYTE lpStream, DWORD dwMemLength, LPCSTR lpszExtensions=NULL); + CLhaArchive(LPBYTE lpStream, DWORD dwMemLength); ~CLhaArchive(); public: Modified: trunk/OpenMPT/unlha/Unlha.cpp =================================================================== --- trunk/OpenMPT/unlha/Unlha.cpp 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/unlha/Unlha.cpp 2013-02-12 16:10:16 UTC (rev 1522) @@ -58,8 +58,8 @@ #include "shuf.cpp" #include "larc.cpp" -CLhaArchive::CLhaArchive(LPBYTE lpStream, DWORD dwMemLength, LPCSTR lpszExtensions) -//--------------------------------------------------------------------------------- +CLhaArchive::CLhaArchive(LPBYTE lpStream, DWORD dwMemLength) +//---------------------------------------------------------- { // File Read m_lpStream = lpStream; Modified: trunk/OpenMPT/unrar/Unrar.cpp =================================================================== --- trunk/OpenMPT/unrar/Unrar.cpp 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/unrar/Unrar.cpp 2013-02-12 16:10:16 UTC (rev 1522) @@ -58,8 +58,8 @@ -CRarArchive::CRarArchive(LPBYTE lpStream, DWORD dwMemLength, LPCSTR lpszExtensions) -//--------------------------------------------------------------------------------- +CRarArchive::CRarArchive(LPBYTE lpStream, DWORD dwMemLength) +//---------------------------------------------------------- { // File Read m_lpStream = lpStream; Modified: trunk/OpenMPT/unrar/Unrar32.h =================================================================== --- trunk/OpenMPT/unrar/Unrar32.h 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/unrar/Unrar32.h 2013-02-12 16:10:16 UTC (rev 1522) @@ -7,7 +7,7 @@ //=============== { public: - CRarArchive(LPBYTE lpStream, DWORD dwMemLength, LPCSTR lpszExtensions=NULL); + CRarArchive(LPBYTE lpStream, DWORD dwMemLength); ~CRarArchive(); public: Modified: trunk/OpenMPT/unzip/unzip.cpp =================================================================== --- trunk/OpenMPT/unzip/unzip.cpp 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/unzip/unzip.cpp 2013-02-12 16:10:16 UTC (rev 1522) @@ -8,8 +8,10 @@ */ #include "../soundlib/FileReader.h" +#include <vector> #include "unzip.h" #include "../common/misc_util.h" +#include <algorithm> #ifndef ZLIB_WINAPI #define ZLIB_WINAPI @@ -88,8 +90,8 @@ }; -CZipArchive::CZipArchive(FileReader &file, const char *ext) : inFile(file), extensions(ext) -//----------------------------------------------------------------------------------------- +CZipArchive::CZipArchive(FileReader &file, const std::vector<const char *> &ext) : inFile(file), extensions(ext) +//-------------------------------------------------------------------------------------------------------------- { zlib_filefunc_def functions = { @@ -121,6 +123,19 @@ } +struct find_str +{ + find_str(const char *str): s1(str) { } + + bool operator() (const char *s2) const + { + return !strcmp(s1, s2); + } + + const char *s1; +}; + + bool CZipArchive::ExtractFile() //----------------------------- { @@ -140,7 +155,9 @@ char *ext = name + info.size_filename; while(ext > name) { - if(*(--ext) == '.') + ext--; + *ext = tolower(*ext); + if(*ext == '.') { ext++; break; @@ -148,37 +165,16 @@ } // Compare with list of preferred extensions - char extCmp[16]; - size_t i = 0, j = 0; - bool foundPreferred = false; - while(extensions[i]) + if(std::find_if(extensions.begin(), extensions.end(), find_str(ext)) != extensions.end()) { - char c = extensions[i++]; - extCmp[j] = c; - if(c == '|') - { - extCmp[j] = 0; - j = 0; - if(!lstrcmpi(ext, extCmp)) - { - // File has a preferred extension: use it. - unzGetFilePos(zipFile, &bestFile); - foundPreferred = true; - break; - } - } else - { - j++; - } - } - if(foundPreferred) - { + // File has a preferred extension: use it. + unzGetFilePos(zipFile, &bestFile); break; } - if(lstrcmpi(ext, "diz") - && lstrcmpi(ext, "nfo") - && lstrcmpi(ext, "txt") + if(strcmp(ext, "diz") + && strcmp(ext, "nfo") + && strcmp(ext, "txt") && info.uncompressed_size >= biggestFile) { // If this isn't some kind of info file, we should maybe pick it. Modified: trunk/OpenMPT/unzip/unzip.h =================================================================== --- trunk/OpenMPT/unzip/unzip.h 2013-02-11 22:35:29 UTC (rev 1521) +++ trunk/OpenMPT/unzip/unzip.h 2013-02-12 16:10:16 UTC (rev 1522) @@ -16,7 +16,7 @@ protected: FileReader inFile, outFile; void *zipFile; - const char *extensions; + const std::vector<const char *> &extensions; public: @@ -25,6 +25,6 @@ bool ExtractFile(); void *GetComments(bool get); - CZipArchive(FileReader &file, const char *ext); + CZipArchive(FileReader &file, const std::vector<const char *> &ext); ~CZipArchive(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |