added ability to have a user-ConEmu.xml file in addition to the computer specific and default ConEmu.xml files

This commit is contained in:
Dax Games 2016-10-02 21:50:56 -05:00
parent af586d5410
commit 66c6d5bbb3

View File

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