From: <man...@us...> - 2015-04-24 16:44:18
|
Revision: 4983 http://sourceforge.net/p/modplug/code/4983 Author: manxorist Date: 2015-04-24 16:44:05 +0000 (Fri, 24 Apr 2015) Log Message: ----------- [Ref] Kill Util::sdOs::IsPathFileAvailable(). Member functions of mpt::PathString can do the job. Modified Paths: -------------- trunk/OpenMPT/mptrack/MPTrackUtil.cpp trunk/OpenMPT/mptrack/MPTrackUtil.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp Modified: trunk/OpenMPT/mptrack/MPTrackUtil.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTrackUtil.cpp 2015-04-24 16:09:00 UTC (rev 4982) +++ trunk/OpenMPT/mptrack/MPTrackUtil.cpp 2015-04-24 16:44:05 UTC (rev 4983) @@ -69,10 +69,4 @@ } -bool Util::sdOs::IsPathFileAvailable(const mpt::PathString &pszFilePath, FileMode fm) -{ - return (_waccess(pszFilePath.AsNative().c_str(), fm) == 0); -} - - OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/MPTrackUtil.h =================================================================== --- trunk/OpenMPT/mptrack/MPTrackUtil.h 2015-04-24 16:09:00 UTC (rev 4982) +++ trunk/OpenMPT/mptrack/MPTrackUtil.h 2015-04-24 16:44:05 UTC (rev 4983) @@ -21,14 +21,6 @@ std::string GetErrorMessage(DWORD nErrorCode); -namespace Util { namespace sdOs -{ - /// Checks whether file or folder exists and whether it has the given mode. - enum FileMode {FileModeExists = 0, FileModeRead = 4, FileModeWrite = 2, FileModeReadWrite = 6}; - bool IsPathFileAvailable(const mpt::PathString &pszFilePath, FileMode fm); - -}} // namespace Util::sdOs - namespace Util { // Get horizontal DPI resolution Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-04-24 16:09:00 UTC (rev 4982) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-04-24 16:44:05 UTC (rev 4983) @@ -2245,13 +2245,14 @@ if (nIndex < vecFilePaths.size()) { const mpt::PathString& sPath = vecFilePaths[nIndex]; - const bool bAvailable = Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeRead); - if (bAvailable) + const bool bExists = sPath.IsFile(); + CDocument *pDoc = nullptr; + if(bExists) { - theApp.GetModDocTemplate()->OpenTemplateFile(sPath, !bTemplateFile); - } else + pDoc = theApp.GetModDocTemplate()->OpenTemplateFile(sPath, !bTemplateFile); + } + if(!pDoc) { - const bool bExists = Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeExists); Reporting::Notification(L"The file '" + sPath.ToWide() + L"' " + (bExists ? L"exists but can't be read" : L"does not exist")); } } @@ -2694,7 +2695,7 @@ mpt::PathString basePath; basePath = (i == 0) ? theApp.GetAppDirPath() : theApp.GetConfigPath(); basePath += pszFolderName; - if (Util::sdOs::IsPathFileAvailable(basePath, Util::sdOs::FileModeExists) == false) + if(!basePath.IsDirectory()) continue; mpt::PathString sPath = basePath + MPT_PATHSTRING("*"); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2015-04-24 16:09:00 UTC (rev 4982) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2015-04-24 16:44:05 UTC (rev 4983) @@ -2909,7 +2909,7 @@ { sName += MPT_PATHSTRING("newTemplate") + mpt::PathString::FromWide(mpt::ToWString(i)); sName += MPT_PATHSTRING(".") + mpt::PathString::FromUTF8(m_SndFile.GetModSpecifications().fileExtension); - if (!Util::sdOs::IsPathFileAvailable(templateFolder + sName, Util::sdOs::FileModeExists)) + if (!(templateFolder + sName).FileOrDirectoryExists()) break; } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-04-24 16:09:00 UTC (rev 4982) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-04-24 16:44:05 UTC (rev 4983) @@ -1137,7 +1137,7 @@ const mpt::PathString dirs[] = { GetConfigPath() + MPT_PATHSTRING("TemplateModules\\"), GetAppDirPath() + MPT_PATHSTRING("TemplateModules\\"), mpt::PathString() }; for(size_t i = 0; i < CountOf(dirs); i++) { - if(Util::sdOs::IsPathFileAvailable(dirs[i] + templateFile, Util::sdOs::FileModeExists)) + if((dirs[i] + templateFile).IsFile()) { if(m_pModTemplate->OpenTemplateFile(dirs[i] + templateFile) != nullptr) { Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2015-04-24 16:09:00 UTC (rev 4982) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2015-04-24 16:44:05 UTC (rev 4983) @@ -62,8 +62,8 @@ m_pModDoc = pModDoc; m_nPlugSlot = nPlugSlot; - hasBridge32 = Util::sdOs::IsPathFileAvailable(theApp.GetAppDirPath() + MPT_PATHSTRING("PluginBridge32.exe"), Util::sdOs::FileModeExists); - hasBridge64 = Util::sdOs::IsPathFileAvailable(theApp.GetAppDirPath() + MPT_PATHSTRING("PluginBridge64.exe"), Util::sdOs::FileModeExists); + hasBridge32 = (theApp.GetAppDirPath() + MPT_PATHSTRING("PluginBridge32.exe")).IsFile(); + hasBridge64 = (theApp.GetAppDirPath() + MPT_PATHSTRING("PluginBridge64.exe")).IsFile(); if(m_pModDoc) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |