mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-13 11:19:10 +08:00
commit
104033e58b
@ -1,7 +1,7 @@
|
|||||||
@echo off
|
@echo off
|
||||||
SET CMDER_ROOT=%~dp0
|
SET CMDER_ROOT=%~dp0
|
||||||
|
|
||||||
:: Remove trailing '\'
|
:: Remove Trailing '\'
|
||||||
@if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1%
|
@if "%CMDER_ROOT:~-1%" == "\" SET CMDER_ROOT=%CMDER_ROOT:~0,-1%
|
||||||
|
|
||||||
if exist "%~1" (
|
if exist "%~1" (
|
||||||
|
@ -103,6 +103,9 @@ 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 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,19 +120,27 @@ 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(oldCfgPath, exeDir, L"config\\ConEmu-%COMPUTERNAME%.xml");
|
PathCombine(cpuCfgPath, exeDir, L"config\\ConEmu-%COMPUTERNAME%.xml");
|
||||||
ExpandEnvironmentStrings(oldCfgPath, oldCfgPath, sizeof(oldCfgPath) / sizeof(oldCfgPath[0]));
|
ExpandEnvironmentStrings(cpuCfgPath, cpuCfgPath, sizeof(cpuCfgPath) / sizeof(cpuCfgPath[0]));
|
||||||
if (!PathFileExists(oldCfgPath)) {
|
|
||||||
|
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");
|
PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml");
|
||||||
|
wcsncpy_s(backupCfgPath, userCfgPath, sizeof(userCfgPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for machine-specific config file.
|
// Set path to vendored ConEmu config file
|
||||||
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu-%COMPUTERNAME%.xml");
|
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
|
||||||
ExpandEnvironmentStrings(cfgPath, cfgPath, sizeof(cfgPath) / sizeof(cfgPath[0]));
|
|
||||||
if (!PathFileExists(cfgPath)) {
|
|
||||||
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
|
|
||||||
}
|
|
||||||
|
|
||||||
SYSTEM_INFO sysInfo;
|
SYSTEM_INFO sysInfo;
|
||||||
GetNativeSystemInfo(&sysInfo);
|
GetNativeSystemInfo(&sysInfo);
|
||||||
@ -151,6 +162,14 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
|||||||
exit(1);
|
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)
|
if (is_single_mode)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user