From fa7993fe3e526e0bb69fa9cb9055ee3f501c36b4 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 7 Sep 2018 22:32:48 -0700 Subject: Load .alsoftrc from the app bundle root on macOS Not sure what priority this should have. Currently it loads after system-level configs, and before user-level configs. --- Alc/alconfig.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Alc/alconfig.c b/Alc/alconfig.c index 5dbf59d2..c7c66653 100644 --- a/Alc/alconfig.c +++ b/Alc/alconfig.c @@ -36,6 +36,9 @@ #include #include #endif +#ifdef __APPLE__ +#include +#endif #include "alMain.h" #include "alconfig.h" @@ -478,6 +481,26 @@ void ReadALConfig(void) alstr_clear(&fname); } +#ifdef __APPLE__ + CFBundleRef mainBundle = CFBundleGetMainBundle(); + if(mainBundle) + { + unsigned char fileName[MAX_PATH]; + CFURLRef configURL; + + if((configURL=CFBundleCopyResourceURL(mainBundle, CFSTR(".alsoftrc"), CFSTR(""), NULL)) && + CFURLGetFileSystemRepresentation(configURL, true, fileName, sizeof(fileName))) + { + f = al_fopen((const char*)fileName, "r"); + if(f) + { + LoadConfigFromFile(f); + fclose(f); + } + } + } +#endif + if((str=getenv("HOME")) != NULL && *str) { alstr_copy_cstr(&fname, str); -- cgit v1.2.3