From: <man...@us...> - 2013-11-09 14:03:16
|
Revision: 3147 http://sourceforge.net/p/modplug/code/3147 Author: manxorist Date: 2013-11-09 14:03:07 +0000 (Sat, 09 Nov 2013) Log Message: ----------- [Ref] Use a simple MPT_PATHSTRING(x) macro for constructing mpt::PathString objects from string literals instead of using mpt::PathString::FromUTF8 and raw char * literals which would result in runtime conversion. Modified Paths: -------------- trunk/OpenMPT/common/mptString.h trunk/OpenMPT/common/typedefs.cpp trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/Load_mo3.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/common/mptString.h 2013-11-09 14:03:07 UTC (rev 3147) @@ -294,6 +294,16 @@ } // namespace mpt +#if defined(WIN32) + +#define MPT_PATHSTRING(x) mpt::PathString::FromNative( L ## x ) + +#else // !WIN32 + +#define MPT_PATHSTRING(x) mpt::PathString::FromNative( x ) + +#endif // WIN32 + FILE * mpt_fopen(const mpt::PathString &filename, const char *mode); FILE * mpt_fopen(const mpt::PathString &filename, const wchar_t *mode); Modified: trunk/OpenMPT/common/typedefs.cpp =================================================================== --- trunk/OpenMPT/common/typedefs.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/common/typedefs.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -123,7 +123,7 @@ static FILE * s_logfile = nullptr; if(!s_logfile) { - s_logfile = mpt_fopen(mpt::PathString::FromUTF8("mptrack.log"), "a"); + s_logfile = mpt_fopen(MPT_PATHSTRING("mptrack.log"), "a"); } if(s_logfile) { Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -30,7 +30,7 @@ //Init CommandSet and Load defaults activeCommandSet = new CCommandSet(); - mpt::PathString sDefaultPath = theApp.GetConfigPath() + mpt::PathString::FromUTF8("Keybindings.mkb"); + mpt::PathString sDefaultPath = theApp.GetConfigPath() + MPT_PATHSTRING("Keybindings.mkb"); if(sDefaultPath.AsNative().length() > MAX_PATH - 1) sDefaultPath = mpt::PathString(); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -2507,7 +2507,7 @@ //----------------------- { mpt::PathString helpFile = theApp.GetAppDirPath(); - helpFile += mpt::PathString::FromUTF8("OpenMPT Manual.pdf"); + helpFile += MPT_PATHSTRING("OpenMPT Manual.pdf"); if(!theApp.OpenFile(helpFile)) { Reporting::Error(std::string("Could not find help file:\n" + helpFile.ToLocale()).c_str()); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -721,7 +721,7 @@ // Check if the user prefers to use the app's directory m_szConfigFileName = m_szExePath; // config file - m_szConfigFileName += mpt::PathString::FromUTF8("mptrack.ini"); + m_szConfigFileName += MPT_PATHSTRING("mptrack.ini"); if(GetPrivateProfileIntW(L"Paths", L"UseAppDataDirectory", 1, m_szConfigFileName.AsNative().c_str()) == 0) { bIsAppDir = true; @@ -730,7 +730,7 @@ if(!bIsAppDir) { // Store our app settings in %APPDATA% or "My Files" - m_szConfigDirectory += mpt::PathString::FromUTF8("\\OpenMPT\\"); + m_szConfigDirectory += MPT_PATHSTRING("\\OpenMPT\\"); // Path doesn't exist yet, so it has to be created if(PathIsDirectoryW(m_szConfigDirectory.AsNative().c_str()) == 0) @@ -740,8 +740,8 @@ #ifdef WIN32 // Legacy stuff // Move the config files if they're still in the old place. - MoveConfigFile(mpt::PathString::FromUTF8("mptrack.ini")); - MoveConfigFile(mpt::PathString::FromUTF8("plugin.cache")); + MoveConfigFile(MPT_PATHSTRING("mptrack.ini")); + MoveConfigFile(MPT_PATHSTRING("plugin.cache")); #endif // WIN32 Legacy Stuff } else { @@ -749,7 +749,7 @@ } // Create tunings dir - mpt::PathString sTuningPath = m_szConfigDirectory + mpt::PathString::FromUTF8("tunings\\"); + mpt::PathString sTuningPath = m_szConfigDirectory + MPT_PATHSTRING("tunings\\"); TrackerDirectories::Instance().SetDefaultDirectory(sTuningPath, DIR_TUNING); if(PathIsDirectoryW(TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING).AsNative().c_str()) == 0) @@ -762,13 +762,13 @@ // Import old tunings mpt::PathString sOldTunings; sOldTunings = m_szExePath; - sOldTunings += mpt::PathString::FromUTF8("tunings\\"); + sOldTunings += MPT_PATHSTRING("tunings\\"); if(PathIsDirectoryW(sOldTunings.AsNative().c_str()) != 0) { mpt::PathString sSearchPattern; sSearchPattern = sOldTunings; - sSearchPattern += mpt::PathString::FromUTF8("*.*"); + sSearchPattern += MPT_PATHSTRING("*.*"); WIN32_FIND_DATAW FindFileData; HANDLE hFind; hFind = FindFirstFileW(sSearchPattern.AsNative().c_str(), &FindFileData); @@ -776,7 +776,7 @@ { do { - MoveConfigFile(mpt::PathString::FromNative(FindFileData.cFileName), mpt::PathString::FromUTF8("tunings\\")); + MoveConfigFile(mpt::PathString::FromNative(FindFileData.cFileName), MPT_PATHSTRING("tunings\\")); } while(FindNextFileW(hFind, &FindFileData) != 0); } FindClose(hFind); @@ -786,13 +786,13 @@ // Set up default file locations m_szConfigFileName = m_szConfigDirectory; // config file - m_szConfigFileName += mpt::PathString::FromUTF8("mptrack.ini"); + m_szConfigFileName += MPT_PATHSTRING("mptrack.ini"); - m_szPluginCacheFileName = m_szConfigDirectory + mpt::PathString::FromUTF8("plugin.cache"); // plugin cache + m_szPluginCacheFileName = m_szConfigDirectory + MPT_PATHSTRING("plugin.cache"); // plugin cache mpt::PathString szTemplatePath; szTemplatePath = m_szConfigDirectory; - szTemplatePath += mpt::PathString::FromUTF8("TemplateModules\\"); + szTemplatePath += MPT_PATHSTRING("TemplateModules\\"); TrackerDirectories::Instance().SetDefaultDirectory(szTemplatePath, DIR_TEMPLATE_FILES_USER); //Force use of custom ini file rather than windowsDir\executableName.ini @@ -2088,7 +2088,7 @@ if(!_wcsnicmp(exePath.AsNative().c_str(), path.AsNative().c_str(), exePath.AsNative().length())) { // Path is OpenMPT's directory or a sub directory ("C:\OpenMPT\Somepath" => ".\Somepath") - result = mpt::PathString::FromUTF8(".\\"); // ".\" + result = MPT_PATHSTRING(".\\"); // ".\" result += mpt::PathString::FromNative(path.AsNative().substr(exePath.AsNative().length())); } else if(!_wcsnicmp(exePath.AsNative().c_str(), path.AsNative().c_str(), 2)) { Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -319,11 +319,11 @@ LameDynBind() { Reset(); - if(!hLame) TryLoad(mpt::PathString::FromUTF8("libmp3lame.dll"), true); - if(!hLame) TryLoad(mpt::PathString::FromUTF8("liblame.dll"), true); - if(!hLame) TryLoad(mpt::PathString::FromUTF8("mp3lame.dll"), true); - if(!hLame) TryLoad(mpt::PathString::FromUTF8("lame.dll"), true); - if(!hLame) TryLoad(mpt::PathString::FromUTF8("lame_enc.dll"), false); + if(!hLame) TryLoad(MPT_PATHSTRING("libmp3lame.dll"), true); + if(!hLame) TryLoad(MPT_PATHSTRING("liblame.dll"), true); + if(!hLame) TryLoad(MPT_PATHSTRING("mp3lame.dll"), true); + if(!hLame) TryLoad(MPT_PATHSTRING("lame.dll"), true); + if(!hLame) TryLoad(MPT_PATHSTRING("lame_enc.dll"), false); } void TryLoad(mpt::PathString filename, bool warn) { @@ -648,12 +648,12 @@ Reset(); if(!hBlade) { - TryLoad(mpt::PathString::FromUTF8("lame_enc.dll")); + TryLoad(MPT_PATHSTRING("lame_enc.dll")); if(hBlade) lame = 1; } if(!hBlade) { - TryLoad(mpt::PathString::FromUTF8("bladeenc.dll")); + TryLoad(MPT_PATHSTRING("bladeenc.dll")); if(hBlade) lame = 0; } } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -1618,7 +1618,7 @@ TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINPRESETS, true); } - bool bank = (dlg.GetExtension() == mpt::PathString::FromUTF8("fxb")); + bool bank = (dlg.GetExtension() == MPT_PATHSTRING("fxb")); mpt::fstream f(dlg.GetFirstFile().AsNative().c_str(), std::ios::out | std::ios::trunc | std::ios::binary); if(f.good() && VSTPresets::SaveFile(f, *this, bank)) Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -49,12 +49,12 @@ // Try to load unmo3 dynamically. #ifdef _WIN32 #ifdef MODPLUG_TRACKER - HMODULE unmo3 = LoadLibraryW((theApp.GetAppDirPath() + mpt::PathString::FromUTF8("unmo3.dll")).AsNative().c_str()); + HMODULE unmo3 = LoadLibraryW((theApp.GetAppDirPath() + MPT_PATHSTRING("unmo3.dll")).AsNative().c_str()); #else - HMODULE unmo3 = LoadLibraryW(mpt::PathString::FromUTF8("unmo3.dll").AsNative().c_str()); + HMODULE unmo3 = LoadLibraryW(MPT_PATHSTRING("unmo3.dll").AsNative().c_str()); #endif // MODPLUG_TRACKER #else - void unmo3 = dlopen(mpt::PathString::FromUTF8("libunmo3.so").AsNative().c_str(), RTLD_LAZY); + void unmo3 = dlopen(MPT_PATHSTRING("libunmo3.so").AsNative().c_str(), RTLD_LAZY); #endif // _WIN32 if(unmo3 == nullptr) Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -2287,11 +2287,11 @@ } #ifdef MODPLUG_TRACKER - if(!mp3lib) mp3lib = LoadLibraryW((theApp.GetAppDirPath() + mpt::PathString::FromUTF8("libmpg123-0.dll")).AsNative().c_str()); - if(!mp3lib) mp3lib = LoadLibraryW((theApp.GetAppDirPath() + mpt::PathString::FromUTF8("libmpg123.dll")).AsNative().c_str()); + if(!mp3lib) mp3lib = LoadLibraryW((theApp.GetAppDirPath() + MPT_PATHSTRING("libmpg123-0.dll")).AsNative().c_str()); + if(!mp3lib) mp3lib = LoadLibraryW((theApp.GetAppDirPath() + MPT_PATHSTRING("libmpg123.dll")).AsNative().c_str()); #else - if(!mp3lib) mp3lib = LoadLibraryW(mpt::PathString::FromUTF8("libmpg123-0.dll").AsNative().c_str()); - if(!mp3lib) mp3lib = LoadLibraryW(mpt::PathString::FromUTF8("libmpg123.dll").AsNative().c_str()); + if(!mp3lib) mp3lib = LoadLibraryW(MPT_PATHSTRING("libmpg123-0.dll").AsNative().c_str()); + if(!mp3lib) mp3lib = LoadLibraryW(MPT_PATHSTRING("libmpg123.dll").AsNative().c_str()); #endif // MODPLUG_TRACKER if(!mp3lib) return false; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -1725,7 +1725,7 @@ // Load local tunings. s_pTuningsSharedLocal->SetSavefilePath( TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING) - + mpt::PathString::FromUTF8("local_tunings") + + MPT_PATHSTRING("local_tunings") + mpt::PathString::FromUTF8(CTuningCollection::s_FileExtension) ); s_pTuningsSharedLocal->Deserialize(); Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2013-11-09 13:44:41 UTC (rev 3146) +++ trunk/OpenMPT/test/test.cpp 2013-11-09 14:03:07 UTC (rev 3147) @@ -1386,7 +1386,7 @@ break; } } - theFile += mpt::PathString::FromUTF8("test/test."); + theFile += MPT_PATHSTRING("test/test."); return theFile; } @@ -1438,7 +1438,7 @@ static mpt::PathString GetTestFilenameBase() { - return mpt::PathString::FromUTF8("../test/test."); + return MPT_PATHSTRING("../test/test."); } typedef std::shared_ptr<CSoundFile> TSoundFileContainer; @@ -1497,13 +1497,13 @@ // Test MPTM file loading { - TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + mpt::PathString::FromUTF8("mptm")); + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + MPT_PATHSTRING("mptm")); TestLoadMPTMFile(GetrSoundFile(sndFileContainer)); #ifndef MODPLUG_NO_FILESAVE // Test file saving - SaveIT(sndFileContainer, filenameBase + mpt::PathString::FromUTF8("saved.mptm")); + SaveIT(sndFileContainer, filenameBase + MPT_PATHSTRING("saved.mptm")); #endif DestroySoundFileContainer(sndFileContainer); @@ -1512,7 +1512,7 @@ // Reload the saved file and test if everything is still working correctly. #ifndef MODPLUG_NO_FILESAVE { - TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + mpt::PathString::FromUTF8("saved.mptm")); + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + MPT_PATHSTRING("saved.mptm")); TestLoadMPTMFile(GetrSoundFile(sndFileContainer)); @@ -1522,7 +1522,7 @@ // Test XM file loading { - TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + mpt::PathString::FromUTF8("xm")); + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + MPT_PATHSTRING("xm")); TestLoadXMFile(GetrSoundFile(sndFileContainer)); @@ -1536,7 +1536,7 @@ #ifndef MODPLUG_NO_FILESAVE // Test file saving - SaveXM(sndFileContainer, filenameBase + mpt::PathString::FromUTF8("saved.xm")); + SaveXM(sndFileContainer, filenameBase + MPT_PATHSTRING("saved.xm")); #endif DestroySoundFileContainer(sndFileContainer); @@ -1545,7 +1545,7 @@ // Reload the saved file and test if everything is still working correctly. #ifndef MODPLUG_NO_FILESAVE { - TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + mpt::PathString::FromUTF8("saved.xm")); + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + MPT_PATHSTRING("saved.xm")); TestLoadXMFile(GetrSoundFile(sndFileContainer)); @@ -1555,13 +1555,13 @@ // Test S3M file loading { - TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + mpt::PathString::FromUTF8("s3m")); + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + MPT_PATHSTRING("s3m")); TestLoadS3MFile(GetrSoundFile(sndFileContainer), false); #ifndef MODPLUG_NO_FILESAVE // Test file saving - SaveS3M(sndFileContainer, filenameBase + mpt::PathString::FromUTF8("saved.s3m")); + SaveS3M(sndFileContainer, filenameBase + MPT_PATHSTRING("saved.s3m")); #endif DestroySoundFileContainer(sndFileContainer); @@ -1570,7 +1570,7 @@ // Reload the saved file and test if everything is still working correctly. #ifndef MODPLUG_NO_FILESAVE { - TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + mpt::PathString::FromUTF8("saved.s3m")); + TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + MPT_PATHSTRING("saved.s3m")); TestLoadS3MFile(GetrSoundFile(sndFileContainer), true); @@ -1583,7 +1583,7 @@ void RunITCompressionTest(const std::vector<int8> &sampleData, ChannelFlags smpFormat, bool it215, int testcount) //--------------------------------------------------------------------------------------------------------------- { - mpt::PathString filename = GetTestFilenameBase() + mpt::PathString::FromUTF8("itcomp" + Stringify(testcount) + ".raw"); + mpt::PathString filename = GetTestFilenameBase() + MPT_PATHSTRING("itcomp" + Stringify(testcount) + ".raw"); ModSample smp; smp.uFlags = smpFormat; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |