Renamed Backup folder in skins and themes to @Backup

This commit is contained in:
Birunthan Mohanathas 2012-06-15 11:58:07 +03:00
parent 59bf41141c
commit 07f49f79a4
2 changed files with 33 additions and 8 deletions

View File

@ -1174,6 +1174,8 @@ void CRainmeter::CreateDataFile()
void CRainmeter::CreateComponentFolders(bool defaultIniLocation) void CRainmeter::CreateComponentFolders(bool defaultIniLocation)
{ {
std::wstring path;
if (CreateDirectory(m_SkinPath.c_str(), NULL)) if (CreateDirectory(m_SkinPath.c_str(), NULL))
{ {
// Folder just created, so copy default skins there // Folder just created, so copy default skins there
@ -1181,8 +1183,18 @@ void CRainmeter::CreateComponentFolders(bool defaultIniLocation)
from += L"*.*"; from += L"*.*";
CSystem::CopyFiles(from, m_SkinPath); CSystem::CopyFiles(from, m_SkinPath);
} }
else
{
path = m_SkinPath;
path += L"Backup";
if (_waccess(path.c_str(), 0) != -1)
{
std::wstring newPath = m_SkinPath + L"@Backup";
MoveFile(path.c_str(), newPath.c_str());
}
}
std::wstring path = GetThemePath(); path = GetThemePath();
if (_waccess(path.c_str(), 0) == -1) if (_waccess(path.c_str(), 0) == -1)
{ {
std::wstring from = GetDefaultThemePath(); std::wstring from = GetDefaultThemePath();
@ -1191,6 +1203,16 @@ void CRainmeter::CreateComponentFolders(bool defaultIniLocation)
CSystem::CopyFiles(from, m_SettingsPath); CSystem::CopyFiles(from, m_SettingsPath);
} }
} }
else
{
path += L"Backup";
if (_waccess(path.c_str(), 0) != -1)
{
std::wstring newPath = GetThemePath();
newPath += L"@Backup";
MoveFile(path.c_str(), newPath.c_str());
}
}
if (defaultIniLocation) if (defaultIniLocation)
{ {
@ -1695,6 +1717,7 @@ int CRainmeter::ScanForSkinsRecursive(const std::wstring& path, std::wstring bas
{ {
if (wcscmp(L".", fileData.cFileName) != 0 && if (wcscmp(L".", fileData.cFileName) != 0 &&
wcscmp(L"..", fileData.cFileName) != 0 && wcscmp(L"..", fileData.cFileName) != 0 &&
!(level == 0 && wcscmp(L"@Backup", fileData.cFileName) == 0) &&
!(level == 0 && wcscmp(L"Backup", fileData.cFileName) == 0) && !(level == 0 && wcscmp(L"Backup", fileData.cFileName) == 0) &&
!(level == 1 && wcscmp(L"@Resources", fileData.cFileName) == 0)) !(level == 1 && wcscmp(L"@Resources", fileData.cFileName) == 0))
{ {
@ -2476,11 +2499,11 @@ void CRainmeter::LoadTheme(const std::wstring& name)
DeleteMeterWindow(NULL); DeleteMeterWindow(NULL);
std::wstring backup = GetThemePath(); std::wstring backup = GetThemePath();
backup += L"Backup"; backup += L"@Backup";
CreateDirectory(backup.c_str(), NULL); CreateDirectory(backup.c_str(), NULL);
backup += L"\\Rainmeter.thm"; backup += L"\\Rainmeter.thm";
if (_wcsicmp(name.c_str(), L"Backup") == 0) if (_wcsicmp(name.c_str(), L"@Backup") == 0)
{ {
// Just load the backup // Just load the backup
CSystem::CopyFiles(backup, m_IniFile); CSystem::CopyFiles(backup, m_IniFile);

View File

@ -669,7 +669,7 @@ bool CDialogInstall::InstallPackage()
} }
else else
{ {
std::wstring to = g_Data.skinsPath + L"Backup\\"; std::wstring to = g_Data.skinsPath + L"@Backup\\";
CreateDirectory(to.c_str(), NULL); CreateDirectory(to.c_str(), NULL);
// Delete current backup // Delete current backup
@ -988,7 +988,7 @@ void CDialogInstall::KeepVariables()
for (int i = 0, isize = m_VariablesFiles.size(); i < isize; ++i) for (int i = 0, isize = m_VariablesFiles.size(); i < isize; ++i)
{ {
std::wstring fromPath = g_Data.skinsPath + L"Backup\\"; std::wstring fromPath = g_Data.skinsPath + L"@Backup\\";
fromPath += m_VariablesFiles[i]; fromPath += m_VariablesFiles[i];
std::wstring toPath = g_Data.skinsPath + m_VariablesFiles[i]; std::wstring toPath = g_Data.skinsPath + m_VariablesFiles[i];
@ -1026,7 +1026,7 @@ void CDialogInstall::LoadTheme(const std::wstring& name, bool setWallpaper)
{ {
// Take a copy of current Rainmeter.ini before doing anything // Take a copy of current Rainmeter.ini before doing anything
std::wstring backupFile = g_Data.settingsPath; std::wstring backupFile = g_Data.settingsPath;
backupFile += L"Themes\\Backup\\"; backupFile += L"Themes\\@Backup\\";
CreateDirectory(backupFile.c_str(), NULL); CreateDirectory(backupFile.c_str(), NULL);
backupFile += L"Rainmeter.thm"; backupFile += L"Rainmeter.thm";
CopyFiles(g_Data.iniFile, backupFile, false); CopyFiles(g_Data.iniFile, backupFile, false);
@ -1128,12 +1128,14 @@ void CDialogInstall::LaunchRainmeter()
bool CDialogInstall::IsIgnoredSkin(const WCHAR* name) bool CDialogInstall::IsIgnoredSkin(const WCHAR* name)
{ {
return _wcsicmp(name, L"Backup") == 0; return _wcsicmp(name, L"Backup") == 0 ||
_wcsicmp(name, L"@Backup") == 0;
} }
bool CDialogInstall::IsIgnoredTheme(const WCHAR* name) bool CDialogInstall::IsIgnoredTheme(const WCHAR* name)
{ {
return _wcsicmp(name, L"Backup") == 0; return _wcsicmp(name, L"Backup") == 0 ||
_wcsicmp(name, L"@Backup") == 0;
} }
bool CDialogInstall::IsIgnoredAddon(const WCHAR* name) bool CDialogInstall::IsIgnoredAddon(const WCHAR* name)