summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/app.c b/src/app.c
index 5e7af85e..d2a80561 100644
--- a/src/app.c
+++ b/src/app.c
@@ -94,17 +94,14 @@ static const char *defaultDataDir_App_ = "~/AppData/Roaming/fi.skyjake.Lagrange"
94#endif 94#endif
95#if defined (iPlatformLinux) || defined (iPlatformOther) 95#if defined (iPlatformLinux) || defined (iPlatformOther)
96#define EMB_BIN "../../share/lagrange/resources.lgr" 96#define EMB_BIN "../../share/lagrange/resources.lgr"
97#define EMB_BIN2 "../../../share/lagrange/resources.lgr"
97static const char *defaultDataDir_App_ = "~/.config/lagrange"; 98static const char *defaultDataDir_App_ = "~/.config/lagrange";
98#endif 99#endif
99#if defined (iPlatformHaiku) 100#if defined (iPlatformHaiku)
100#define EMB_BIN "./resources.lgr" 101#define EMB_BIN "./resources.lgr"
101static const char *defaultDataDir_App_ = "~/config/settings/lagrange"; 102static const char *defaultDataDir_App_ = "~/config/settings/lagrange";
102#endif 103#endif
103#if defined (LAGRANGE_EMB_BIN) /* specified in build config */ 104#define EMB_BIN_EXEC "../resources.lgr" /* fallback from build/executable dir */
104# undef EMB_BIN
105# define EMB_BIN LAGRANGE_EMB_BIN
106#endif
107#define EMB_BIN2 "../resources.lgr" /* fallback from build/executable dir */
108static const char *prefsFileName_App_ = "prefs.cfg"; 105static const char *prefsFileName_App_ = "prefs.cfg";
109static const char *oldStateFileName_App_ = "state.binary"; 106static const char *oldStateFileName_App_ = "state.binary";
110static const char *stateFileName_App_ = "state.lgr"; 107static const char *stateFileName_App_ = "state.lgr";
@@ -722,14 +719,29 @@ static void init_App_(iApp *d, int argc, char **argv) {
722 } 719 }
723 /* Load the resources from a file. Check the executable directory first, then a 720 /* Load the resources from a file. Check the executable directory first, then a
724 system-wide location, and as a final fallback, the current working directory. */ { 721 system-wide location, and as a final fallback, the current working directory. */ {
725 if (!init_Resources(concatPath_CStr(cstr_String(execPath_App()), EMB_BIN2))) { 722 const char *execPath = cstr_String(execPath_App());
726 if (!init_Resources(concatPath_CStr(cstr_String(execPath_App()), EMB_BIN))) { 723 const char *paths[] = {
727 if (!init_Resources("resources.lgr")) { 724 concatPath_CStr(execPath, EMB_BIN_EXEC), /* first the executable's directory */
728 fprintf(stderr, "failed to load resources: %s\n", strerror(errno)); 725#if defined (LAGRANGE_EMB_BIN) /* specified in build config (absolute path) */
729 exit(-1); 726 LAGRANGE_EMB_BIN,
730 } 727#endif
728#if defined (EMB_BIN2) /* alternative location */
729 concatPath_CStr(execPath, EMB_BIN2),
730#endif
731 concatPath_CStr(execPath, EMB_BIN),
732 "resources.lgr" /* cwd */
733 };
734 iBool wasLoaded = iFalse;
735 iForIndices(i, paths) {
736 if (init_Resources(paths[i])) {
737 wasLoaded = iTrue;
738 break;
731 } 739 }
732 } 740 }
741 if (!wasLoaded) {
742 fprintf(stderr, "failed to load resources: %s\n", strerror(errno));
743 exit(-1);
744 }
733 } 745 }
734 init_Lang(); 746 init_Lang();
735 /* Configure the valid command line options. */ { 747 /* Configure the valid command line options. */ {