From 80008ed09f516aed4f68efbf253ab6f716c13820 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Wed, 15 Feb 2012 22:34:51 +0100 Subject: [PATCH] Issue #168 - Configuration cleanup Fixed bug with configuration tokens parsing - when something appear after token it should be appended to replaced path. Signed-off-by: Lukasz Gromanowski --- components/files/configurationmanager.cpp | 34 +++++++++++++++-------- components/files/fixedpath.hpp | 1 + 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 28d49a50c..46cd0e053 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -89,27 +89,37 @@ void ConfigurationManager::processPaths(Files::PathContainer& dataDirs) const std::string& path = it->string(); // Check if path contains a token - if (!path.empty() && *path.begin() == '?' && *path.rbegin() == '?') + if (!path.empty() && *path.begin() == '?') { - TokensMappingContainer::iterator tokenIt = mTokensMapping.find(path); - if (tokenIt != mTokensMapping.end()) + std::string::size_type pos = path.find('?', 1); + if (pos != std::string::npos && pos != 0) { - boost::filesystem::path tempPath(((mFixedPath).*(tokenIt->second))()); - - if (boost::filesystem::is_directory(tempPath)) + TokensMappingContainer::iterator tokenIt = mTokensMapping.find(path.substr(0, pos + 1)); + if (tokenIt != mTokensMapping.end()) { - (*it) = tempPath; + boost::filesystem::path tempPath(((mFixedPath).*(tokenIt->second))()); + if (pos < path.length() - 1) + { + // There is something after the token, so we should + // append it to the path + tempPath /= path.substr(pos + 1, path.length() - pos); + } + + if (boost::filesystem::is_directory(tempPath)) + { + (*it) = tempPath; + } + else + { + (*it).clear(); + } } else { + // Clean invalid / unknown token, it will be removed outside the loop (*it).clear(); } } - else - { - // Clean invalid / unknown token, it will be removed outside the loop - (*it).clear(); - } } } diff --git a/components/files/fixedpath.hpp b/components/files/fixedpath.hpp index 1bf582ab9..0e052fd24 100644 --- a/components/files/fixedpath.hpp +++ b/components/files/fixedpath.hpp @@ -86,6 +86,7 @@ struct FixedPath mGlobalPath /= suffix; mLocalDataPath /= suffix; + mUserDataPath /= suffix; mGlobalDataPath /= suffix; } }