diff options
author | Chris Robinson <[email protected]> | 2018-09-07 22:32:48 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-09-07 22:32:48 -0700 |
commit | fa7993fe3e526e0bb69fa9cb9055ee3f501c36b4 (patch) | |
tree | 18171e4837c122fa695f12878a9fcb4af4a13ca6 | |
parent | 46cfedb1171ace7c21bd1d95c1c75a8274892d3d (diff) |
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.
-rw-r--r-- | Alc/alconfig.c | 23 |
1 files changed, 23 insertions, 0 deletions
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 <windows.h> #include <shlobj.h> #endif +#ifdef __APPLE__ +#include <CoreFoundation/CoreFoundation.h> +#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); |