From: <man...@us...> - 2013-06-02 11:31:08
|
Revision: 2280 http://sourceforge.net/p/modplug/code/2280 Author: manxorist Date: 2013-06-02 11:30:59 +0000 (Sun, 02 Jun 2013) Log Message: ----------- [Ref] Split tracker-only-related misc functions from common/misc_util into mptrack/MPTrackUtil. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/mptrack/Mptrack.h trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2013-06-02 11:25:38 UTC (rev 2279) +++ trunk/OpenMPT/common/misc_util.cpp 2013-06-02 11:30:59 UTC (rev 2280) @@ -10,65 +10,3 @@ #include "stdafx.h" #include "misc_util.h" -#include <ctime> - -#ifdef MODPLUG_TRACKER - -/* - * Loads resource. - * [in] lpName and lpType: parameters passed to FindResource(). - * [out] pData: Pointer to loaded resource data, nullptr if load not successful. - * [out] nSize: Size of the data in bytes, zero if load not succesfull. - * [out] hglob: HGLOBAL returned by LoadResource-function. - * Return: pData. - */ -LPCCH LoadResource(LPCTSTR lpName, LPCTSTR lpType, LPCCH& pData, size_t& nSize, HGLOBAL& hglob) -//--------------------------------------------------------------------------------------------- -{ - pData = nullptr; - nSize = 0; - hglob = nullptr; - HINSTANCE hInstance = AfxGetInstanceHandle(); - HRSRC hrsrc = FindResource(hInstance, lpName, lpType); - if (hrsrc != NULL) - { - hglob = LoadResource(hInstance, hrsrc); - if (hglob != NULL) - { - pData = reinterpret_cast<const char*>(LockResource(hglob)); - nSize = SizeofResource(hInstance, hrsrc); - } - } - return pData; -} - - -// Returns WinAPI error message corresponding to error code returned by GetLastError(). -std::string GetErrorMessage(DWORD nErrorCode) -//------------------------------------------- -{ - LPVOID lpMsgBuf; - - FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - nErrorCode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, - 0, - NULL ); - - std::string msg = (LPTSTR)lpMsgBuf; - LocalFree(lpMsgBuf); - - return msg; -} -#endif // MODPLUG_TRACKER - - - -#ifdef MODPLUG_TRACKER -time_t Util::sdTime::MakeGmTime(tm& timeUtc) -{ - return _mkgmtime(&timeUtc); -} -#endif // MODPLUG_TRACKER Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2013-06-02 11:25:38 UTC (rev 2279) +++ trunk/OpenMPT/common/misc_util.h 2013-06-02 11:30:59 UTC (rev 2280) @@ -21,10 +21,6 @@ #include "typedefs.h" -#ifdef MODPLUG_TRACKER -#include <io.h> // for _taccess -#endif - #if defined(HAS_TYPE_TRAITS) #include <type_traits> #endif @@ -178,12 +174,6 @@ #endif -#ifdef MODPLUG_TRACKER -LPCCH LoadResource(LPCTSTR lpName, LPCTSTR lpType, LPCCH& pData, size_t& nSize, HGLOBAL& hglob); -std::string GetErrorMessage(DWORD nErrorCode); -#endif // MODPLUG_TRACKER - - static inline char SanitizeFilenameChar(char c) //--------------------------------------------- { @@ -220,7 +210,7 @@ str[i] = SanitizeFilenameChar(str[i]); } } -#ifdef MODPLUG_TRACKER +#ifdef _MFC_VER static inline void SanitizeFilename(CString &str) //----------------------------------------------- { @@ -371,23 +361,6 @@ }; -#ifdef MODPLUG_TRACKER -namespace Util { namespace sdTime -{ - - time_t MakeGmTime(tm& timeUtc); - -}}; // namespace Util::sdTime - -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}; - inline bool IsPathFileAvailable(LPCTSTR pszFilePath, FileMode fm) {return (_taccess(pszFilePath, fm) == 0);} - -} } // namespace Util::sdOs -#endif // MODPLUG_TRACKER - namespace Util { inline int32 muldiv(int32 a, int32 b, int32 c) Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-06-02 11:25:38 UTC (rev 2279) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-06-02 11:30:59 UTC (rev 2280) @@ -13,6 +13,7 @@ #include "resource.h" // main symbols #include "ACMConvert.h" #include <windows.h> +#include "../mptrack/MpTrackUtil.h" #include "../mptrack/Reporting.h" #include "../soundlib/MIDIMacros.h" #include "../soundlib/modcommand.h" Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-06-02 11:25:38 UTC (rev 2279) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2013-06-02 11:30:59 UTC (rev 2280) @@ -471,6 +471,10 @@ > </File> <File + RelativePath=".\MPTrackUtil.cpp" + > + </File> + <File RelativePath="..\common\mptString.cpp" > </File> @@ -1013,6 +1017,10 @@ > </File> <File + RelativePath=".\MPTrackUtil.h" + > + </File> + <File RelativePath="..\common\mptString.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-06-02 11:25:38 UTC (rev 2279) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-06-02 11:30:59 UTC (rev 2280) @@ -439,6 +439,7 @@ <ClCompile Include="Mpdlgs.cpp" /> <ClCompile Include="MPTHacks.cpp" /> <ClCompile Include="Mptrack.cpp" /> + <ClCompile Include="MPTrackUtil.cpp" /> <ClCompile Include="Mpt_midi.cpp" /> <ClCompile Include="PatternClipboard.cpp" /> <ClCompile Include="PatternEditorDialogs.cpp" /> @@ -613,6 +614,7 @@ <ClInclude Include="ModConvert.h" /> <ClInclude Include="Moddoc.h" /> <ClInclude Include="Mptrack.h" /> + <ClInclude Include="MPTrackUtil.h" /> <ClInclude Include="Notification.h" /> <ClInclude Include="PatternClipboard.h" /> <ClInclude Include="PatternCursor.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-06-02 11:25:38 UTC (rev 2279) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-06-02 11:30:59 UTC (rev 2280) @@ -511,6 +511,9 @@ <ClCompile Include="..\test\test.cpp"> <Filter>test</Filter> </ClCompile> + <ClCompile Include="MPTrackUtil.cpp"> + <Filter>Source Files\mptrack</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\soundlib\Loaders.h"> @@ -918,6 +921,9 @@ <ClInclude Include="..\test\test.h"> <Filter>test</Filter> </ClInclude> + <ClInclude Include="MPTrackUtil.h"> + <Filter>Header Files\mptrack</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |