diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-07-06 15:05:23 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-07-06 15:05:23 +0200 |
| commit | 0277f4c6bd8f1203a54ed7d6266871c8b8a5e6c6 (patch) | |
| tree | b526a052632ebc0b8cf381871400e4cb02bff349 /src/config/ConfigManager.cpp | |
| parent | 8d05dddb98e598da6e487b472399d691fc0b7e85 (diff) | |
support relative paths in source=
Diffstat (limited to 'src/config/ConfigManager.cpp')
| -rw-r--r-- | src/config/ConfigManager.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 842e3bf4..ee8ab95e 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -577,6 +577,23 @@ void CConfigManager::handleSource(const std::string& command, const std::string& auto value = rawpath; + if (value.length() < 2) { + Debug::log(ERR, "source= path garbage"); + parseError = "source path " + value + " bogus!"; + return; + } + + if (value[0] == '.') { + auto currentDir = configCurrentPath.substr(0, configCurrentPath.find_last_of('/')); + + if (value[1] == '.') { + auto parentDir = currentDir.substr(0, currentDir.find_last_of('/')); + value.replace(0, 2, parentDir); + } else { + value.replace(0, 1, currentDir); + } + } + if (value[0] == '~') { value.replace(0, 1, std::string(ENVHOME)); } |
