Statistics now saved in Rainmeter.stats file in same folder as Rainmeter.ini

This commit is contained in:
Birunthan Mohanathas 2011-04-16 20:05:14 +00:00
parent 355a5fc7b1
commit f66791253a
2 changed files with 29 additions and 16 deletions

View File

@ -1790,15 +1790,18 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
}
// Set the log file location
m_LogFile = m_IniFile;
m_LogFile = m_StatsFile = m_IniFile;
size_t logFileLen = m_LogFile.length();
if (logFileLen > 4 && _wcsicmp(m_LogFile.substr(logFileLen - 4).c_str(), L".ini") == 0)
{
m_LogFile.replace(logFileLen - 4, 4, L".log");
m_StatsFile.replace(logFileLen - 4, 4, L".sta");
m_StatsFile += L"ts";
}
else
{
m_LogFile += L".log"; // Append the extension so that we don't accidentally overwrite the ini file
m_StatsFile += L".stats";
}
// Read Logging settings beforehand
@ -2245,8 +2248,7 @@ int CRainmeter::CompareVersions(const std::wstring& strA, const std::wstring& st
/*
** CreateDefaultConfigFile
**
** Creates the default Rainmeter.ini file.
** illustro\System is enabled.
** Creates the default Rainmeter.ini file with illustro\System enabled.
**
*/
void CRainmeter::CreateDefaultConfigFile(const std::wstring& strFile)
@ -3687,17 +3689,31 @@ void CRainmeter::UpdateDesktopWorkArea(bool reset)
*/
void CRainmeter::ReadStats()
{
// If m_StatsFile doesn't exist, create it and copy the stats section from m_IniFile
if (_waccess(m_StatsFile.c_str(), 0) == -1)
{
WCHAR* tmpSz = new WCHAR[SHRT_MAX]; // Max size returned by GetPrivateProfileSection()
if (GetPrivateProfileSection(L"Statistics", tmpSz, SHRT_MAX, m_IniFile.c_str()) > 0)
{
WritePrivateProfileSection(L"Statistics", tmpSz, m_StatsFile.c_str());
WritePrivateProfileString(L"Statistics", NULL, NULL, m_IniFile.c_str());
}
delete [] tmpSz;
}
WCHAR* tmpSz = new WCHAR[MAX_LINE_LENGTH];
if (GetPrivateProfileString(L"Statistics", L"Since", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
if (GetPrivateProfileString(L"Statistics", L"Since", L"", tmpSz, MAX_LINE_LENGTH, m_StatsFile.c_str()) > 0)
{
m_StatsDate = tmpSz;
m_StatsDate = tmpSz;
}
delete [] tmpSz;
// Only Net measure has stats at the moment
CMeasureNet::ReadStats(m_IniFile);
CMeasureNet::ReadStats(m_StatsFile);
}
/*
@ -3715,12 +3731,12 @@ void CRainmeter::WriteStats(bool bForce)
lastWrite = GetTickCount();
// Write the date for statistics
WritePrivateProfileString(L"Statistics", L"Since", m_StatsDate.c_str(), m_IniFile.c_str());
WritePrivateProfileString(L"Statistics", L"Since", m_StatsDate.c_str(), m_StatsFile.c_str());
// Only Net measure has stats at the moment
CMeasureNet::WriteStats(m_IniFile);
CMeasureNet::WriteStats(m_StatsFile);
WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str());
WritePrivateProfileString(NULL, NULL, NULL, m_StatsFile.c_str());
}
}

View File

@ -170,10 +170,6 @@ public:
CTrayWindow* GetTrayWindow() { return m_TrayWindow; }
CMeterWindow* GetMeterWindow(const std::wstring& config);
// Added by Peter Souza IV / psouza4 / 2010.12.13
//
// Read comments in Rainmeter.cpp for details.
CMeterWindow* GetMeterWindowByINI(const std::wstring& ini_searching);
CMeterWindow* GetMeterWindow(HWND hwnd);
@ -284,14 +280,15 @@ private:
CTrayWindow* m_TrayWindow;
std::vector<CONFIG> m_ConfigStrings; // All configs found in the given folder
std::vector<CONFIG> m_ConfigStrings; // All configs found in the given folder
std::vector<CONFIGMENU> m_ConfigMenu;
std::multimap<int, int> m_ConfigOrders;
std::map<std::wstring, CMeterWindow*> m_Meters; // The meter windows
std::map<std::wstring, CMeterWindow*> m_Meters; // The meter windows
std::vector<std::wstring> m_Themes;
std::wstring m_Path; // Path to the main folder
std::wstring m_Path; // Path to the main folder
std::wstring m_IniFile; // The main ini file
std::wstring m_StatsFile; // The statistics ini file
std::wstring m_LogFile; // The log file
std::wstring m_SkinPath; // Path to the folder where the skins are
std::wstring m_PluginPath; // Path to the folder where the plugins are