dropshell/src/utils/directories.hpp

99 lines
3.6 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
// server_definition_path
// |-- <server_name>
// |-- server.json
// |-- services
// |-- <service_name>
// |-- service.env
// |-- .template_info.env
// |-- (...other config files for specific server&service...)
// backup path
// |-- katie-_-squashkiwi-_-squashkiwi-test-_-2025-04-28_21-23-59.tgz
// temp files path
// template cache path
// |-- templates
// | |-- <template_name>.json
// | |-- <template_name>
// | |-- (...script files...)
// | |-- _default.env
// | |-- config
// | |-- service.env
// | |-- .template_info.env
// | |-- (...other service config files...)
// |-- remote_versions
// | |-- server_name-service_name.json
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);
} // 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 local_bin();
std::string current_user_home();
} // namespace local
//------------------------------------------------------------------------------------------------
// remote paths
// DROPSHELL_DIR
// |-- backups
// |-- temp_files
// |-- services
// |-- service name
// |-- config
// |-- service.env
// |-- template
// |-- (script files)
// |-- config
// |-- service.env
// |-- (other config files for specific server&service)
namespace remotefile {
std::string service_env(const std::string &server_name, const std::string &service_name);
} // namespace remotefile
namespace remotepath {
std::string DROPSHELL_DIR(const std::string &server_name);
std::string services(const std::string &server_name);
std::string service(const std::string &server_name, const std::string &service_name);
std::string service_config(const std::string &server_name, const std::string &service_name);
std::string service_template(const std::string &server_name, const std::string &service_name);
std::string backups(const std::string &server_name);
std::string temp_files(const std::string &server_name);
} // namespace remotepath
//------------------------------------------------------------------------------------------------
// 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