Skip to content

Commit 2e77513

Browse files
authored
Merge pull request #1947 from daxgames/fix_ignore_config
Fix ignore config
2 parents 45f05ed + 1640e9c commit 2e77513

File tree

3 files changed

+85
-48
lines changed

3 files changed

+85
-48
lines changed

.gitignore

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11

22
## Those files should be taken from their repositary
33

4-
bin/*/*
4+
bin/*
55
!bin/Readme.md
6+
67
vendor/*/*
78
!vendor/bin/*
89
!vendor/lib/*
910
!vendor/*
1011
!vendor/psmodules/PsGet
1112

12-
config/.history
13+
config/*
14+
!config/Readme.md
15+
1316
Thumbs.db
1417
*.exe
1518
*.dll
1619
build/
1720
Version v*
1821
*.bak
19-
config/user-*
20-
config/user_*
21-
config/*.lua
22-
config/settings
23-
config/aliases
24-
config/profile.d
2522
.github_changelog_generator
2623
launcher/.vs
2724
launcher/src/version.rc2

launcher/src/CmderLauncher.cpp

Lines changed: 80 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
110110

111111
PathCombine(configDirPath, exeDir, L"config");
112112

113+
/*
114+
Convert legacy user-profile.cmd to new name user_profile.cmd
115+
*/
113116
PathCombine(legacyUserProfilePath, configDirPath, L"user-profile.cmd");
114-
if (PathFileExists(legacyUserProfilePath)) {
117+
if (PathFileExists(legacyUserProfilePath))
118+
{
115119
PathCombine(userProfilePath, configDirPath, L"user_profile.cmd");
116120

117121
char *lPr = (char *)malloc(MAX_PATH);
@@ -124,8 +128,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
124128
rename(lPr, pR);
125129
}
126130

131+
/*
132+
Convert legacy user-aliases.cmd to new name user_aliases.cmd
133+
*/
127134
PathCombine(legacyUserAliasesPath, configDirPath, L"user-aliases.cmd");
128-
if (PathFileExists(legacyUserAliasesPath)) {
135+
if (PathFileExists(legacyUserAliasesPath))
136+
{
129137
PathCombine(userAliasesPath, configDirPath, L"user_aliases.cmd");
130138

131139
char *lPr = (char *)malloc(MAX_PATH);
@@ -137,13 +145,18 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
137145
userAliasesPath, (size_t)MAX_PATH);
138146
rename(lPr, pR);
139147
}
140-
148+
149+
/*
150+
Was -c [path] specified?
151+
*/
141152
if (wcscmp(userConfigDirPath, L"") == 0)
142153
{
154+
// No - It wasn't.
143155
PathCombine(userConfigDirPath, exeDir, L"config");
144156
}
145157
else
146158
{
159+
// Yes - It was.
147160
PathCombine(userBinDirPath, userConfigDirPath, L"bin");
148161
SHCreateDirectoryEx(0, userBinDirPath, 0);
149162

@@ -152,9 +165,13 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
152165

153166
PathCombine(userProfiledDirPath, userConfigDirPath, L"profile.d");
154167
SHCreateDirectoryEx(0, userProfiledDirPath, 0);
155-
168+
169+
/*
170+
Convert legacy user-profile.cmd to new name user_profile.cmd
171+
*/
156172
PathCombine(legacyUserProfilePath, userConfigDirPath, L"user-profile.cmd");
157-
if (PathFileExists(legacyUserProfilePath)) {
173+
if (PathFileExists(legacyUserProfilePath))
174+
{
158175
PathCombine(userProfilePath, userConfigDirPath, L"user_profile.cmd");
159176

160177
char *lPr = (char *)malloc(MAX_PATH);
@@ -167,8 +184,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
167184
rename(lPr, pR);
168185
}
169186

187+
/*
188+
Convert legacy user-aliases.cmd to new name user_aliases.cmd
189+
*/
170190
PathCombine(legacyUserAliasesPath, userConfigDirPath, L"user-aliases.cmd");
171-
if (PathFileExists(legacyUserAliasesPath)) {
191+
if (PathFileExists(legacyUserAliasesPath))
192+
{
172193
PathCombine(userAliasesPath, userConfigDirPath, L"user_aliases.cmd");
173194

174195
char *lPr = (char *)malloc(MAX_PATH);
@@ -186,104 +207,119 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
186207
PathCombine(cfgPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.xml");
187208

188209
// Set path to Cmder default ConEmu config file
189-
PathCombine(defaultCfgPath, exeDir, L"config\\ConEmu.xml");
210+
PathCombine(defaultCfgPath, exeDir, L"vendor\\ConEmu.xml.default");
190211

191212
// Check for machine-specific then user config source file.
192213
PathCombine(cpuCfgPath, userConfigDirPath, L"ConEmu-%COMPUTERNAME%.xml");
193214
ExpandEnvironmentStrings(cpuCfgPath, cpuCfgPath, sizeof(cpuCfgPath) / sizeof(cpuCfgPath[0]));
194215

216+
// Set path to Cmder user ConEmu config file
195217
PathCombine(userCfgPath, userConfigDirPath, L"user-ConEmu.xml");
196-
if (PathFileExists(cpuCfgPath)) {
197-
if (PathFileExists(cfgPath)) {
218+
219+
if (PathFileExists(cpuCfgPath)) // config/ConEmu-%COMPUTERNAME%.xml file exists, use it.
220+
{
221+
if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml file exists, copy vendor/conemu-maximus5/ConEmu.xml to config/ConEmu-%COMPUTERNAME%.xml.
222+
{
198223
if (!CopyFile(cfgPath, cpuCfgPath, FALSE))
199224
{
200225
MessageBox(NULL,
201226
(GetLastError() == ERROR_ACCESS_DENIED)
202-
? L"Failed to copy ConEmu.xml file to ConEmu-%COMPUTERNAME%.xml backup location! Restart Cmder as Administrator."
203-
: L"Failed to copy ConEmu.xml file to ConEmu-%COMPUTERNAME%.xml backup location!", MB_TITLE, MB_ICONSTOP);
227+
? L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/ConEmu-%COMPUTERNAME%.xml! Access Denied."
228+
: L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/ConEmu-%COMPUTERNAME%.xml!", MB_TITLE, MB_ICONSTOP);
204229
exit(1);
205230
}
206231
}
207-
else
232+
else // vendor/conemu-maximus5/ConEmu.xml config file does not exist, copy config/ConEmu-%COMPUTERNAME%.xml to vendor/conemu-maximus5/ConEmu.xml file
208233
{
209234
if (!CopyFile(cpuCfgPath, cfgPath, FALSE))
210235
{
211236
MessageBox(NULL,
212237
(GetLastError() == ERROR_ACCESS_DENIED)
213-
? L"Failed to copy ConEmu-%COMPUTERNAME%.xml file to vendored ConEmu.xml location! Restart Cmder as Administrator."
214-
: L"Failed to copy ConEmu-%COMPUTERNAME%.xml file to vendored ConEmu.xml location!", MB_TITLE, MB_ICONSTOP);
238+
? L"Failed to copy conig/ConEmu-%COMPUTERNAME%.xml file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
239+
: L"Failed to copy config/ConEmu-%COMPUTERNAME%.xml file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP);
215240
exit(1);
216241
}
217242
}
218243
}
219-
else if (PathFileExists(userCfgPath)) {
220-
if (PathFileExists(cfgPath)) {
244+
else if (PathFileExists(userCfgPath)) // config/user_conemu.xml exists, use it.
245+
{
246+
if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml.
247+
{
221248
if (!CopyFile(cfgPath, userCfgPath, FALSE))
222249
{
223250
MessageBox(NULL,
224251
(GetLastError() == ERROR_ACCESS_DENIED)
225-
? L"Failed to copy ConEmu.xml file to backup location! Restart Cmder as Administrator."
226-
: L"Failed to copy ConEmu.xml file to backup location!", MB_TITLE, MB_ICONSTOP);
252+
? L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/user-conemu.xml! Access Denied."
253+
: L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/user-conemu.xml!", MB_TITLE, MB_ICONSTOP);
227254
exit(1);
228255
}
229256
}
230-
else
257+
else // vendor/conemu-maximus5/ConEmu.xml does not exist, copy config/user-conemu.xml to vendor/conemu-maximus5/ConEmu.xml
231258
{
232259
if (!CopyFile(userCfgPath, cfgPath, FALSE))
233260
{
234261
MessageBox(NULL,
235262
(GetLastError() == ERROR_ACCESS_DENIED)
236-
? L"Failed to copy ConEmu.xml file to vendored ConEmu.xml location! Restart Cmder as Administrator."
237-
: L"Failed to copy ConEmu.xml file to vendored ConEmu.xml location!", MB_TITLE, MB_ICONSTOP);
263+
? L"Failed to copy config/user-conemu.xml file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
264+
: L"Failed to copy config/user-conemu.xml file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP);
238265
exit(1);
239266
}
240267
}
241268
}
242-
else if (PathFileExists(cfgPath)) {
269+
else if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml
270+
{
243271
if (!CopyFile(cfgPath, userCfgPath, FALSE))
244272
{
245273
MessageBox(NULL,
246274
(GetLastError() == ERROR_ACCESS_DENIED)
247-
? L"Failed to copy ConEmu.xml file to user-conemu.xml backup location! Restart Cmder as Administrator."
248-
: L"Failed to copy ConEmu.xml file to user-conemu.xml backup location!", MB_TITLE, MB_ICONSTOP);
275+
? L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/user-conemu.xml! Access Denied."
276+
: L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/user-conemu.xml!", MB_TITLE, MB_ICONSTOP);
249277
exit(1);
250278
}
251279
}
252-
else {
253-
if (!CopyFile(defaultCfgPath, cfgPath, FALSE))
280+
else // vendor/ConEmu.xml config exists, copy Cmder vendor/ConEmu.xml file to vendor/conemu-maximus5/ConEmu.xml.
281+
{
282+
if ( ! CopyFile(defaultCfgPath, cfgPath, FALSE))
254283
{
284+
ShowErrorAndExit(GetLastError(), __WFUNCTION__, __LINE__);
255285
MessageBox(NULL,
256286
(GetLastError() == ERROR_ACCESS_DENIED)
257-
? L"Failed to copy Cmder default ConEmu.xml file to vendored ConEmu.xml location! Restart Cmder as Administrator."
258-
: L"Failed to copy Cmder default ConEmu.xml file to vendored ConEmu.xml location!", MB_TITLE, MB_ICONSTOP);
287+
? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
288+
: L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP);
259289
exit(1);
260290
}
261291
}
262292

263293
SYSTEM_INFO sysInfo;
264294
GetNativeSystemInfo(&sysInfo);
265-
if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
295+
if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
296+
{
266297
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu64.exe");
267298
}
268-
else {
299+
else
300+
{
269301
PathCombine(conEmuPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu.exe");
270302
}
271303

272304
if (is_single_mode)
273305
{
274-
if (!streqi(cmderTask.c_str(), L"")) {
306+
if (!streqi(cmderTask.c_str(), L""))
307+
{
275308
swprintf_s(args, L"%s /single /Icon \"%s\" /Title Cmder /dir \"%s\" /run {%s}", args, icoPath, cmderStart.c_str(), cmderTask.c_str());
276309
}
277-
else {
310+
else
311+
{
278312
swprintf_s(args, L"%s /single /Icon \"%s\" /Title Cmder /dir \"%s\"", args, icoPath, cmderStart.c_str());
279313
}
280314
}
281315
else
282316
{
283-
if (!streqi(cmderTask.c_str(), L"")) {
317+
if (!streqi(cmderTask.c_str(), L""))
318+
{
284319
swprintf_s(args, L"/Icon \"%s\" /Title Cmder /dir \"%s\" /run {%s}", icoPath, cmderStart.c_str(), cmderTask.c_str());
285320
}
286-
else {
321+
else
322+
{
287323
swprintf_s(args, L"%s /Icon \"%s\" /Title Cmder /dir \"%s\"", args, icoPath, cmderStart.c_str());
288324
}
289325
}
@@ -424,7 +460,6 @@ cmderOptions GetOption()
424460
{
425461

426462
// MessageBox(NULL, szArgList[i], L"Arglist contents", MB_OK);
427-
428463
if (_wcsicmp(L"/c", szArgList[i]) == 0)
429464
{
430465
TCHAR userProfile[MAX_PATH];
@@ -435,7 +470,8 @@ cmderOptions GetOption()
435470

436471
cmderOptions.cmderCfgRoot = cmderCfgRoot;
437472

438-
if (szArgList[i + 1] != NULL && szArgList[i + 1][0] != '/') {
473+
if (szArgList[i + 1] != NULL && szArgList[i + 1][0] != '/')
474+
{
439475
cmderOptions.cmderCfgRoot = szArgList[i + 1];
440476
i++;
441477
}
@@ -453,7 +489,8 @@ cmderOptions GetOption()
453489
cmderOptions.cmderStart = szArgList[i + 1];
454490
i++;
455491
}
456-
else {
492+
else
493+
{
457494
MessageBox(NULL, szArgList[i + 1], L"/START - Folder does not exist!", MB_OK);
458495
}
459496
}
@@ -505,11 +542,13 @@ cmderOptions GetOption()
505542
cmderOptions.cmderStart = szArgList[i];
506543
i++;
507544
}
508-
else {
545+
else
546+
{
509547
MessageBox(NULL, szArgList[i], L"Folder does not exist!", MB_OK);
510548
}
511549
}
512-
else {
550+
else
551+
{
513552
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
514553
cmderOptions.error = true;
515554
}
@@ -531,7 +570,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
531570

532571
cmderOptions cmderOptions = GetOption();
533572

534-
if (cmderOptions.registerApp == true) {
573+
if (cmderOptions.registerApp == true)
574+
{
535575
RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_BACKGROUND);
536576
RegisterShellMenu(cmderOptions.cmderRegScope, SHELL_MENU_REGISTRY_PATH_LISTITEM);
537577
}
File renamed without changes.

0 commit comments

Comments
 (0)