From f0ad77251b28fcf48dcaf25f23e3a140d69a4735 Mon Sep 17 00:00:00 2001 From: FlafyDev Date: Fri, 19 Aug 2022 23:18:09 +0300 Subject: move absolutePath to MiscFunctions --- src/config/ConfigManager.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 37ea10fc..162c8611 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -782,7 +782,7 @@ void CConfigManager::handleSource(const std::string& command, const std::string& return; } - auto value = absolutePath(rawpath); + auto value = absolutePath(rawpath, configCurrentPath); if (!std::filesystem::exists(value)) { Debug::log(ERR, "source= file doesnt exist"); @@ -876,28 +876,6 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: return parseError; } -std::string CConfigManager::absolutePath(const std::string& rawpath) { - auto value = rawpath; - - 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] == '~') { - static const char* const ENVHOME = getenv("HOME"); - value.replace(0, 1, std::string(ENVHOME)); - } - - return value; -} - void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equalsPlace) { auto dollarPlace = line.find_first_of('$', equalsPlace); -- cgit v1.2.3