From: <sag...@us...> - 2015-01-10 18:53:15
|
Revision: 4711 http://sourceforge.net/p/modplug/code/4711 Author: saga-games Date: 2015-01-10 18:53:02 +0000 (Sat, 10 Jan 2015) Log Message: ----------- [Ref] Do a bit of general refactoring in the autosaver code and remove the hint about ITP instruments in the error message. Modified Paths: -------------- trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/AutoSaver.h Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2015-01-10 17:06:12 UTC (rev 4710) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2015-01-10 18:53:02 UTC (rev 4711) @@ -29,8 +29,8 @@ // Construction/Destruction /////////////////////////// -CAutoSaver::CAutoSaver(bool enabled, int saveInterval, int backupHistory, bool useOriginalPath, mpt::PathString path) -//------------------------------------------------------------------------------------------------------------------- +CAutoSaver::CAutoSaver(bool enabled, uint32_t saveInterval, uint32_t backupHistory, bool useOriginalPath, mpt::PathString path) +//----------------------------------------------------------------------------------------------------------------------------- : m_bSaveInProgress(false) , m_nLastSave(timeGetTime()) , m_bEnabled(enabled) @@ -71,7 +71,7 @@ } else { m_bEnabled = false; - Reporting::Warning("Warning: Autosave failed and has been disabled. Please:\n- Review your autosave paths\n- Check available diskspace & filesystem access rights\n- If you are using the ITP format, ensure all instruments exist as independant .iti files"); + Reporting::Warning("Warning: Auto Save failed and has been disabled. Please:\n- Review your Auto Save paths\n- Check available disk space and filesystem access rights"); success = false; } } @@ -91,10 +91,10 @@ /////////////////////////// -bool CAutoSaver::CheckTimer(DWORD curTime) +bool CAutoSaver::CheckTimer(DWORD curTime) //---------------------------------------- { - DWORD curInterval = curTime-m_nLastSave; + DWORD curInterval = curTime - m_nLastSave; return (curInterval >= m_nSaveInterval); } @@ -102,7 +102,6 @@ mpt::PathString CAutoSaver::BuildFileName(CModDoc &modDoc) //-------------------------------------------------------- { - std::wstring timeStamp = mpt::ToWide((CTime::GetCurrentTime()).Format("%Y%m%d.%H%M%S")); mpt::PathString name; if(m_bUseOriginalPath) @@ -125,9 +124,8 @@ name = m_csPath + mpt::PathString::FromCStringSilent(modDoc.GetTitle()).SanitizeComponent(); } - name += MPT_PATHSTRING(".AutoSave."); //append backup tag - name += mpt::PathString::FromWide(timeStamp); //append timestamp - name += MPT_PATHSTRING("."); //append extension + const CString timeStamp = (CTime::GetCurrentTime()).Format(_T(".AutoSave.%Y%m%d.%H%M%S.")); + name += mpt::PathString::FromCString(timeStamp); //append backtup tag + timestamp name += mpt::PathString::FromUTF8(modDoc.GetrSoundFile().GetModSpecifications().fileExtension); return name; @@ -147,7 +145,7 @@ ScopedLogCapturer logcapturer(modDoc, "", nullptr, false); bool success = false; - switch(modDoc.GetModType()) + switch(modDoc.GetrSoundFile().GetBestSaveFormat()) { case MOD_TYPE_MOD: success = sndFile.SaveMod(fileName); @@ -175,8 +173,8 @@ } -void CAutoSaver::CleanUpBackups(CModDoc &modDoc) -//---------------------------------------------- +void CAutoSaver::CleanUpBackups(const CModDoc &modDoc) +//---------------------------------------------------- { mpt::PathString path; @@ -216,7 +214,7 @@ } std::sort(foundfiles.begin(), foundfiles.end()); - while(foundfiles.size() > m_nBackupHistory) + while(foundfiles.size() > (size_t)m_nBackupHistory) { DeleteFileW(foundfiles[0].AsNative().c_str()); foundfiles.erase(foundfiles.begin()); Modified: trunk/OpenMPT/mptrack/AutoSaver.h =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.h 2015-01-10 17:06:12 UTC (rev 4710) +++ trunk/OpenMPT/mptrack/AutoSaver.h 2015-01-10 18:53:02 UTC (rev 4711) @@ -20,8 +20,8 @@ { public: //Cons/Destr - CAutoSaver(bool enabled=true, int saveInterval=10, int backupHistory=3, - bool useOriginalPath=true, mpt::PathString path=mpt::PathString()); + CAutoSaver(bool enabled = true, uint32_t saveInterval = 10, uint32_t backupHistory = 3, + bool useOriginalPath = true, mpt::PathString path = mpt::PathString()); //Work bool DoSave(DWORD curTime); @@ -33,19 +33,19 @@ bool GetUseOriginalPath() const { return m_bUseOriginalPath; } void SetPath(const mpt::PathString &path) { m_csPath = path; } mpt::PathString GetPath() const { return m_csPath; } - void SetHistoryDepth(int history) { m_nBackupHistory = Clamp(history, 1, 1000); } - int GetHistoryDepth() const { return m_nBackupHistory; } - void SetSaveInterval(int minutes) + void SetHistoryDepth(uint32_t history) { m_nBackupHistory = Clamp(history, 1u, 1000u); } + uint32_t GetHistoryDepth() const { return m_nBackupHistory; } + void SetSaveInterval(uint32_t minutes) { - m_nSaveInterval = Clamp(minutes, 1, 10000) * 60 * 1000; //minutes to milliseconds + m_nSaveInterval = Clamp(minutes, 1u, 10000u) * 60u * 1000u; //minutes to milliseconds } - int GetSaveInterval() const { return m_nSaveInterval / 60 / 1000; } + uint32_t GetSaveInterval() const { return m_nSaveInterval / 60u / 1000u; } //internal implementation private: bool SaveSingleFile(CModDoc &modDoc); mpt::PathString BuildFileName(CModDoc &modDoc); - void CleanUpBackups(CModDoc &modDoc); + void CleanUpBackups(const CModDoc &modDoc); bool CheckTimer(DWORD curTime); //internal implementation members @@ -56,8 +56,8 @@ bool m_bEnabled; DWORD m_nLastSave; - DWORD m_nSaveInterval; - size_t m_nBackupHistory; + uint32_t m_nSaveInterval; + uint32_t m_nBackupHistory; bool m_bUseOriginalPath; mpt::PathString m_csPath; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |