added backup of ConEmu.xml to ./config/user-ConEmu.xml at cmder launch if it exists

This commit is contained in:
Dax Games 2016-10-02 22:23:12 -05:00
parent abd7db99b6
commit 5feccb3c7c

View File

@ -103,6 +103,7 @@ void StartCmder(std::wstring path, bool is_single_mode)
wchar_t exeDir[MAX_PATH] = { 0 }; wchar_t exeDir[MAX_PATH] = { 0 };
wchar_t icoPath[MAX_PATH] = { 0 }; wchar_t icoPath[MAX_PATH] = { 0 };
wchar_t cfgPath[MAX_PATH] = { 0 }; wchar_t cfgPath[MAX_PATH] = { 0 };
wchar_t backupCfgPath[MAX_PATH] = { 0 };
wchar_t cpuCfgPath[MAX_PATH] = { 0 }; wchar_t cpuCfgPath[MAX_PATH] = { 0 };
wchar_t userCfgPath[MAX_PATH] = { 0 }; wchar_t userCfgPath[MAX_PATH] = { 0 };
wchar_t oldCfgPath[MAX_PATH] = { 0 }; wchar_t oldCfgPath[MAX_PATH] = { 0 };
@ -127,12 +128,15 @@ void StartCmder(std::wstring path, bool is_single_mode)
if (PathFileExists(cpuCfgPath)) { if (PathFileExists(cpuCfgPath)) {
wcsncpy_s(oldCfgPath, cpuCfgPath, sizeof(cpuCfgPath)); wcsncpy_s(oldCfgPath, cpuCfgPath, sizeof(cpuCfgPath));
wcsncpy_s(backupCfgPath, cpuCfgPath, sizeof(cpuCfgPath));
} }
else if (PathFileExists(userCfgPath)) { else if (PathFileExists(userCfgPath)) {
wcsncpy_s(oldCfgPath, userCfgPath,sizeof(userCfgPath)); wcsncpy_s(oldCfgPath, userCfgPath,sizeof(userCfgPath));
wcsncpy_s(backupCfgPath, userCfgPath, sizeof(userCfgPath));
} }
else { else {
PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml"); PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml");
wcsncpy_s(backupCfgPath, userCfgPath, sizeof(userCfgPath));
} }
// Set path to vendored ConEmu config file // Set path to vendored ConEmu config file
@ -158,8 +162,7 @@ void StartCmder(std::wstring path, bool is_single_mode)
exit(1); exit(1);
} }
} }
else { else if (!CopyFile(cfgPath, backupCfgPath, FALSE))
if (!CopyFile(cfgPath, oldCfgPath, FALSE))
{ {
MessageBox(NULL, MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED) (GetLastError() == ERROR_ACCESS_DENIED)
@ -167,7 +170,6 @@ void StartCmder(std::wstring path, bool is_single_mode)
: L"Failed to backup ConEmu.xml file to ./config folder!", MB_TITLE, MB_ICONSTOP); : L"Failed to backup ConEmu.xml file to ./config folder!", MB_TITLE, MB_ICONSTOP);
exit(1); exit(1);
} }
}
if (is_single_mode) if (is_single_mode)
{ {