From: <man...@us...> - 2013-11-08 11:51:04
|
Revision: 3122 http://sourceforge.net/p/modplug/code/3122 Author: manxorist Date: 2013-11-08 11:50:55 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Ref] First batch of PathString conversions. Still a lot of work to do. Modified Paths: -------------- trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/AutoSaver.h trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/Settings.cpp trunk/OpenMPT/mptrack/Settings.h trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h 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/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -203,8 +203,8 @@ } -CString CAutoSaver::BuildFileName(CModDoc &modDoc) -//------------------------------------------------ +mpt::PathString CAutoSaver::BuildFileName(CModDoc &modDoc) +//-------------------------------------------------------- { CString timeStamp = (CTime::GetCurrentTime()).Format("%Y%m%d.%H%M%S"); CString name; @@ -218,7 +218,7 @@ } else { // if it doesnt, put it in settings dir - name = theApp.GetConfigPath() + modDoc.GetTitle(); + name = theApp.GetConfigPath().ToCString() + modDoc.GetTitle(); } } else { @@ -236,7 +236,7 @@ name.Append(modDoc.GetrSoundFile().GetModSpecifications().fileExtension); } - return name; + return mpt::PathString::FromCString(name); } @@ -247,7 +247,7 @@ // list with backups... hence we have duplicated code.. :( CSoundFile &sndFile = modDoc.GetrSoundFile(); - CString fileName = BuildFileName(modDoc); + CString fileName = BuildFileName(modDoc).ToCString(); // We are acutally not going to show the log for autosaved files. ScopedLogCapturer logcapturer(modDoc, "", nullptr, false); @@ -296,7 +296,7 @@ path = fullPath.Left(fullPath.GetLength() - modDoc.GetTitle().GetLength()); //remove file name if necessary } else { - path = theApp.GetConfigPath(); + path = theApp.GetConfigPath().ToCString(); } } else { Modified: trunk/OpenMPT/mptrack/AutoSaver.h =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.h 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/AutoSaver.h 2013-11-08 11:50:55 UTC (rev 3122) @@ -44,7 +44,7 @@ //internal implementation private: bool SaveSingleFile(CModDoc &modDoc); - CString BuildFileName(CModDoc &modDoc); + mpt::PathString BuildFileName(CModDoc &modDoc); void CleanUpBackups(CModDoc &modDoc); bool CheckTimer(DWORD curTime); Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -107,7 +107,7 @@ if(numFiles == 0) { // Show the rescue directory in Explorer... - CTrackApp::OpenDirectory(baseRescuePath); + CTrackApp::OpenDirectory(mpt::PathString::FromCString(baseRescuePath)); } CString filename; filename.Format("%s%d_%s.%s", baseRescuePath, ++numFiles, pModDoc->GetTitle(), pModDoc->GetSoundFile()->GetModSpecifications().fileExtension); Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -30,11 +30,11 @@ //Init CommandSet and Load defaults activeCommandSet = new CCommandSet(); - CString sDefaultPath = CString(theApp.GetConfigPath()) + TEXT("Keybindings.mkb"); + CString sDefaultPath = theApp.GetConfigPath().ToCString() + TEXT("Keybindings.mkb"); if (sDefaultPath.GetLength() > MAX_PATH - 1) sDefaultPath = ""; - const bool bNoExistingKbdFileSetting = (TrackerSettings::Instance().m_szKbdFile[0] == 0); + const bool bNoExistingKbdFileSetting = TrackerSettings::Instance().m_szKbdFile.empty(); // 1. Try to load keybindings from the path saved in the settings. // 2. If the setting doesn't exist or the loading fails, try to load from default location. @@ -42,10 +42,10 @@ // 4. If there were no keybinging setting already, create a keybinding file to default location // and set it's path to settings. - if (bNoExistingKbdFileSetting || !(activeCommandSet->LoadFile(TrackerSettings::Instance().m_szKbdFile))) + if (bNoExistingKbdFileSetting || !(activeCommandSet->LoadFile(TrackerSettings::Instance().m_szKbdFile.ToCString()))) { if (bNoExistingKbdFileSetting) - _tcscpy(TrackerSettings::Instance().m_szKbdFile, sDefaultPath); + TrackerSettings::Instance().m_szKbdFile = mpt::PathString::FromCString(sDefaultPath); bool bSuccess = false; if (PathFileExists(sDefaultPath) == TRUE) bSuccess = activeCommandSet->LoadFile(sDefaultPath); @@ -56,14 +56,14 @@ bSuccess = activeCommandSet->LoadDefaultKeymap(); if (bSuccess && bNoExistingKbdFileSetting) { - activeCommandSet->SaveFile(TrackerSettings::Instance().m_szKbdFile); + activeCommandSet->SaveFile(TrackerSettings::Instance().m_szKbdFile.ToCString()); } } if (bSuccess == false) ErrorBox(IDS_UNABLE_TO_LOAD_KEYBINDINGS); } // We will only overwrite the default Keybindings.mkb file from now on. - _tcscpy(TrackerSettings::Instance().m_szKbdFile, sDefaultPath); + TrackerSettings::Instance().m_szKbdFile = mpt::PathString::FromCString(sDefaultPath); //Get Keymap activeCommandSet->GenKeyMap(keyMap); Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -162,7 +162,7 @@ m_nCurKeyChoice = -1; m_bModified = false; m_bChoiceModified = false; - m_sFullPathName = TrackerSettings::Instance().m_szKbdFile; + m_sFullPathName = TrackerSettings::Instance().m_szKbdFile.ToCString(); plocalCmdSet = new CCommandSet(); plocalCmdSet->Copy(CMainFrame::GetInputHandler()->activeCommandSet); @@ -842,7 +842,7 @@ .DefaultExtension("mkb") .DefaultFilename(std::string(m_sFullPathName)) .ExtensionFilter("OpenMPT Key Bindings (*.mkb)|*.mkb||") - .WorkingDirectory(TrackerSettings::Instance().m_szKbdFile); + .WorkingDirectory(TrackerSettings::Instance().m_szKbdFile.ToLocale()); if(!dlg.Show()) return; m_sFullPathName = dlg.GetFirstFile().c_str(); @@ -859,7 +859,7 @@ .DefaultExtension("mkb") .DefaultFilename(std::string(m_sFullPathName)) .ExtensionFilter("OpenMPT Key Bindings (*.mkb)|*.mkb||") - .WorkingDirectory(TrackerSettings::Instance().m_szKbdFile); + .WorkingDirectory(TrackerSettings::Instance().m_szKbdFile.ToLocale()); if(!dlg.Show()) return; m_sFullPathName = dlg.GetFirstFile().c_str(); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -467,7 +467,7 @@ if(m_InputHandler && m_InputHandler->activeCommandSet) { - m_InputHandler->activeCommandSet->SaveFile(TrackerSettings::Instance().m_szKbdFile); + m_InputHandler->activeCommandSet->SaveFile(TrackerSettings::Instance().m_szKbdFile.ToCString()); } EndWaitCursor(); @@ -2508,12 +2508,11 @@ void CMainFrame::OnHelp() //----------------------- { - CString helpFile = theApp.GetAppDirPath(); - helpFile += "OpenMPT Manual.pdf"; + mpt::PathString helpFile = theApp.GetAppDirPath(); + helpFile += mpt::PathString::FromUTF8("OpenMPT Manual.pdf"); if(!theApp.OpenFile(helpFile)) { - helpFile = "Could not find help file:\n" + helpFile; - Reporting::Error(helpFile); + Reporting::Error(std::string("Could not find help file:\n" + helpFile.ToLocale()).c_str()); } } @@ -2530,11 +2529,11 @@ for(size_t i = 0; i < 2; i++) // 0: app items, 1: user items { // To avoid duplicates, check whether app path and config path are the same. - if (i == 1 && _tcsicmp(CTrackApp::GetAppDirPath(), theApp.GetConfigPath()) == 0) + if (i == 1 && _tcsicmp(CTrackApp::GetAppDirPath().ToCString(), theApp.GetConfigPath().ToCString()) == 0) break; CFileFind fileFind; CFixedStringT<CString, MAX_PATH> sPath; - sPath = (i == 0) ? CTrackApp::GetAppDirPath() : theApp.GetConfigPath(); + sPath = (i == 0) ? CTrackApp::GetAppDirPath().ToCString() : theApp.GetConfigPath().ToCString(); sPath += pszFolderName; if (Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeExists) == false) continue; Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -491,7 +491,7 @@ FileDialog dlg = OpenFileDialog() .DefaultExtension("mptcolor") .ExtensionFilter("OpenMPT Color Schemes|*.mptcolor||") - .WorkingDirectory(theApp.GetConfigPath()); + .WorkingDirectory(theApp.GetConfigPath().ToLocale()); if(!dlg.Show()) return; // Ensure that all colours are reset (for outdated colour schemes) @@ -514,7 +514,7 @@ FileDialog dlg = SaveFileDialog() .DefaultExtension("mptcolor") .ExtensionFilter("OpenMPT Color Schemes|*.mptcolor||") - .WorkingDirectory(theApp.GetConfigPath()); + .WorkingDirectory(theApp.GetConfigPath().ToLocale()); if(!dlg.Show()) return; { Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -260,7 +260,7 @@ } -TCHAR CTrackApp::m_szExePath[_MAX_PATH] = TEXT(""); +mpt::PathString CTrackApp::m_szExePath; ///////////////////////////////////////////////////////////////////////////// // MPTRACK Command Line options @@ -650,8 +650,6 @@ m_pPluginManager = NULL; m_pSoundDevicesManager = nullptr; m_bInitialized = FALSE; - m_szConfigFileName[0] = 0; - m_szPluginCacheFileName[0] = 0; } @@ -662,27 +660,29 @@ // Move a config file called sFileName from the App's directory (or one of its sub directories specified by sSubDir) to // %APPDATA%. If specified, it will be renamed to sNewFileName. Existing files are never overwritten. // Returns true on success. -bool CTrackApp::MoveConfigFile(TCHAR sFileName[_MAX_PATH], TCHAR sSubDir[_MAX_PATH], TCHAR sNewFileName[_MAX_PATH]) -//----------------------------------------------------------------------------------------------------------------- +bool CTrackApp::MoveConfigFile(mpt::PathString sFileName, mpt::PathString sSubDir, mpt::PathString sNewFileName) +//-------------------------------------------------------------------------------------------------------------- { // copy a config file from the exe directory to the new config dirs - TCHAR sOldPath[_MAX_PATH], sNewPath[_MAX_PATH]; - strcpy(sOldPath, m_szExePath); - if(sSubDir[0]) - strcat(sOldPath, sSubDir); - strcat(sOldPath, sFileName); + mpt::PathString sOldPath; + mpt::PathString sNewPath; + sOldPath = m_szExePath; + sOldPath += sSubDir; + sOldPath += sFileName; - strcpy(sNewPath, m_szConfigDirectory); - if(sSubDir[0]) - strcat(sNewPath, sSubDir); - if(sNewFileName[0]) - strcat(sNewPath, sNewFileName); - else - strcat(sNewPath, sFileName); + sNewPath = m_szConfigDirectory; + sNewPath += sSubDir; + if(!sNewFileName.empty()) + { + sNewPath += sNewFileName; + } else + { + sNewPath += sFileName; + } - if(PathFileExists(sNewPath) == 0 && PathFileExists(sOldPath) != 0) + if(PathFileExistsW(sNewPath.AsNative().c_str()) == 0 && PathFileExistsW(sOldPath.AsNative().c_str()) != 0) { - return (MoveFile(sOldPath, sNewPath) != 0); + return (MoveFileW(sOldPath.AsNative().c_str(), sNewPath.AsNative().c_str()) != 0); } return false; } @@ -693,33 +693,39 @@ void CTrackApp::SetupPaths(bool overridePortable) //----------------------------------------------- { - if(GetModuleFileName(NULL, m_szExePath, CountOf(m_szExePath))) + WCHAR tempExePath[MAX_PATH]; + if(GetModuleFileNameW(NULL, tempExePath, CountOf(tempExePath))) { - mpt::String::SetNullTerminator(m_szExePath); - TCHAR szDrive[_MAX_DRIVE] = "", szDir[_MAX_PATH] = ""; - _splitpath(m_szExePath, szDrive, szDir, NULL, NULL); - strcpy(m_szExePath, szDrive); - strcat(m_szExePath, szDir); + mpt::String::SetNullTerminator(tempExePath); + wchar_t szDrive[_MAX_DRIVE] = L""; + wchar_t szDir[_MAX_PATH] = L""; + _wsplitpath(tempExePath, szDrive, szDir, NULL, NULL); + m_szExePath = mpt::PathString::FromNative(szDrive); + m_szExePath += mpt::PathString::FromNative(szDir); - GetFullPathName(m_szExePath, CountOf(szDir), szDir, NULL); - strcpy(m_szExePath, szDir); + WCHAR wcsDir[MAX_PATH]; + GetFullPathNameW(m_szExePath.AsNative().c_str(), CountOf(wcsDir), wcsDir, NULL); + m_szExePath = mpt::PathString::FromNative(wcsDir); } - m_szConfigDirectory[0] = 0; + m_szConfigDirectory = mpt::PathString(); // Try to find a nice directory where we should store our settings (default: %APPDATA%) bool bIsAppDir = overridePortable; - if(!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, m_szConfigDirectory))) + WCHAR tempConfigDirectory[MAX_PATH]; + tempConfigDirectory[0] = 0; + if(!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tempConfigDirectory))) { - if(!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, m_szConfigDirectory))) + if(!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, tempConfigDirectory))) { bIsAppDir = true; } } + m_szConfigDirectory = mpt::PathString::FromNative(tempConfigDirectory); // Check if the user prefers to use the app's directory - strcpy(m_szConfigFileName, m_szExePath); // config file - strcat(m_szConfigFileName, "mptrack.ini"); - if(GetPrivateProfileInt("Paths", "UseAppDataDirectory", 1, m_szConfigFileName) == 0) + m_szConfigFileName = m_szExePath; // config file + m_szConfigFileName += mpt::PathString::FromUTF8("mptrack.ini"); + if(GetPrivateProfileIntW(L"Paths", L"UseAppDataDirectory", 1, m_szConfigFileName.AsNative().c_str()) == 0) { bIsAppDir = true; } @@ -727,79 +733,81 @@ if(!bIsAppDir) { // Store our app settings in %APPDATA% or "My Files" - strcat(m_szConfigDirectory, "\\OpenMPT\\"); + m_szConfigDirectory += mpt::PathString::FromUTF8("\\OpenMPT\\"); // Path doesn't exist yet, so it has to be created - if(PathIsDirectory(m_szConfigDirectory) == 0) + if(PathIsDirectoryW(m_szConfigDirectory.AsNative().c_str()) == 0) { - CreateDirectory(m_szConfigDirectory, 0); + CreateDirectoryW(m_szConfigDirectory.AsNative().c_str(), 0); } #ifdef WIN32 // Legacy stuff // Move the config files if they're still in the old place. - MoveConfigFile("mptrack.ini"); - MoveConfigFile("plugin.cache"); + MoveConfigFile(mpt::PathString::FromUTF8("mptrack.ini")); + MoveConfigFile(mpt::PathString::FromUTF8("plugin.cache")); #endif // WIN32 Legacy Stuff } else { - strcpy(m_szConfigDirectory, m_szExePath); + m_szConfigDirectory = m_szExePath; } // Create tunings dir - CString sTuningPath; - sTuningPath.Format(TEXT("%stunings\\"), m_szConfigDirectory); - TrackerDirectories::Instance().SetDefaultDirectory(sTuningPath, DIR_TUNING); + mpt::PathString sTuningPath = m_szConfigDirectory + mpt::PathString::FromUTF8("tunings\\"); + TrackerDirectories::Instance().SetDefaultDirectory(sTuningPath.ToLocale().c_str(), DIR_TUNING); - if(PathIsDirectory(TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING)) == 0) + if(PathIsDirectoryW(mpt::PathString::FromLocale(TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING)).AsNative().c_str()) == 0) { - CreateDirectory(TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING), 0); + CreateDirectoryW(mpt::PathString::FromLocale(TrackerDirectories::Instance().GetDefaultDirectory(DIR_TUNING)).AsNative().c_str(), 0); } if(!bIsAppDir) { // Import old tunings - TCHAR sOldTunings[_MAX_PATH]; - strcpy(sOldTunings, m_szExePath); - strcat(sOldTunings, "tunings\\"); + mpt::PathString sOldTunings; + sOldTunings = m_szExePath; + sOldTunings += mpt::PathString::FromUTF8("tunings\\"); - if(PathIsDirectory(sOldTunings) != 0) + if(PathIsDirectoryW(sOldTunings.AsNative().c_str()) != 0) { - TCHAR sSearchPattern[_MAX_PATH]; - strcpy(sSearchPattern, sOldTunings); - strcat(sSearchPattern, "*.*"); - WIN32_FIND_DATA FindFileData; + mpt::PathString sSearchPattern; + sSearchPattern = sOldTunings; + sSearchPattern += mpt::PathString::FromUTF8("*.*"); + WIN32_FIND_DATAW FindFileData; HANDLE hFind; - hFind = FindFirstFile(sSearchPattern, &FindFileData); + hFind = FindFirstFileW(sSearchPattern.AsNative().c_str(), &FindFileData); if(hFind != INVALID_HANDLE_VALUE) { do { - MoveConfigFile(FindFileData.cFileName, "tunings\\"); - } while(FindNextFile(hFind, &FindFileData) != 0); + MoveConfigFile(mpt::PathString::FromNative(FindFileData.cFileName), mpt::PathString::FromUTF8("tunings\\")); + } while(FindNextFileW(hFind, &FindFileData) != 0); } FindClose(hFind); - RemoveDirectory(sOldTunings); + RemoveDirectoryW(sOldTunings.AsNative().c_str()); } } // Set up default file locations - strcpy(m_szConfigFileName, m_szConfigDirectory); // config file - strcat(m_szConfigFileName, "mptrack.ini"); + m_szConfigFileName = m_szConfigDirectory; // config file + m_szConfigFileName += mpt::PathString::FromUTF8("mptrack.ini"); - strcpy(m_szPluginCacheFileName, m_szConfigDirectory); // plugin cache - strcat(m_szPluginCacheFileName, "plugin.cache"); + m_szPluginCacheFileName = m_szConfigDirectory + mpt::PathString::FromUTF8("plugin.cache"); // plugin cache - TCHAR szTemplatePath[MAX_PATH]; - _tcscpy(szTemplatePath, m_szConfigDirectory); - _tcscat(szTemplatePath, _T("TemplateModules\\")); - TrackerDirectories::Instance().SetDefaultDirectory(szTemplatePath, DIR_TEMPLATE_FILES_USER); + mpt::PathString szTemplatePath; + szTemplatePath = m_szConfigDirectory; + szTemplatePath += mpt::PathString::FromUTF8("TemplateModules\\"); + TrackerDirectories::Instance().SetDefaultDirectory(szTemplatePath.ToLocale().c_str(), DIR_TEMPLATE_FILES_USER); //Force use of custom ini file rather than windowsDir\executableName.ini if(m_pszProfileName) { free((void *)m_pszProfileName); } - m_pszProfileName = _tcsdup(m_szConfigFileName); + #ifdef UNICODE + m_pszProfileName = _tcsdup(m_szConfigFileName.AsNative().c_str()); + #else + m_pszProfileName = _tcsdup(m_szConfigFileName.ToLocale().c_str()); + #endif m_bPortableMode = bIsAppDir; } @@ -839,13 +847,13 @@ // Construct auto saver instance, class TrackerSettings expects it being available. CMainFrame::m_pAutoSaver = new CAutoSaver(); - m_pSettingsIniFile = new IniFileSettingsBackend(mpt::PathString::FromLocale(m_szConfigFileName)); + m_pSettingsIniFile = new IniFileSettingsBackend(m_szConfigFileName); m_pSettings = new SettingsContainer(m_pSettingsIniFile); m_pTrackerSettings = new TrackerSettings(*m_pSettings); - m_pPluginCache = new IniFileSettingsContainer(mpt::PathString::FromLocale(m_szPluginCacheFileName)); + m_pPluginCache = new IniFileSettingsContainer(m_szPluginCacheFileName); int mruListLength = GetSettings().Read<int32>("Misc", "MRUListLength", 10); Limit(mruListLength, 0, 15); @@ -2030,15 +2038,34 @@ /////////////////////////////////////////////////////////////////////////////////// // Internet-related functions -bool CTrackApp::OpenURL(const LPCSTR lpszURL) -//------------------------------------------- +bool CTrackApp::OpenURL(const char *url) +//-------------------------------------- { - if(lpszURL != nullptr && lpszURL[0] != '\0' && theApp.m_pMainWnd) + if(!url) return false; + return OpenURL(mpt::PathString::FromUTF8(url)); +} + +bool CTrackApp::OpenURL(const std::string &url) +//--------------------------------------------- +{ + return OpenURL(mpt::PathString::FromUTF8(url)); +} + +bool CTrackApp::OpenURL(const CString &url) +//----------------------------------------- +{ + return OpenURL(mpt::PathString::FromCString(url)); +} + +bool CTrackApp::OpenURL(const mpt::PathString &lpszURL) +//----------------------------------------------------- +{ + if(!lpszURL.empty() && theApp.m_pMainWnd) { - if(reinterpret_cast<int>(ShellExecute( + if(reinterpret_cast<int>(ShellExecuteW( theApp.m_pMainWnd->m_hWnd, - "open", - lpszURL, + L"open", + lpszURL.AsNative().c_str(), NULL, NULL, SW_SHOW)) >= 32) @@ -2065,7 +2092,7 @@ const size_t nStrLength = nLength - 1; // "usable" length, i.e. not including the null char. TCHAR szExePath[nLength], szTempPath[nLength]; - _tcsncpy(szExePath, GetAppDirPath(), nStrLength); + _tcsncpy(szExePath, GetAppDirPath().ToCString(), nStrLength); mpt::String::SetNullTerminator(szExePath); if(!_tcsncicmp(szExePath, szPath, _tcslen(szExePath))) @@ -2108,7 +2135,7 @@ const size_t nStrLength = nLength - 1; // "usable" length, i.e. not including the null char. TCHAR szExePath[nLength], szTempPath[nLength] = _T(""); - _tcsncpy(szExePath, GetAppDirPath(), nStrLength); + _tcsncpy(szExePath, GetAppDirPath().ToCString(), nStrLength); mpt::String::SetNullTerminator(szExePath); if(!_tcsncicmp(szPath, _T("\\"), 1) && _tcsncicmp(szPath, _T("\\\\"), 2)) Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-11-08 11:50:55 UTC (rev 3122) @@ -114,10 +114,10 @@ DWORD m_dwTimeStarted, m_dwLastPluginIdleCall; // Default macro configuration MIDIMacroConfig m_MidiCfg; - static TCHAR m_szExePath[_MAX_PATH]; - TCHAR m_szConfigDirectory[_MAX_PATH]; - TCHAR m_szConfigFileName[_MAX_PATH]; - TCHAR m_szPluginCacheFileName[_MAX_PATH]; + static mpt::PathString m_szExePath; + mpt::PathString m_szConfigDirectory; + mpt::PathString m_szConfigFileName; + mpt::PathString m_szPluginCacheFileName; bool m_bPortableMode; public: @@ -131,7 +131,7 @@ static VOID SetAsProject(BOOL n) { m_nProject = n; } // -! NEW_FEATURE#0023 - static LPCTSTR GetAppDirPath() {return m_szExePath;} // Returns '\'-ended executable directory path. + static mpt::PathString GetAppDirPath() {return m_szExePath;} // Returns '\'-ended executable directory path. static MODTYPE GetDefaultDocType() { return m_nDefaultDocType; } static void SetDefaultDocType(MODTYPE n) { m_nDefaultDocType = n; } static LPMIDILIBSTRUCT GetMidiLibrary() { return glpMidiLibrary; } @@ -144,9 +144,12 @@ static BOOL SaveDefaultDLSBanks(); static BOOL RemoveDLSBank(UINT nBank); static BOOL AddDLSBank(LPCSTR); - static bool OpenURL(const LPCSTR lpszURL); - static bool OpenFile(const LPCSTR file) { return OpenURL(file); }; - static bool OpenDirectory(const LPCSTR directory) { return OpenURL(directory); }; + static bool OpenURL(const char *url); + static bool OpenURL(const std::string &url); + static bool OpenURL(const CString &url); + static bool OpenURL(const mpt::PathString &lpszURL); + static bool OpenFile(const mpt::PathString &file) { return OpenURL(file); }; + static bool OpenDirectory(const mpt::PathString &directory) { return OpenURL(directory); }; int GetOpenDocumentCount() const; std::vector<CModDoc *>GetOpenDocuments() const; @@ -157,7 +160,7 @@ SoundDevicesManager *GetSoundDevicesManager() const { return m_pSoundDevicesManager; } void GetDefaultMidiMacro(MIDIMacroConfig &cfg) const { cfg = m_MidiCfg; } void SetDefaultMidiMacro(const MIDIMacroConfig &cfg) { m_MidiCfg = cfg; } - std::string GetConfigFileName() const { return m_szConfigFileName; } + mpt::PathString GetConfigFileName() const { return m_szConfigFileName; } TrackerDirectories & GetTrackerDirectories() { ASSERT(m_pTrackerDirectories); @@ -181,7 +184,7 @@ } /// Returns path to config folder including trailing '\'. - LPCTSTR GetConfigPath() const { return m_szConfigDirectory; } + mpt::PathString GetConfigPath() const { return m_szConfigDirectory; } void SetupPaths(bool overridePortable); // Relative / absolute paths conversion template <size_t nLength> @@ -239,7 +242,7 @@ #ifdef WIN32 // Legacy stuff - bool MoveConfigFile(TCHAR sFileName[_MAX_PATH], TCHAR sSubDir[_MAX_PATH] = _T(""), TCHAR sNewFileName[_MAX_PATH] = _T("")); + bool MoveConfigFile(mpt::PathString sFileName, mpt::PathString sSubDir = mpt::PathString(), mpt::PathString sNewFileName = mpt::PathString()); #endif // WIN32 }; Modified: trunk/OpenMPT/mptrack/Settings.cpp =================================================================== --- trunk/OpenMPT/mptrack/Settings.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/Settings.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -525,7 +525,7 @@ DefaultSettingsContainer::DefaultSettingsContainer() - : IniFileSettingsContainer(mpt::PathString::FromLocale(theApp.GetConfigFileName())) + : IniFileSettingsContainer(theApp.GetConfigFileName()) { return; } Modified: trunk/OpenMPT/mptrack/Settings.h =================================================================== --- trunk/OpenMPT/mptrack/Settings.h 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/Settings.h 2013-11-08 11:50:55 UTC (rev 3122) @@ -296,6 +296,9 @@ template<> inline SettingValue ToSettingValue(const CString &val) { return SettingValue(std::basic_string<TCHAR>(val.GetString())); } template<> inline CString FromSettingValue(const SettingValue &val) { return CString(val.as<std::basic_string<TCHAR> >().c_str()); } +template<> inline SettingValue ToSettingValue(const mpt::PathString &val) { return SettingValue(val.AsNative()); } +template<> inline mpt::PathString FromSettingValue(const SettingValue &val) { return mpt::PathString::FromNative(val); } + template<> inline SettingValue ToSettingValue(const float &val) { return SettingValue(double(val)); } template<> inline float FromSettingValue(const SettingValue &val) { return float(val.as<double>()); } Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -319,18 +319,18 @@ LameDynBind() { Reset(); - if(!hLame) TryLoad("libmp3lame.dll", true); - if(!hLame) TryLoad("liblame.dll", true); - if(!hLame) TryLoad("mp3lame.dll", true); - if(!hLame) TryLoad("lame.dll", true); - if(!hLame) TryLoad("lame_enc.dll", false); + 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); } - void TryLoad(std::string filename, bool warn) + void TryLoad(mpt::PathString filename, bool warn) { #ifdef MODPLUG_TRACKER - filename = std::string(theApp.GetAppDirPath()) + filename; + filename = theApp.GetAppDirPath() + filename; #endif - hLame = LoadLibrary(filename.c_str()); + hLame = LoadLibraryW(filename.AsNative().c_str()); if(!hLame) { return; @@ -648,21 +648,21 @@ Reset(); if(!hBlade) { - TryLoad("lame_enc.dll"); + TryLoad(mpt::PathString::FromUTF8("lame_enc.dll")); if(hBlade) lame = 1; } if(!hBlade) { - TryLoad("bladeenc.dll"); + TryLoad(mpt::PathString::FromUTF8("bladeenc.dll")); if(hBlade) lame = 0; } } - void TryLoad(std::string filename) + void TryLoad(mpt::PathString filename) { #ifdef MODPLUG_TRACKER - filename = std::string(theApp.GetAppDirPath()) + filename; + filename = theApp.GetAppDirPath() + filename; #endif - hBlade = LoadLibrary(filename.c_str()); + hBlade = LoadLibraryW(filename.AsNative().c_str()); if(!hBlade) { return; Modified: trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/StreamEncoderOpus.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -86,27 +86,27 @@ }; for(std::size_t i=0; i<CountOf(dll_names); ++i) { - if(TryLoad(dll_names[i].ogg, dll_names[i].opus)) + if(TryLoad(mpt::PathString::FromUTF8(dll_names[i].ogg), mpt::PathString::FromUTF8(dll_names[i].opus))) { // success break; } } } - bool TryLoad(std::string Ogg_fn, std::string Opus_fn) + bool TryLoad(mpt::PathString Ogg_fn, mpt::PathString Opus_fn) { #ifdef MODPLUG_TRACKER - Ogg_fn = std::string(theApp.GetAppDirPath()) + Ogg_fn; - Opus_fn = std::string(theApp.GetAppDirPath()) + Opus_fn; + Ogg_fn = theApp.GetAppDirPath() + Ogg_fn; + Opus_fn = theApp.GetAppDirPath() + Opus_fn; #endif - hOgg = LoadLibrary(Ogg_fn.c_str()); + hOgg = LoadLibraryW(Ogg_fn.AsNative().c_str()); if(!hOgg) { if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } if(hOpus) { FreeLibrary(hOpus); hOpus = NULL; } return false; } - hOpus = LoadLibrary(Opus_fn.c_str()); + hOpus = LoadLibraryW(Opus_fn.AsNative().c_str()); if(!hOpus) { if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } Modified: trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -82,21 +82,21 @@ }; for(std::size_t i=0; i<CountOf(dll_names); ++i) { - if(TryLoad(dll_names[i].ogg, dll_names[i].vorbis, dll_names[i].vorbisenc)) + if(TryLoad(mpt::PathString::FromUTF8(dll_names[i].ogg), mpt::PathString::FromUTF8(dll_names[i].vorbis), mpt::PathString::FromUTF8(dll_names[i].vorbisenc))) { // success break; } } } - bool TryLoad(std::string Ogg_fn, std::string Vorbis_fn, std::string VorbisEnc_fn) + bool TryLoad(mpt::PathString Ogg_fn, mpt::PathString Vorbis_fn, mpt::PathString VorbisEnc_fn) { #ifdef MODPLUG_TRACKER - Ogg_fn = std::string(theApp.GetAppDirPath()) + Ogg_fn; - Vorbis_fn = std::string(theApp.GetAppDirPath()) + Vorbis_fn; - VorbisEnc_fn = std::string(theApp.GetAppDirPath()) + VorbisEnc_fn; + Ogg_fn = theApp.GetAppDirPath() + Ogg_fn; + Vorbis_fn = theApp.GetAppDirPath() + Vorbis_fn; + VorbisEnc_fn = theApp.GetAppDirPath() + VorbisEnc_fn; #endif - hOgg = LoadLibrary(Ogg_fn.c_str()); + hOgg = LoadLibraryW(Ogg_fn.AsNative().c_str()); if(!hOgg) { if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } @@ -104,7 +104,7 @@ if(hVorbisEnc) { FreeLibrary(hVorbisEnc); hVorbisEnc = NULL; } return false; } - hVorbis = LoadLibrary(Vorbis_fn.c_str()); + hVorbis = LoadLibraryW(Vorbis_fn.AsNative().c_str()); if(!hVorbis) { if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } @@ -112,7 +112,7 @@ if(hVorbisEnc) { FreeLibrary(hVorbisEnc); hVorbisEnc = NULL; } return false; } - hVorbisEnc = LoadLibrary(VorbisEnc_fn.c_str()); + hVorbisEnc = LoadLibraryW(VorbisEnc_fn.AsNative().c_str()); if(!hVorbisEnc) { if(hOgg) { FreeLibrary(hOgg); hOgg = NULL; } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -246,9 +246,7 @@ path = theApp.RelativePathToAbsolute(path); SetDefaultDirectory(path, static_cast<Directory>(i), false); } - MemsetZero(m_szKbdFile); - mpt::String::Copy(m_szKbdFile, conf.Read<std::string>("Paths", "Key_Config_File", "")); - theApp.RelativePathToAbsolute(m_szKbdFile); + m_szKbdFile = conf.Read<mpt::PathString>("Paths", "Key_Config_File", mpt::PathString()); // init old and messy stuff: @@ -445,6 +443,9 @@ { SetCurrentDirectory(TrackerDirectories::Instance().m_szDefaultDirectory[DIR_MODS]); } + CString tmpKbdFile = m_szKbdFile.ToCString(); + theApp.RelativePathToAbsolute(tmpKbdFile); + m_szKbdFile = mpt::PathString::FromCString(tmpKbdFile); // Last fixup: update config version IniVersion = MptVersion::str; Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-11-08 11:50:55 UTC (rev 3122) @@ -352,7 +352,7 @@ // Paths - TCHAR m_szKbdFile[_MAX_PATH]; + mpt::PathString m_szKbdFile; // Chords MPTChords Chords; Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -541,7 +541,7 @@ mpt::String::CopyN(s, TrackerSettings::Instance().GetDefaultDirectory(DIR_PLUGINS)); if(!s[0]) { - mpt::String::CopyN(s, theApp.GetAppDirPath()); + mpt::String::CopyN(s, theApp.GetAppDirPath().ToLocale().c_str()); } size_t len = strlen(s); if((len > 0) && (s[len - 1] != '\\') && (s[len - 1] != '/')) Modified: trunk/OpenMPT/soundlib/Load_mo3.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/soundlib/Load_mo3.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -52,12 +52,9 @@ // try to load unmo3.dll dynamically. #ifdef MODPLUG_TRACKER - CHAR szPath[MAX_PATH]; - strcpy(szPath, theApp.GetAppDirPath()); - _tcsncat(szPath, MPT_TEXT("unmo3.dll"), MAX_PATH - (_tcslen(szPath) + 1)); - HMODULE unmo3 = LoadLibrary(szPath); + HMODULE unmo3 = LoadLibraryW((theApp.GetAppDirPath() + mpt::PathString::FromUTF8("unmo3.dll")).AsNative().c_str()); #else - HMODULE unmo3 = LoadLibrary(MPT_TEXT("unmo3.dll")); + HMODULE unmo3 = LoadLibraryW(mpt::PathString::FromUTF8("unmo3.dll").AsNative().c_str()); #endif // MODPLUG_TRACKER if(unmo3 == nullptr) // Didn't succeed. { Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -2287,11 +2287,11 @@ } #ifdef MODPLUG_TRACKER - if(!mp3lib) mp3lib = LoadLibrary(CString(theApp.GetAppDirPath()) + "libmpg123-0.dll"); - if(!mp3lib) mp3lib = LoadLibrary(CString(theApp.GetAppDirPath()) + "libmpg123.dll"); + 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()); #else - if(!mp3lib) mp3lib = LoadLibrary(MPT_TEXT("libmpg123-0.dll")); - if(!mp3lib) mp3lib = LoadLibrary(MPT_TEXT("libmpg123.dll")); + 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()); #endif // MODPLUG_TRACKER if(!mp3lib) return false; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -891,7 +891,7 @@ { sUrl.AppendFormat("%08X%s%%0a", LittleEndian(m_MixPlugins[*i].Info.dwPluginId2), m_MixPlugins[*i].GetLibraryName()); } - CTrackApp::OpenURL(sUrl); + CTrackApp::OpenURL(mpt::PathString::FromCString(sUrl)); } } #endif // NO_VST Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2013-11-08 10:25:40 UTC (rev 3121) +++ trunk/OpenMPT/test/test.cpp 2013-11-08 11:50:55 UTC (rev 3122) @@ -1336,7 +1336,7 @@ static bool ShouldRunTests() { - CString theFile = theApp.GetAppDirPath(); + CString theFile = theApp.GetAppDirPath().ToCString(); // Only run the tests when we're in the project directory structure. for(std::size_t i = 0; i < CountOf(debugPaths); ++i) { @@ -1350,7 +1350,7 @@ static std::string GetTestFilenameBase() { - CString theFile = theApp.GetAppDirPath(); + CString theFile = theApp.GetAppDirPath().ToCString(); for(std::size_t i = 0; i < CountOf(debugPaths); ++i) { if(PathEndsIn(theFile, debugPaths[i])) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |