Merge pull request #1109 from daxgames/user_conemu_cfg

User conemu cfg
This commit is contained in:
Dax T Games 2016-11-02 10:25:54 -05:00 committed by GitHub
commit 104033e58b
2 changed files with 30 additions and 11 deletions

View File

@ -1,7 +1,7 @@
@echo off
SET CMDER_ROOT=%~dp0
:: Remove trailing '\'
:: Remove Trailing '\'
@if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1%
if exist "%~1" (

View File

@ -103,6 +103,9 @@ 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 };
wchar_t conEmuPath[MAX_PATH] = { 0 };
wchar_t args[MAX_PATH * 2 + 256] = { 0 };
@ -117,19 +120,27 @@ void StartCmder(std::wstring path, bool is_single_mode)
PathCombine(icoPath, exeDir, L"icons\\cmder.ico");
// Check for machine-specific config file.
PathCombine(oldCfgPath, exeDir, L"config\\ConEmu-%COMPUTERNAME%.xml");
ExpandEnvironmentStrings(oldCfgPath, oldCfgPath, sizeof(oldCfgPath) / sizeof(oldCfgPath[0]));
if (!PathFileExists(oldCfgPath)) {
// Check for machine-specific then user config source file.
PathCombine(cpuCfgPath, exeDir, L"config\\ConEmu-%COMPUTERNAME%.xml");
ExpandEnvironmentStrings(cpuCfgPath, cpuCfgPath, sizeof(cpuCfgPath) / sizeof(cpuCfgPath[0]));
PathCombine(userCfgPath, exeDir, L"config\\user-ConEmu.xml");
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));
}
// Check for machine-specific config file.
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu-%COMPUTERNAME%.xml");
ExpandEnvironmentStrings(cfgPath, cfgPath, sizeof(cfgPath) / sizeof(cfgPath[0]));
if (!PathFileExists(cfgPath)) {
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
}
// Set path to vendored ConEmu config file
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
SYSTEM_INFO sysInfo;
GetNativeSystemInfo(&sysInfo);
@ -151,6 +162,14 @@ void StartCmder(std::wstring path, bool is_single_mode)
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)
{