# Prevents OpenAL Soft from loading from its config file. --- a/alc/alconfig.cpp +++ b/alc/alconfig.cpp @@ -329,157 +329,157 @@ const char *GetConfigValue(const char *devName, const char *blockName, const cha #ifdef _WIN32 void ReadALConfig() { - WCHAR buffer[MAX_PATH]; - if(SHGetSpecialFolderPathW(nullptr, buffer, CSIDL_APPDATA, FALSE) != FALSE) - { - std::string filepath{wstr_to_utf8(buffer)}; - filepath += "\\alsoft.ini"; - TRACE("Loading config %s...\n", filepath.c_str()); - al::ifstream f{filepath}; - if(f.is_open()) - LoadConfigFromFile(f); - } - std::string ppath{GetProcBinary().path}; - if(!ppath.empty()) - { - ppath += "\\alsoft.ini"; - TRACE("Loading config %s...\n", ppath.c_str()); - al::ifstream f{ppath}; - if(f.is_open()) - LoadConfigFromFile(f); - } - if(auto confpath = al::getenv(L"ALSOFT_CONF")) - { - TRACE("Loading config %s...\n", wstr_to_utf8(confpath->c_str()).c_str()); - al::ifstream f{*confpath}; - if(f.is_open()) - LoadConfigFromFile(f); - } + + + + + + + + + + + + + + + + + + + + + + + + + + } #else void ReadALConfig() { - const char *str{"/etc/openal/alsoft.conf"}; - - TRACE("Loading config %s...\n", str); - al::ifstream f{str}; - if(f.is_open()) - LoadConfigFromFile(f); - f.close(); - - std::string confpaths{al::getenv("XDG_CONFIG_DIRS").value_or("/etc/xdg")}; - /* Go through the list in reverse, since "the order of base directories - * denotes their importance; the first directory listed is the most - * important". Ergo, we need to load the settings from the later dirs - * first so that the settings in the earlier dirs override them. - */ - std::string fname; - while(!confpaths.empty()) - { - auto next = confpaths.find_last_of(':'); - if(next < confpaths.length()) - { - fname = confpaths.substr(next+1); - confpaths.erase(next); - } - else - { - fname = confpaths; - confpaths.clear(); - } - if(fname.empty() || fname.front() != '/') - WARN("Ignoring XDG config dir: %s\n", fname.c_str()); - else - { - if(fname.back() != '/') fname += "/alsoft.conf"; - else fname += "alsoft.conf"; - TRACE("Loading config %s...\n", fname.c_str()); - f = al::ifstream{fname}; - if(f.is_open()) - LoadConfigFromFile(f); - } - fname.clear(); - } -#ifdef __APPLE__ - CFBundleRef mainBundle = CFBundleGetMainBundle(); - if(mainBundle) - { - unsigned char fileName[PATH_MAX]; - CFURLRef configURL; - if((configURL=CFBundleCopyResourceURL(mainBundle, CFSTR(".alsoftrc"), CFSTR(""), nullptr)) && - CFURLGetFileSystemRepresentation(configURL, true, fileName, sizeof(fileName))) - { - f = al::ifstream{reinterpret_cast(fileName)}; - if(f.is_open()) - LoadConfigFromFile(f); - } - } -#endif - if(auto homedir = al::getenv("HOME")) - { - fname = *homedir; - if(fname.back() != '/') fname += "/.alsoftrc"; - else fname += ".alsoftrc"; - - TRACE("Loading config %s...\n", fname.c_str()); - f = al::ifstream{fname}; - if(f.is_open()) - LoadConfigFromFile(f); - } - if(auto configdir = al::getenv("XDG_CONFIG_HOME")) - { - fname = *configdir; - if(fname.back() != '/') fname += "/alsoft.conf"; - else fname += "alsoft.conf"; - } - else - { - fname.clear(); - if(auto homedir = al::getenv("HOME")) - { - fname = *homedir; - if(fname.back() != '/') fname += "/.config/alsoft.conf"; - else fname += ".config/alsoft.conf"; - } - } - if(!fname.empty()) - { - TRACE("Loading config %s...\n", fname.c_str()); - f = al::ifstream{fname}; - if(f.is_open()) - LoadConfigFromFile(f); - } - std::string ppath{GetProcBinary().path}; - if(!ppath.empty()) - { - if(ppath.back() != '/') ppath += "/alsoft.conf"; - else ppath += "alsoft.conf"; - TRACE("Loading config %s...\n", ppath.c_str()); - f = al::ifstream{ppath}; - if(f.is_open()) - LoadConfigFromFile(f); - } - if(auto confname = al::getenv("ALSOFT_CONF")) - { - TRACE("Loading config %s...\n", confname->c_str()); - f = al::ifstream{*confname}; - if(f.is_open()) - LoadConfigFromFile(f); - } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } #endif