...
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include "config.hpp"
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
namespace pt = boost::property_tree;
|
||||
@ -18,18 +19,14 @@ bool is_config_loaded() {
|
||||
return config_loaded;
|
||||
}
|
||||
|
||||
bool get_config_path(std::string& path) {
|
||||
bool get_config_path(std::string &path)
|
||||
{
|
||||
// Try ~/.config/dropshell/dropshell.conf
|
||||
const char* home = std::getenv("HOME");
|
||||
if (home) {
|
||||
fs::path user_path = fs::path(home) / ".config" / "dropshell" / "dropshell.conf";
|
||||
if (!fs::exists(user_path)) {
|
||||
// create path
|
||||
fs::create_directories(user_path.parent_path());
|
||||
}
|
||||
|
||||
path = user_path.string();
|
||||
return true;
|
||||
return fs::exists(path);
|
||||
}
|
||||
std::cerr << "Warning: Couldn't determine user directory" << std::endl;
|
||||
path = "";
|
||||
@ -39,12 +36,7 @@ bool get_config_path(std::string& path) {
|
||||
bool load_config() {
|
||||
std::string config_path;
|
||||
if (!get_config_path(config_path))
|
||||
return true;
|
||||
|
||||
if (config_path.empty()) {
|
||||
// No config file found, but this is not an error
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
try {
|
||||
pt::ptree tree;
|
||||
|
Reference in New Issue
Block a user