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

ENH: simplify code, and put the given path in front of the path list, instead of at end

parent 51658139
No related branches found
No related tags found
No related merge requests found
......@@ -54,25 +54,18 @@ ApplicationRegistry::AddApplicationPath(std::string newpath)
const char* currentEnv = itksys::SystemTools::GetEnv("ITK_AUTOLOAD_PATH");
#if defined(WIN32)
char pathSeparator = ';';
const char pathSeparator = ';';
#else
char pathSeparator = ':';
const char pathSeparator = ':';
#endif
if (currentEnv && strlen(currentEnv) > 0)
putEnvPath << newpath << pathSeparator;
if (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