Skip to content

Commit

Permalink
added backup of ConEmu.xml to ./config/user-ConEmu.xml at cmder launc…
Browse files Browse the repository at this point in the history
…h if it exists
  • Loading branch information
Dax Games authored and Dax Games committed Oct 3, 2016
1 parent abd7db9 commit 5feccb3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions launcher/src/CmderLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void StartCmder(std::wstring path, bool is_single_mode)
wchar_t exeDir[MAX_PATH] = { 0 };
wchar_t icoPath[MAX_PATH] = { 0 };
wchar_t cfgPath[MAX_PATH] = { 0 };
wchar_t backupCfgPath[MAX_PATH] = { 0 };
wchar_t cpuCfgPath[MAX_PATH] = { 0 };
wchar_t userCfgPath[MAX_PATH] = { 0 };
wchar_t oldCfgPath[MAX_PATH] = { 0 };
Expand All @@ -127,12 +128,15 @@ void StartCmder(std::wstring path, bool is_single_mode)

if (PathFileExists(cpuCfgPath)) {
wcsncpy_s(oldCfgPath, cpuCfgPath, sizeof(cpuCfgPath));
wcsncpy_s(backupCfgPath, cpuCfgPath, sizeof(cpuCfgPath));
}
else if (PathFileExists(userCfgPath)) {
wcsncpy_s(oldCfgPath, userCfgPath,sizeof(userCfgPath));
wcsncpy_s(backupCfgPath, userCfgPath, sizeof(userCfgPath));
}
else {
PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml");
wcsncpy_s(backupCfgPath, userCfgPath, sizeof(userCfgPath));
}

// Set path to vendored ConEmu config file
Expand All @@ -158,15 +162,13 @@ void StartCmder(std::wstring path, bool is_single_mode)
exit(1);
}
}
else {
if (!CopyFile(cfgPath, oldCfgPath, FALSE))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to backup ConEmu.xml file to ./config folder!"
: L"Failed to backup ConEmu.xml file to ./config folder!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
else if (!CopyFile(cfgPath, backupCfgPath, FALSE))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to backup ConEmu.xml file to ./config folder!"
: L"Failed to backup ConEmu.xml file to ./config folder!", MB_TITLE, MB_ICONSTOP);
exit(1);
}

if (is_single_mode)
Expand Down

0 comments on commit 5feccb3

Please sign in to comment.