Fix config path.
This commit is contained in:
parent
76efe77e85
commit
e258726829
@ -22,7 +22,7 @@ config::~config() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool config::load_config() {
|
bool config::load_config() {
|
||||||
std::string config_path = localfile::dropshell_conf();
|
std::string config_path = localfile::dropshell_env();
|
||||||
if (config_path.empty() || !std::filesystem::exists(config_path))
|
if (config_path.empty() || !std::filesystem::exists(config_path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -56,10 +56,10 @@ void config::save_config()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string parent_path = dropshell::get_parent(localfile::dropshell_conf());
|
std::string parent_path = dropshell::get_parent(localfile::dropshell_env());
|
||||||
std::filesystem::create_directories(parent_path);
|
std::filesystem::create_directories(parent_path);
|
||||||
|
|
||||||
std::string config_path = localfile::dropshell_conf();
|
std::string config_path = localfile::dropshell_env();
|
||||||
envmanager config_env(config_path);
|
envmanager config_env(config_path);
|
||||||
|
|
||||||
config_env.set_variable("local.config.directories", multi2string(mLocalConfigPaths));
|
config_env.set_variable("local.config.directories", multi2string(mLocalConfigPaths));
|
||||||
|
@ -114,7 +114,7 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmd == "edit" && argc < 3) {
|
if (cmd == "edit" && argc < 3) {
|
||||||
std::string config_file = dropshell::localfile::dropshell_conf();
|
std::string config_file = dropshell::localfile::dropshell_env();
|
||||||
std::filesystem::create_directories( dropshell::get_parent(config_file) );
|
std::filesystem::create_directories( dropshell::get_parent(config_file) );
|
||||||
dropshell::edit_file(config_file, "Please ensure any directories you have introduced in the config file exist.");
|
dropshell::edit_file(config_file, "Please ensure any directories you have introduced in the config file exist.");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -11,11 +11,11 @@ namespace dropshell {
|
|||||||
|
|
||||||
|
|
||||||
namespace localfile {
|
namespace localfile {
|
||||||
std::string dropshell_conf() {
|
std::string dropshell_env() {
|
||||||
// Try ~/.config/dropshell/dropshell.conf
|
// Try ~/.config/dropshell/dropshell.env
|
||||||
const char* home = std::getenv("HOME");
|
const char* home = std::getenv("HOME");
|
||||||
if (home) {
|
if (home) {
|
||||||
fs::path user_path = fs::path(home) / ".config" / "dropshell" / "dropshell.conf";
|
fs::path user_path = fs::path(home) / ".config" / "dropshell" / "dropshell.env";
|
||||||
return user_path.string();
|
return user_path.string();
|
||||||
}
|
}
|
||||||
std::cerr << "Warning: Couldn't determine user directory" << std::endl;
|
std::cerr << "Warning: Couldn't determine user directory" << std::endl;
|
||||||
|
@ -28,7 +28,7 @@ namespace dropshell {
|
|||||||
// | |-- service_name.hash.env
|
// | |-- service_name.hash.env
|
||||||
namespace localfile {
|
namespace localfile {
|
||||||
// ~/.config/dropshell/dropshell.conf
|
// ~/.config/dropshell/dropshell.conf
|
||||||
std::string dropshell_conf();
|
std::string dropshell_env();
|
||||||
std::string server_env(const std::string &server_name);
|
std::string server_env(const std::string &server_name);
|
||||||
std::string service_env(const std::string &server_name, const std::string &service_name);
|
std::string service_env(const std::string &server_name, const std::string &service_name);
|
||||||
std::string service_hash(const std::string &server_name, const std::string &service_name);
|
std::string service_hash(const std::string &server_name, const std::string &service_name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user