dropshell/source/src/utils/directories.hpp
Your Name 763293c7d0
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 17s
dropshell release 2025.0524.1149
2025-05-24 11:49:24 +12:00

137 lines
4.9 KiB
C++

#ifndef DIRECTORIES_HPP
#define DIRECTORIES_HPP
#include <string>
#include <filesystem>
namespace dropshell {
// all functions return empty string on failure
//------------------------------------------------------------------------------------------------
// local user config directories
// ~/.config/dropshell/dropshell.json
// ~/.local/dropshell_agent
// |-- agent-local
// |-- agent-install.sh
// |-- bb64 (only used locally, as it's for the local machine's architecture!)
// |-- template_example
// |-- agent-remote
// |-- (remote agent files, including _allservicesstatus.sh)
// ~/.local/dropshell_files
// |-- backups
// |-- katie-_-squashkiwi-_-squashkiwi-test-_-2025-04-28_21-23-59.tgz
// |-- temp_files
// |-- template_cache
// |-- templates
// | |-- <template_name>.json
// | |-- <template_name>
// | |-- (...script files...)
// | |-- config
// | |-- service.env
// | |-- .template_info.env
// | |-- (...other service config files...)
// server_definition_path
// |-- <server_name>
// |-- server.json
// |-- services
// |-- <service_name>
// |-- service.env
// |-- .template_info.env
// |-- (...other config files for specific server&service...)
namespace filenames {
static const std::string template_info_env = ".template_info.env";
static const std::string service_env = "service.env";
static const std::string readme = "README.txt";
static const std::string server_json = "server.json";
static const std::string dropshell_json = "dropshell.json";
} // namespace filenames.
namespace localfile {
// ~/.config/dropshell/dropshell.json
std::string dropshell_json();
std::string server_json(const std::string &server_name);
std::string service_env(const std::string &server_name, const std::string &service_name);
std::string template_info_env(const std::string &server_name, const std::string &service_name);
std::string template_example();
std::string bb64();
} // namespace localfile
namespace localpath {
std::string server(const std::string &server_name);
std::string service(const std::string &server_name, const std::string &service_name);
std::string remote_versions(const std::string &server_name, const std::string &service_name);
std::string agent_local();
std::string agent_remote();
std::string current_user_home();
std::string dropshell_files();
std::string backups();
std::string temp_files();
std::string template_cache();
bool create_directories();
} // namespace local
//------------------------------------------------------------------------------------------------
// remote paths
// DROPSHELL_DIR
// |-- backups
// |-- temp_files
// |-- agent
// | |-- bb64
// | |-- (other agent files, including _allservicesstatus.sh)
// |-- services
// |-- service name
// |-- config
// |-- service.env (actual service config)
// |-- .template_info.env
// |-- template
// |-- (script files)
// |-- config
// |-- service.env (default service config)
// |-- .template_info.env
// |-- (other config files for specific server&service)
class remotefile {
public:
remotefile(const std::string &server_name, const std::string &user);
std::string service_env(const std::string &service_name) const;
private:
std::string mServer_name;
std::string mUser;
};
class remotepath {
public:
remotepath(const std::string &server_name, const std::string &user);
std::string DROPSHELL_DIR() const;
std::string services() const;
std::string service(const std::string &service_name) const;
std::string service_config(const std::string &service_name) const;
std::string service_template(const std::string &service_name) const;
std::string backups() const;
std::string temp_files() const;
std::string agent() const;
private:
std::string mServer_name;
std::string mUser;
};
//------------------------------------------------------------------------------------------------
// utility functions
std::string get_parent(const std::filesystem::path path);
std::string get_child(const std::filesystem::path path);
} // namespace dropshell
#endif // DIRECTORIES_HPP