void write_preferences() { #ifndef _WIN32 bool prefs_file_existed = access(get_prefs_file().c_str(), F_OK) == 0; #endif try { scoped_ostream prefs_file = ostream_file(get_prefs_file()); write(*prefs_file, prefs); } catch(io_exception&) { ERR_FS << "error writing to preferences file '" << get_prefs_file() << "'\n"; } #ifndef _WIN32 if(!prefs_file_existed) { if(chmod(get_prefs_file().c_str(), 0600) == -1) { ERR_FS << "error setting permissions of preferences file '" << get_prefs_file() << "'\n"; } } #endif }
base_manager::base_manager() { scoped_istream stream = istream_file(get_prefs_file(), true); read(prefs, *stream); if (member().empty()) { std::stringstream strstr; std::map<int, int> member; member.insert(std::make_pair(172, 5)); member.insert(std::make_pair(176, 6)); member.insert(std::make_pair(244, 7)); member.insert(std::make_pair(279, 8)); member.insert(std::make_pair(103, 8)); member.insert(std::make_pair(106, 9)); member.insert(std::make_pair(120, 9)); member.insert(std::make_pair(381, 9)); for (std::map<int ,int>::const_iterator it = member.begin(); it != member.end(); ++ it) { if (it != member.begin()) { strstr << ", "; } strstr << ((it->second << 16) | it->first); } set_member(strstr.str()); } }
base_manager::base_manager() { try{ scoped_istream stream = istream_file(get_prefs_file()); read(prefs, *stream); } catch(const config::error& e) { ERR_CFG << "Error loading preference, message: " << e.what() << '\n'; } }
base_manager::base_manager() { try{ #ifdef DEFAULT_PREFS_PATH scoped_istream stream = istream_file(get_default_prefs_file()); read(prefs, *stream); config user_prefs; stream = istream_file(get_prefs_file()); read(user_prefs, *stream); prefs.merge_with(user_prefs); #else scoped_istream stream = istream_file(get_prefs_file()); read(prefs, *stream); #endif } catch(const config::error& e) { ERR_CFG << "Error loading preference, message: " << e.what() << '\n'; } }
base_manager::base_manager() { scoped_istream stream = istream_file(get_prefs_file()); read(prefs, *stream); }