History

Fix config load problem on macOS/Linux

Olav Sørensen committed 4 years ago

Commit 1e43b501 parent ed51fab3 files · +18 −4Browse files

Unified · Split

3 files
  1. src/pt2_config.c +4 −4
  2. src/pt2_diskop.c +11 −0
  3. src/pt2_diskop.h +3 −0
src/pt2_config.c+4−4
@@ -17,7 +17,7 @@ · 16 unmodified lines
1717 #include "pt2_config.h"
1818 #include "pt2_tables.h"
1919 #include "pt2_sampler.h"
20−#include "pt2_diskop.h" // changePathToDesktop()
20+#include "pt2_diskop.h" // changePathToDesktop(), changePathToHome()
2121
2222 #ifndef _WIN32
2323 static char oldCwd[PATH_MAX];
@@ -87,7 +87,7 @@ void loadConfig(void) · 63 unmodified lines
8787 proTrackerDotIniFound = true;
8888
8989 // check in ~/.protracker/
90− if (!proTrackerDotIniFound && changePathToDesktop() && chdir(".protracker") == 0)
90+ if (!proTrackerDotIniFound && changePathToHome() && chdir(".protracker") == 0)
9191 {
9292 f = fopen("protracker.ini", "r");
9393 if (f != NULL)
@@ -116,7 +116,7 @@ void loadConfig(void) · 22 unmodified lines
116116 ptDotConfigFound = true;
117117
118118 // check in ~/.protracker/
119− if (!ptDotConfigFound && changePathToDesktop() && chdir(".protracker") == 0)
119+ if (!ptDotConfigFound && changePathToHome() && chdir(".protracker") == 0)
120120 {
121121 f = openPTDotConfig();
122122 if (f != NULL)
@@ -140,7 +140,7 @@ void loadConfig(void) · 17 unmodified lines
140140 colorsDotIniFound = loadColorsDotIni();
141141
142142 // check in ~/.protracker/
143− if (!colorsDotIniFound && changePathToDesktop() && chdir(".protracker") == 0)
143+ if (!colorsDotIniFound && changePathToHome() && chdir(".protracker") == 0)
144144 loadColorsDotIni();
145145 #endif
146146
src/pt2_diskop.c+11−0
@@ -393,6 +393,17 @@ bool changePathToDesktop(void) · 392 unmodified lines
393393 #endif
394394 }
395395
396+#ifndef _WIN32
397+bool changePathToHome(void)
398+{
399+ char *homePath = getenv("HOME");
400+ if (homePath != NULL && chdir(homePath) == 0)
401+ return true;
402+
403+ return false;
404+}
405+#endif
406+
396407 void setPathFromDiskOpMode(void)
397408 {
398409 UNICHAR_CHDIR((diskop.mode == DISKOP_MODE_MOD) ? editor.modulesPathU : editor.samplesPathU);
src/pt2_diskop.h+3−0
@@ -28,5 +28,8 @@ void freeDiskOpMem(void); · 27 unmodified lines
2828 void freeDiskOpEntryMem(void);
2929 void setPathFromDiskOpMode(void);
3030 bool changePathToDesktop(void);
31+#ifndef _WIN32
32+bool changePathToHome(void);
33+#endif
3134 void renderDiskOpScreen(void);
3235 void updateDiskOp(void);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t