From ba0b1e9129ce2a1a1f04e11582dc6dd04216345d Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sun, 7 Oct 2012 17:01:06 +0300 Subject: [PATCH] SkinInstaller: Added support for 3cae4f7 --- Library/Rainmeter.cpp | 2 -- SkinInstaller/Application.cpp | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index a92b9e3f..626f8ef9 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1248,8 +1248,6 @@ void CRainmeter::CreateComponentFolders(bool defaultIniLocation) path = GetLayoutPath(); if (_waccess(path.c_str(), 0) == -1) { - // TODO: If Skin Installer creates Layouts first, old Themes is not migrated. - std::wstring themesPath = m_SettingsPath + L"Themes"; if (_waccess(themesPath.c_str(), 0) != -1) { diff --git a/SkinInstaller/Application.cpp b/SkinInstaller/Application.cpp index d56eb93a..b0e5751e 100644 --- a/SkinInstaller/Application.cpp +++ b/SkinInstaller/Application.cpp @@ -118,6 +118,56 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi } } + std::wstring layoutsPath = g_Data.settingsPath + L"Layouts\\"; + if (_waccess(layoutsPath.c_str(), 0) == -1) + { + // Migrate Themes into Layouts for backwards compatibility and rename + // Rainmeter.thm to Rainmeter.ini and RainThemes.bmp to Wallpaper.bmp. + std::wstring themesPath = g_Data.settingsPath + L"Themes"; + if (_waccess(themesPath.c_str(), 0) != -1) + { + // Migrate Themes into Layouts for backwards compatibility and rename + // Rainmeter.thm to Rainmeter.ini and RainThemes.bmp to Wallpaper.bmp. + MoveFile(themesPath.c_str(), layoutsPath.c_str()); + + layoutsPath += L'*'; // For FindFirstFile. + WIN32_FIND_DATA fd; + HANDLE hFind = FindFirstFile(layoutsPath.c_str(), &fd); + layoutsPath.pop_back(); // Remove '*'. + + if (hFind != INVALID_HANDLE_VALUE) + { + do + { + if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && + wcscmp(L".", fd.cFileName) != 0 && + wcscmp(L"..", fd.cFileName) != 0) + { + std::wstring layoutFolder = layoutsPath + fd.cFileName; + layoutFolder += L'\\'; + + std::wstring file = layoutFolder + L"Rainmeter.thm"; + if (_waccess(file.c_str(), 0) != -1) + { + std::wstring newFile = layoutFolder + L"Rainmeter.ini"; + MoveFile(file.c_str(), newFile.c_str()); + } + + file = layoutFolder + L"RainThemes.bmp"; + if (_waccess(file.c_str(), 0) != -1) + { + std::wstring newFile = layoutFolder + L"Wallpaper.bmp"; + MoveFile(file.c_str(), newFile.c_str()); + } + } + } + while (FindNextFile(hFind, &fd)); + + FindClose(hFind); + } + } + } + if (_wcsnicmp(lpCmdLine, L"/LoadTheme ", 11) == 0) { // For backwards compatibility.