Skip to content
Snippets Groups Projects
Commit 51658139 authored by Julien Malik's avatar Julien Malik
Browse files

BUG: fix ITK_AUTOLOAD_PATH configuration for Windows, and avoid multiple separators

parent c3c4c38e
No related branches found
No related tags found
No related merge requests found
......@@ -50,13 +50,29 @@ ApplicationRegistry::AddApplicationPath(std::string newpath)
std::ostringstream putEnvPath;
putEnvPath << "ITK_AUTOLOAD_PATH=";
// Can be NULL if the env var is not set
const char* currentEnv = itksys::SystemTools::GetEnv("ITK_AUTOLOAD_PATH");
if (currentEnv)
#if defined(WIN32)
char pathSeparator = ';';
#else
char pathSeparator = ':';
#endif
if (currentEnv && strlen(currentEnv) > 0)
{
putEnvPath << currentEnv << ":";
putEnvPath << currentEnv;
// The current value of the env var can already end with the pathSeparator
char lastChar = currentEnv[ strlen(currentEnv) - 1 ];
if ( lastChar != pathSeparator )
{
putEnvPath << pathSeparator;
}
}
putEnvPath << newpath;
std::cout << "ITK_AUTOLOAD_PATH " << putEnvPath.str() << std::endl;
// do NOT use putenv() directly, since the string memory must be managed carefully
itksys::SystemTools::PutEnv(putEnvPath.str().c_str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment