Tidying
This commit is contained in:
@ -11,33 +11,32 @@ namespace dropshell {
|
||||
|
||||
|
||||
namespace localfile {
|
||||
|
||||
std::string dropshell_env() {
|
||||
// Try ~/.config/dropshell/dropshell.env
|
||||
const char* home = std::getenv("HOME");
|
||||
if (home) {
|
||||
fs::path user_path = fs::path(home) / ".config" / "dropshell" / "dropshell.env";
|
||||
return user_path.string();
|
||||
}
|
||||
std::cerr << "Warning: Couldn't determine user directory" << std::endl;
|
||||
return std::string();
|
||||
// Try ~/.config/dropshell/dropshell.env
|
||||
const char* home = std::getenv("HOME");
|
||||
if (home) {
|
||||
fs::path user_path = fs::path(home) / ".config" / "dropshell" / "dropshell.env";
|
||||
return user_path.string();
|
||||
}
|
||||
std::cerr << "Warning: Couldn't determine user directory" << std::endl;
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string server_env(const std::string &server_name) {
|
||||
if (server_name.empty())
|
||||
return std::string();
|
||||
std::string serverpath = localpath::server(server_name);
|
||||
if (serverpath.empty())
|
||||
return std::string();
|
||||
return (fs::path(serverpath) / "server.env").string();
|
||||
return (serverpath.empty() ? "" : (fs::path(serverpath) / "server.env").string());
|
||||
}
|
||||
|
||||
std::string service_env(const std::string &server_name, const std::string &service_name) {
|
||||
if (server_name.empty() || service_name.empty())
|
||||
return std::string();
|
||||
std::string servicepath = localpath::service(server_name, service_name);
|
||||
if (servicepath.empty())
|
||||
return std::string();
|
||||
return (fs::path(servicepath) / "service.env").string();
|
||||
return (servicepath.empty() ? "" : (fs::path(servicepath) / "service.env").string());
|
||||
}
|
||||
|
||||
std::string template_info_env(const std::string &server_name, const std::string &service_name)
|
||||
{
|
||||
std::string servicepath = localpath::service(server_name, service_name);
|
||||
return (servicepath.empty() ? "" : (fs::path(servicepath) / ".template_info.env").string());
|
||||
}
|
||||
|
||||
std::string service_hash(const std::string &server_name, const std::string &service_name) {
|
||||
@ -80,6 +79,7 @@ namespace localpath {
|
||||
}
|
||||
|
||||
std::string server(const std::string &server_name) {
|
||||
if (server_name.empty()) return "";
|
||||
for (auto &dir : gConfig().get_local_config_directories())
|
||||
if (fs::exists(dir + "/servers/" + server_name))
|
||||
return dir + "/servers/" + server_name;
|
||||
@ -88,7 +88,7 @@ namespace localpath {
|
||||
|
||||
std::string service(const std::string &server_name, const std::string &service_name) {
|
||||
std::string serverpath = localpath::server(server_name);
|
||||
return (serverpath.empty() ? "" : (serverpath+"/"+service_name));
|
||||
return (serverpath.empty() || service_name.empty() ? "" : (serverpath+"/"+service_name));
|
||||
}
|
||||
} // namespace localpath
|
||||
|
||||
|
Reference in New Issue
Block a user