History

Fix config load problem on macOS/Linux

Olav Sørensen committed 4 years ago

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

Showing the changes to src (3 of 3 files). Show all

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
17#include "pt2_config.h"17#include "pt2_config.h"
18#include "pt2_tables.h"18#include "pt2_tables.h"
19#include "pt2_sampler.h"19#include "pt2_sampler.h"
20#include "pt2_diskop.h" // changePathToDesktop()20#include "pt2_diskop.h" // changePathToDesktop(), changePathToHome()
21 21
22#ifndef _WIN3222#ifndef _WIN32
23static char oldCwd[PATH_MAX];23static char oldCwd[PATH_MAX];
@@ -87,7 +87,7 @@ void loadConfig(void) · 63 unmodified lines
87 proTrackerDotIniFound = true;87 proTrackerDotIniFound = true;
88 88
89 // check in ~/.protracker/89 // check in ~/.protracker/
90 if (!proTrackerDotIniFound && changePathToDesktop() && chdir(".protracker") == 0)90 if (!proTrackerDotIniFound && changePathToHome() && chdir(".protracker") == 0)
91 {91 {
92 f = fopen("protracker.ini", "r");92 f = fopen("protracker.ini", "r");
93 if (f != NULL)93 if (f != NULL)
@@ -116,7 +116,7 @@ void loadConfig(void) · 22 unmodified lines
116 ptDotConfigFound = true;116 ptDotConfigFound = true;
117 117
118 // check in ~/.protracker/118 // check in ~/.protracker/
119 if (!ptDotConfigFound && changePathToDesktop() && chdir(".protracker") == 0)119 if (!ptDotConfigFound && changePathToHome() && chdir(".protracker") == 0)
120 {120 {
121 f = openPTDotConfig();121 f = openPTDotConfig();
122 if (f != NULL)122 if (f != NULL)
@@ -140,7 +140,7 @@ void loadConfig(void) · 17 unmodified lines
140 colorsDotIniFound = loadColorsDotIni();140 colorsDotIniFound = loadColorsDotIni();
141 141
142 // check in ~/.protracker/142 // check in ~/.protracker/
143 if (!colorsDotIniFound && changePathToDesktop() && chdir(".protracker") == 0)143 if (!colorsDotIniFound && changePathToHome() && chdir(".protracker") == 0)
144 loadColorsDotIni();144 loadColorsDotIni();
145#endif145#endif
146 146
src/pt2_diskop.c+11−0
@@ -393,6 +393,17 @@ bool changePathToDesktop(void) · 392 unmodified lines
393#endif393#endif
394}394}
395 395
396#ifndef _WIN32
397bool 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
396void setPathFromDiskOpMode(void)407void setPathFromDiskOpMode(void)
397{408{
398 UNICHAR_CHDIR((diskop.mode == DISKOP_MODE_MOD) ? editor.modulesPathU : editor.samplesPathU);409 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
28void freeDiskOpEntryMem(void);28void freeDiskOpEntryMem(void);
29void setPathFromDiskOpMode(void);29void setPathFromDiskOpMode(void);
30bool changePathToDesktop(void);30bool changePathToDesktop(void);
31#ifndef _WIN32
32bool changePathToHome(void);
33#endif
31void renderDiskOpScreen(void);34void renderDiskOpScreen(void);
32void updateDiskOp(void);35void 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