From 4558c2836c6b63699244b2dccfe89218bb7f4ac8 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Mon, 21 May 2012 14:19:25 +0300 Subject: [PATCH] Changed @\ to #@# --- Library/ConfigParser.cpp | 29 +++++++++++++---------------- Library/ConfigParser.h | 6 +++--- Library/MeterWindow.cpp | 31 +++++-------------------------- Library/Rainmeter.cpp | 8 -------- 4 files changed, 21 insertions(+), 53 deletions(-) diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index c94e9980..596b9234 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -51,7 +51,7 @@ CConfigParser::~CConfigParser() { } -void CConfigParser::Initialize(const std::wstring& filename, CMeterWindow* meterWindow, LPCTSTR config, const std::wstring* includePath) +void CConfigParser::Initialize(const std::wstring& filename, CMeterWindow* meterWindow, LPCTSTR config, const std::wstring* resourcePath) { m_Measures.clear(); m_Sections.clear(); @@ -68,12 +68,12 @@ void CConfigParser::Initialize(const std::wstring& filename, CMeterWindow* meter m_CurrentSection = NULL; // Set the built-in variables. Do this before the ini file is read so that the paths can be used with @include - SetBuiltInVariables(filename, meterWindow); + SetBuiltInVariables(filename, resourcePath, meterWindow); ResetMonitorVariables(meterWindow); CSystem::UpdateIniFileMappingList(); - ReadIniFile(filename, includePath, config); + ReadIniFile(filename, config); ReadVariables(); // Clear and minimize @@ -81,7 +81,7 @@ void CConfigParser::Initialize(const std::wstring& filename, CMeterWindow* meter m_ListVariables.clear(); } -void CConfigParser::SetBuiltInVariables(const std::wstring& filename, CMeterWindow* meterWindow) +void CConfigParser::SetBuiltInVariables(const std::wstring& filename, const std::wstring* resourcePath, CMeterWindow* meterWindow) { SetBuiltInVariable(L"PROGRAMPATH", Rainmeter->GetPath()); SetBuiltInVariable(L"PROGRAMDRIVE", Rainmeter->GetDrive()); @@ -91,6 +91,11 @@ void CConfigParser::SetBuiltInVariables(const std::wstring& filename, CMeterWind SetBuiltInVariable(L"CURRENTPATH", CRainmeter::ExtractPath(filename)); SetBuiltInVariable(L"ADDONSPATH", Rainmeter->GetAddonPath()); + if (resourcePath) + { + SetBuiltInVariable(L"@", *resourcePath); + } + if (meterWindow) { SetBuiltInVariable(L"CURRENTFILE", meterWindow->GetSkinIniFile()); @@ -1148,7 +1153,7 @@ RECT CConfigParser::ParseRECT(LPCTSTR string) ** Reads the given ini file and fills the m_Values and m_Keys maps. ** */ -void CConfigParser::ReadIniFile(const std::wstring& iniFile, const std::wstring* includePath, LPCTSTR config, int depth) +void CConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR config, int depth) { if (depth > 100) // Is 100 enough to assume the include loop never ends? { @@ -1312,18 +1317,10 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, const std::wstring* ReplaceVariables(value); if (!CSystem::IsAbsolutePath(value)) { - if (includePath && - value[0] == L'@' && value[1] == L'\\') // value[1] == L'\0' if value.size() == 1 - { - value.replace(0, 2, *includePath); - } - else - { - // Relative to the ini folder - value.insert(0, CRainmeter::ExtractPath(iniFile)); - } + // Relative to the ini folder + value.insert(0, CRainmeter::ExtractPath(iniFile)); } - ReadIniFile(value, includePath, config, depth + 1); + ReadIniFile(value, config, depth + 1); } } else diff --git a/Library/ConfigParser.h b/Library/ConfigParser.h index 46dbfd5a..1796d328 100644 --- a/Library/ConfigParser.h +++ b/Library/ConfigParser.h @@ -40,7 +40,7 @@ public: CConfigParser(); ~CConfigParser(); - void Initialize(const std::wstring& filename, CMeterWindow* meterWindow = NULL, LPCTSTR config = NULL, const std::wstring* includePath = NULL); + void Initialize(const std::wstring& filename, CMeterWindow* meterWindow = NULL, LPCTSTR config = NULL, const std::wstring* resourcePath = NULL); void AddMeasure(CMeasure* pMeasure); bool GetVariable(const std::wstring& strVariable, std::wstring& strValue); @@ -100,13 +100,13 @@ public: static void UpdateWorkareaVariables() { SetMultiMonitorVariables(false); } private: - void SetBuiltInVariables(const std::wstring& filename, CMeterWindow* meterWindow); + void SetBuiltInVariables(const std::wstring& filename, const std::wstring* resourcePath, CMeterWindow* meterWindow); void ReadVariables(); CMeasure* GetMeasure(const std::wstring& name); - void ReadIniFile(const std::wstring& iniFile, const std::wstring* includePath, LPCTSTR config = NULL, int depth = 0); + void ReadIniFile(const std::wstring& iniFile, LPCTSTR config = NULL, int depth = 0); void SetAutoSelectedMonitorVariables(CMeterWindow* meterWindow); diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 423cba6e..673163f3 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -4677,32 +4677,11 @@ void CMeterWindow::MakePathAbsolute(std::wstring& path) else { std::wstring absolute; - - if (path[0] == L'@' && path[1] == L'\\') // path[1] == L'\0' if path.size() == 1 - { - const std::wstring::size_type resourcesLen = 13; // Count of "\\@Resources\\" - - std::wstring::size_type suiteLen; - if ((suiteLen = m_SkinName.find_first_of(L'\\')) == std::wstring::npos) - { - suiteLen = m_SkinName.size(); - } - - absolute.reserve(Rainmeter->GetSkinPath().size() + suiteLen + resourcesLen + (path.size() - 2)); - absolute = Rainmeter->GetSkinPath(); - absolute.append(m_SkinName, 0, suiteLen); - absolute += L"\\@Resources\\"; - absolute.append(path, 2, path.length() - 1); - } - else - { - absolute.reserve(Rainmeter->GetSkinPath().size() + m_SkinName.size() + 1 + path.size()); - absolute = Rainmeter->GetSkinPath(); - absolute += m_SkinName; - absolute += L'\\'; - absolute += path; - } - + absolute.reserve(Rainmeter->GetSkinPath().size() + m_SkinName.size() + 1 + path.size()); + absolute = Rainmeter->GetSkinPath(); + absolute += m_SkinName; + absolute += L'\\'; + absolute += path; absolute.swap(path); } } diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index e524f201..741b48e9 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -2139,14 +2139,6 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow, { std::wstring tmpSz = command; meterWindow->GetParser().ReplaceMeasures(tmpSz); - - std::wstring::size_type pos = tmpSz.find_first_not_of(L" \t\""); - if (pos != std::wstring::npos && - tmpSz[pos] == L'@' && tmpSz[pos + 1] == L'\\') // tmpSz[pos + 1] == L'\0' if tmpSz.size() == 1 - { - tmpSz.replace(pos, 2, meterWindow->GetSkinResourcesPath()); - } - RunCommand(NULL, tmpSz.c_str(), SW_SHOWNORMAL); } else