mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Changed backups to use new .rmskin format
This commit is contained in:
parent
a9b7347a7e
commit
5e3d266c25
@ -19,6 +19,7 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Application.h"
|
||||
#include "DialogBackup.h"
|
||||
#include "DialogInstall.h"
|
||||
#include "resource.h"
|
||||
#include "../Version.h"
|
||||
|
||||
@ -191,9 +192,8 @@ bool CDialogBackup::CreateBackup()
|
||||
{
|
||||
m_WriteBuffer = new char[c_WriteBufferSize];
|
||||
|
||||
std::wstring addonsPath = g_Data.programPath + L"Addons";
|
||||
std::wstring fontsPath = g_Data.programPath + L"Fonts";
|
||||
std::wstring pluginsPath = g_Data.programPath + L"Plugins";
|
||||
std::wstring addonsPath = g_Data.settingsPath + L"Addons";
|
||||
std::wstring pluginsPath = g_Data.settingsPath + L"Plugins";
|
||||
std::wstring themesPath = g_Data.settingsPath + L"Themes";
|
||||
std::wstring skinsPath = g_Data.skinsPath;
|
||||
|
||||
@ -207,9 +207,26 @@ bool CDialogBackup::CreateBackup()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and add the options file
|
||||
{
|
||||
WCHAR tempFile[MAX_PATH];
|
||||
GetTempPath(MAX_PATH, tempFile);
|
||||
GetTempFileName(tempFile, L"ini", 0, tempFile);
|
||||
|
||||
WCHAR userName[UNLEN + 1];
|
||||
DWORD userNameSize = UNLEN + 1;
|
||||
GetUserName(userName, &userNameSize);
|
||||
|
||||
WritePrivateProfileString(L"rmskin", L"Name", L"Backup", tempFile);
|
||||
WritePrivateProfileString(L"rmskin", L"Author", userName, tempFile);
|
||||
WritePrivateProfileString(L"rmskin", L"Version", m_BackupTime.c_str(), tempFile);
|
||||
WritePrivateProfileString(L"rmskin", L"MinimumRainmeter", L"2.3", tempFile);
|
||||
AddFileToBackup(ConvertToAscii(tempFile).c_str(), "RMSKIN.ini");
|
||||
DeleteFile(tempFile);
|
||||
}
|
||||
|
||||
if ((_waccess(addonsPath.c_str(), 0) == 0 && !AddFolderToBackup(addonsPath, L"", "Addons", true)) ||
|
||||
(_waccess(fontsPath.c_str(), 0) == 0 && !AddFolderToBackup(themesPath, L"", "Fonts", true)) ||
|
||||
(_waccess(skinsPath.c_str(), 0) == 0 && !AddFolderToBackup(skinsPath, L"", "Skins", true)) ||
|
||||
//(_waccess(skinsPath.c_str(), 0) == 0 && !AddFolderToBackup(skinsPath, L"", "Skins", true)) ||
|
||||
(_waccess(themesPath.c_str(), 0) == 0 && !AddFolderToBackup(themesPath, L"", "Themes", true)) ||
|
||||
#ifdef _WIN64
|
||||
(_waccess(pluginsPath.c_str(), 0) == 0 && !AddFolderToBackup(pluginsPath, L"", "Plugins\\64bit", false)))
|
||||
@ -221,30 +238,22 @@ bool CDialogBackup::CreateBackup()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and add the config file
|
||||
WCHAR tempFile[MAX_PATH];
|
||||
GetTempPath(MAX_PATH, tempFile);
|
||||
GetTempFileName(tempFile, L"ini", 0, tempFile);
|
||||
|
||||
std::wstring tmpSz = m_TargetFile;
|
||||
std::wstring::size_type pos = m_TargetFile.find_last_of(L'\\');
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
tmpSz.erase(0, ++pos);
|
||||
}
|
||||
|
||||
WritePrivateProfileString(L"Rainstaller", L"Name", tmpSz.c_str(), tempFile);
|
||||
WritePrivateProfileString(L"Rainstaller", L"RainmeterFonts", L"1", tempFile);
|
||||
WritePrivateProfileString(L"Rainstaller", L"MinRainmeterVer", L"2.2", tempFile);
|
||||
AddFileToBackup(ConvertToAscii(tempFile).c_str(), "Rainstaller.cfg");
|
||||
DeleteFile(tempFile);
|
||||
|
||||
if (zipClose(m_ZipFile, NULL) != ZIP_OK)
|
||||
{
|
||||
MessageBox(NULL, L"Unable to access backup .rmskin file.", NULL, MB_OK | MB_TOPMOST);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add footer
|
||||
FILE* file = _wfopen(m_TargetFile.c_str(), L"r+b");
|
||||
if (file)
|
||||
{
|
||||
fseek(file, 0, SEEK_END);
|
||||
CDialogInstall::PackageFooter footer = { _ftelli64(file), CDialogInstall::PackageFlag::Backup, "RMSKIN" };
|
||||
fwrite(&footer, sizeof(footer), 1, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
delete m_WriteBuffer;
|
||||
return true;
|
||||
}
|
||||
@ -431,10 +440,16 @@ void CDialogBackup::CTabBackup::Initialize()
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
c_Dialog->m_TargetFile = buffer;
|
||||
|
||||
SYSTEMTIME lt;
|
||||
GetLocalTime(<);
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"\\Backup-%02d.%02d.%02d-%02d.%02d.rmskin", lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute);
|
||||
c_Dialog->m_TargetFile += buffer;
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"%02d.%02d.%02d-%02d.%02d", lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute);
|
||||
|
||||
c_Dialog->m_BackupTime = buffer;
|
||||
|
||||
c_Dialog->m_TargetFile += L"\\Backup-";
|
||||
c_Dialog->m_TargetFile += c_Dialog->m_BackupTime;
|
||||
c_Dialog->m_TargetFile += L".rmskin";
|
||||
|
||||
HWND item = GetDlgItem(m_Window, IDC_BACKUP_FILE_TEXT);
|
||||
SetWindowText(item, c_Dialog->m_TargetFile.c_str());
|
||||
|
@ -62,6 +62,7 @@ private:
|
||||
CTabBackup m_TabBackup;
|
||||
|
||||
std::wstring m_TargetFile;
|
||||
std::wstring m_BackupTime;
|
||||
|
||||
HANDLE m_ThreadHandle;
|
||||
|
||||
|
@ -264,7 +264,7 @@ bool CDialogInstall::ReadPackage()
|
||||
__int64 fileSize = 0;
|
||||
if (file)
|
||||
{
|
||||
fseek(file, sizeof(footer), SEEK_END);
|
||||
fseek(file, -(long)sizeof(footer), SEEK_END);
|
||||
fileSize = _ftelli64(file);
|
||||
fread(&footer, sizeof(footer), 1, file);
|
||||
fclose(file);
|
||||
@ -331,15 +331,15 @@ bool CDialogInstall::ReadPackage()
|
||||
if (!path)
|
||||
{
|
||||
path = buffer;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_PackageFormat == PackageFormat::New)
|
||||
{
|
||||
// New package files must be in root of archive
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
++path; // Skip slash
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,8 @@ protected:
|
||||
virtual CTab& GetActiveTab();
|
||||
|
||||
private:
|
||||
friend class CDialogBackup;
|
||||
|
||||
class CTabInstall : public CTab
|
||||
{
|
||||
public:
|
||||
|
@ -64,12 +64,12 @@ IDD_BACKUP_TABDIALOG DIALOGEX 15, 30, 250, 58
|
||||
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
|
||||
FONT 8, "MS Shell Dlg 2"
|
||||
{
|
||||
LTEXT "A backup allows you to save a complete copy of your setup, including skins and statistics.\n\nThe backup will be created at:", IDC_BACKUP_DESCRIPTION_TEXT, 0, 0, 245, 39
|
||||
LTEXT "A backup allows you to save a complete copy of your current Rainmeter skins and themes.\n\nThe backup will be created at:", IDC_BACKUP_DESCRIPTION_TEXT, 0, 0, 245, 39
|
||||
EDITTEXT IDC_BACKUP_FILE_TEXT, 0, 42, 220, 14, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL | ES_READONLY
|
||||
PUSHBUTTON "...", IDC_BACKUP_BROWSE_BUTTON, 225, 42, 25, 14, WS_TABSTOP
|
||||
|
||||
LTEXT "Backup in progress...", IDC_BACKUP_INPROGRESS_TEXT, 0, 0, 245, 9, NOT WS_VISIBLE
|
||||
CONTROL "", IDC_BACKUP_PROGRESS, "msctls_progress32", PBS_MARQUEE | NOT WS_VISIBLE | WS_BORDER, 0, 42, 250, 11
|
||||
LTEXT "Backup in progress...", IDC_BACKUP_INPROGRESS_TEXT, 0, 0, 245, 39, NOT WS_VISIBLE
|
||||
CONTROL "", IDC_BACKUP_PROGRESS, "msctls_progress32", PBS_MARQUEE | NOT WS_VISIBLE | WS_BORDER, 0, 15, 250, 11
|
||||
}
|
||||
|
||||
IDD_INSTALL_DIALOG DIALOGEX 0, 0, 266, 270
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <Windows.h>
|
||||
#include <Windowsx.h>
|
||||
#include <Commdlg.h>
|
||||
#include <Lmcons.h>
|
||||
#include <Shlobj.h>
|
||||
#include <Shlwapi.h>
|
||||
#include <Shellapi.h>
|
||||
|
Loading…
Reference in New Issue
Block a user