| 596 | } |
| 597 | |
| 598 | void ReadConfigFile(map<string, string>& mapSettingsRet, |
| 599 | map<string, vector<string> >& mapMultiSettingsRet) |
| 600 | { |
| 601 | boost::filesystem::ifstream streamConfig(GetConfigFile()); |
| 602 | if (!streamConfig.good()) { |
| 603 | // Create empty lux.conf if it does not exist |
| 604 | FILE* configFile = fopen(GetConfigFile().string().c_str(), "a"); |
| 605 | if (configFile != NULL) |
| 606 | fclose(configFile); |
| 607 | return; // Nothing to read, so just return |
| 608 | } |
| 609 | |
| 610 | set<string> setOptions; |
| 611 | setOptions.insert("*"); |
| 612 | |
| 613 | for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) { |
| 614 | // Don't overwrite existing settings so command line settings override lux.conf |
| 615 | string strKey = string("-") + it->string_key; |
| 616 | if (mapSettingsRet.count(strKey) == 0) { |
| 617 | mapSettingsRet[strKey] = it->value[0]; |
| 618 | // interpret nofoo=1 as foo=0 (and nofoo=0 as foo=1) as long as foo not set) |
| 619 | InterpretNegativeSetting(strKey, mapSettingsRet); |
| 620 | } |
| 621 | mapMultiSettingsRet[strKey].push_back(it->value[0]); |
| 622 | } |
| 623 | // If datadir is changed in .conf file: |
| 624 | ClearDatadirCache(); |
| 625 | } |
| 626 | |
| 627 | void WriteConfigToFile(std::string strKey, std::string strValue) |
| 628 | { |
no test coverage detected