Add a possibility to overwrite assets dir using environment variable.

It fixes #2982 when both SUPERTUXKART_DATADIR and SUPERTUXKART_ASSETS_DIR are set.
This commit is contained in:
Deve
2017-10-29 21:02:13 +01:00
parent f7886a31bf
commit 57c874f703

View File

@@ -211,14 +211,33 @@ FileManager::FileManager()
"Set $SUPERTUXKART_DATADIR to point to the data directory.");
// fatal will exit the application
}
addRootDirs(root_dir);
if( fileExists(root_dir+"../../stk-assets"))
addRootDirs(root_dir+"../../stk-assets");
if( fileExists(root_dir+"../../supertuxkart-assets"))
addRootDirs(root_dir+"../../supertuxkart-assets");
if ( getenv ( "SUPERTUXKART_ROOT_PATH" ) != NULL )
addRootDirs(getenv("SUPERTUXKART_ROOT_PATH"));
std::string assets_dir;
if (getenv("SUPERTUXKART_ASSETS_DIR") != NULL)
{
assets_dir = std::string(getenv("SUPERTUXKART_ASSETS_DIR"));
}
else if (fileExists(root_dir + "../../stk-assets"))
{
assets_dir = root_dir + "../../stk-assets";
}
else if (fileExists(root_dir + "../../supertuxkart-assets"))
{
assets_dir = root_dir + "../../supertuxkart-assets";
}
else if (getenv("SUPERTUXKART_ROOT_PATH") != NULL)
{
//is this needed?
assets_dir = std::string(getenv("SUPERTUXKART_ROOT_PATH"));
}
if (!assets_dir.empty() && assets_dir != root_dir)
{
addRootDirs(assets_dir);
}
checkAndCreateConfigDir();
checkAndCreateAddonsDir();