Customisable backup directory.
This commit is contained in:
@@ -38,12 +38,25 @@ int getNumConfigDirectories()
|
||||
std::string get_local_config_path(int index)
|
||||
{
|
||||
config *cfg = get_global_config();
|
||||
if (!cfg)
|
||||
return std::string();
|
||||
|
||||
std::vector<std::string> local_config_directories = cfg->get_local_config_directories();
|
||||
if (index < 0 || index >= local_config_directories.size())
|
||||
return std::string();
|
||||
return local_config_directories[index];
|
||||
}
|
||||
|
||||
|
||||
std::string get_local_backup_path()
|
||||
{
|
||||
config *cfg = get_global_config();
|
||||
if (!cfg)
|
||||
return std::string();
|
||||
|
||||
return cfg->get_local_backup_path();
|
||||
}
|
||||
|
||||
std::string get_local_config_templates_path(int index)
|
||||
{
|
||||
std::string config_path = get_local_config_path(index);
|
||||
|
@@ -9,6 +9,8 @@ namespace dropshell {
|
||||
std::string get_local_dropshell_config_path();
|
||||
std::string get_local_system_templates_path();
|
||||
|
||||
std::string get_local_backup_path();
|
||||
|
||||
int getNumConfigDirectories();
|
||||
std::string get_local_config_path(int index);
|
||||
std::string get_local_config_templates_path(int index);
|
||||
|
@@ -36,7 +36,7 @@ bool envmanager::load() {
|
||||
std::string value = line.substr(pos + 1);
|
||||
|
||||
// trim whitespace from the key and value
|
||||
m_variables[trim(key)] = trim(value);
|
||||
m_variables[dequote(trim(key))] = dequote(trim(value));
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
@@ -50,13 +50,13 @@ void envmanager::save() {
|
||||
}
|
||||
|
||||
for (const auto& pair : m_variables) {
|
||||
file << pair.first << "=" << pair.second << std::endl;
|
||||
file << pair.first << "=" << quote(pair.second) << std::endl;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
std::string envmanager::get_variable(std::string key) const {
|
||||
key = trim(key);
|
||||
key = dequote(trim(key));
|
||||
|
||||
// Use case-insensitive comparison to find the key
|
||||
for (const auto& pair : m_variables) {
|
||||
@@ -91,7 +91,7 @@ void envmanager::add_variables(std::map<std::string, std::string> variables) {
|
||||
}
|
||||
|
||||
void envmanager::set_variable(std::string key, std::string value) {
|
||||
m_variables[trim(key)] = trim(value);
|
||||
m_variables[dequote(trim(key))] = dequote(trim(value));
|
||||
}
|
||||
|
||||
void envmanager::clear_variables() {
|
||||
@@ -115,7 +115,8 @@ std::string envmanager::expand_patterns(std::string str) const {
|
||||
|
||||
result = result.replace(match.position(), match.length(), value);
|
||||
}
|
||||
|
||||
|
||||
// dequote the result
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user