1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 03:53:52 +00:00

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 <lgromanowski@gmail.com>
This commit is contained in:
Lukasz Gromanowski 2012-02-15 22:34:51 +01:00
parent bcc4d7a7c9
commit 80008ed09f
2 changed files with 23 additions and 12 deletions

View file

@ -89,12 +89,21 @@ void ConfigurationManager::processPaths(Files::PathContainer& dataDirs)
const std::string& path = it->string(); const std::string& path = it->string();
// Check if path contains a token // Check if path contains a token
if (!path.empty() && *path.begin() == '?' && *path.rbegin() == '?') if (!path.empty() && *path.begin() == '?')
{ {
TokensMappingContainer::iterator tokenIt = mTokensMapping.find(path); std::string::size_type pos = path.find('?', 1);
if (pos != std::string::npos && pos != 0)
{
TokensMappingContainer::iterator tokenIt = mTokensMapping.find(path.substr(0, pos + 1));
if (tokenIt != mTokensMapping.end()) if (tokenIt != mTokensMapping.end())
{ {
boost::filesystem::path tempPath(((mFixedPath).*(tokenIt->second))()); 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)) if (boost::filesystem::is_directory(tempPath))
{ {
@ -112,6 +121,7 @@ void ConfigurationManager::processPaths(Files::PathContainer& dataDirs)
} }
} }
} }
}
dataDirs.erase(std::remove_if(dataDirs.begin(), dataDirs.end(), EmptyPath()), dataDirs.end()); dataDirs.erase(std::remove_if(dataDirs.begin(), dataDirs.end(), EmptyPath()), dataDirs.end());
} }

View file

@ -86,6 +86,7 @@ struct FixedPath
mGlobalPath /= suffix; mGlobalPath /= suffix;
mLocalDataPath /= suffix; mLocalDataPath /= suffix;
mUserDataPath /= suffix;
mGlobalDataPath /= suffix; mGlobalDataPath /= suffix;
} }
} }