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.
This commit is contained in:
Chris Robinson
2018-09-07 22:32:48 -07:00
parent 46cfedb117
commit fa7993fe3e
+23
View File
@@ -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);