mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 17:59:11 +08:00
Merge pull request #600 from Maximus5/br-xml-location
Use standard path for ConEmu.xml
This commit is contained in:
commit
568e2cfcdd
@ -79,6 +79,19 @@ optpair GetOption()
|
|||||||
return pair;
|
return pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileExists(const wchar_t * filePath)
|
||||||
|
{
|
||||||
|
HANDLE hFile = CreateFile(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
|
|
||||||
|
if (hFile != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
CloseHandle(hFile);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void StartCmder(std::wstring path, bool is_single_mode)
|
void StartCmder(std::wstring path, bool is_single_mode)
|
||||||
{
|
{
|
||||||
#if USE_TASKBAR_API
|
#if USE_TASKBAR_API
|
||||||
@ -87,6 +100,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 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 };
|
||||||
|
|
||||||
@ -99,16 +113,29 @@ void StartCmder(std::wstring path, bool is_single_mode)
|
|||||||
PathRemoveFileSpec(exeDir);
|
PathRemoveFileSpec(exeDir);
|
||||||
|
|
||||||
PathCombine(icoPath, exeDir, L"icons\\cmder.ico");
|
PathCombine(icoPath, exeDir, L"icons\\cmder.ico");
|
||||||
PathCombine(cfgPath, exeDir, L"config\\ConEmu.xml");
|
PathCombine(oldCfgPath, exeDir, L"config\\ConEmu.xml");
|
||||||
|
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
|
||||||
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
|
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
|
||||||
|
|
||||||
|
if (FileExists(oldCfgPath) && !FileExists(cfgPath))
|
||||||
|
{
|
||||||
|
if (!CopyFile(oldCfgPath, cfgPath, FALSE))
|
||||||
|
{
|
||||||
|
MessageBox(NULL,
|
||||||
|
(GetLastError() == ERROR_ACCESS_DENIED)
|
||||||
|
? L"Failed to copy ConEmu.xml file to new location! Restart cmder as administrator."
|
||||||
|
: L"Failed to copy ConEmu.xml file to new location!", MB_TITLE, MB_ICONSTOP);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (is_single_mode)
|
if (is_single_mode)
|
||||||
{
|
{
|
||||||
swprintf_s(args, L"/single /Icon \"%s\" /Title Cmder /LoadCfgFile \"%s\"", icoPath, cfgPath);
|
swprintf_s(args, L"/single /Icon \"%s\" /Title Cmder", icoPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
swprintf_s(args, L"/Icon \"%s\" /Title Cmder /LoadCfgFile \"%s\"", icoPath, cfgPath);
|
swprintf_s(args, L"/Icon \"%s\" /Title Cmder", icoPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
|
||||||
|
@ -47,7 +47,10 @@ Param(
|
|||||||
[string]$launcher = "..\launcher",
|
[string]$launcher = "..\launcher",
|
||||||
|
|
||||||
# Include git with the package build
|
# Include git with the package build
|
||||||
[switch]$Full
|
[switch]$Full,
|
||||||
|
|
||||||
|
# config folder location
|
||||||
|
[string]$config = "..\config"
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot\utils.ps1"
|
. "$PSScriptRoot\utils.ps1"
|
||||||
@ -61,6 +64,16 @@ Ensure-Exists $sourcesPath
|
|||||||
Ensure-Executable "7z"
|
Ensure-Executable "7z"
|
||||||
New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null
|
New-Item -Type Directory -Path (Join-Path $saveTo "/tmp/") -ErrorAction SilentlyContinue >$null
|
||||||
|
|
||||||
|
# Preserve modified (by user) ConEmu setting file
|
||||||
|
if ($config -ne "") {
|
||||||
|
$ConEmuXml = Join-Path $saveTo "conemu-maximus5\ConEmu.xml"
|
||||||
|
if (Test-Path $ConEmuXml -pathType leaf) {
|
||||||
|
$ConEmuXmlSave = Join-Path $config "ConEmu.xml"
|
||||||
|
Write-Verbose "Backup '$ConEmuXml' to '$ConEmuXmlSave'"
|
||||||
|
Copy-Item $ConEmuXml $ConEmuXmlSave
|
||||||
|
} else { $ConEmuXml = "" }
|
||||||
|
} else { $ConEmuXml = "" }
|
||||||
|
|
||||||
foreach ($s in $sources) {
|
foreach ($s in $sources) {
|
||||||
if($Full -eq $false -and $s.name -eq "msysgit"){
|
if($Full -eq $false -and $s.name -eq "msysgit"){
|
||||||
Continue
|
Continue
|
||||||
@ -83,6 +96,12 @@ foreach ($s in $sources) {
|
|||||||
"$($s.version)" | Out-File "$($s.name)/.cmderver"
|
"$($s.version)" | Out-File "$($s.name)/.cmderver"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Restore user configuration
|
||||||
|
if ($ConEmuXml -ne "") {
|
||||||
|
Write-Verbose "Restore '$ConEmuXmlSave' to '$ConEmuXml'"
|
||||||
|
Copy-Item $ConEmuXmlSave $ConEmuXml
|
||||||
|
}
|
||||||
|
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
Push-Location -Path $launcher
|
Push-Location -Path $launcher
|
||||||
|
Loading…
Reference in New Issue
Block a user