diff --git a/SystemTools.cxx b/SystemTools.cxx index e041f06a74fb1876c9c6506373e9031eafa1f9cb..68542e487a6a54f02134b2eb90bac9d690359512 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -158,14 +158,18 @@ SystemTools::GetTime(void) } // adds the elements of the env variable path to the arg passed in -void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path) +void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char* env) { #if defined(_WIN32) && !defined(__CYGWIN__) const char* pathSep = ";"; #else const char* pathSep = ":"; #endif - kwsys_stl::string pathEnv = getenv("PATH"); + if(!env) + { + env = "PATH"; + } + kwsys_stl::string pathEnv = getenv(env); // A hack to make the below algorithm work. if(pathEnv[pathEnv.length()-1] != ':') { diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index b892e2f67b06d4e8a1ec29f270021cdd24a8b594..b95eb4782392c6378b062c81e08fba9cae46ffed 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -121,9 +121,10 @@ public: static unsigned long FileLength(const char *filename); /** * Add the paths from the environment variable PATH to the - * string vector passed in. + * string vector passed in. If env is set then the value + * of env will be used instead of PATH. */ - static void GetPath(kwsys_stl::vector<kwsys_stl::string>& path); + static void GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char* env=0); /** Read an environment variable. */ static const char* GetEnv(const char* key);