diff --git a/SystemTools.cxx b/SystemTools.cxx index f5bdf771302927077deb18e444447247ccec7ee4..d84cee77dee6925e54b0a0a6088249d60ff8df82 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -190,6 +190,24 @@ void SystemTools::GetPath(kwsys_std::vector<kwsys_std::string>& path) } } +const char* SystemTools::GetEnv(const char* key) +{ + return getenv(key); +} + +bool SystemTools::GetEnv(const char* key, kwsys_std::string& result) +{ + const char* v = getenv(key); + if(v) + { + result = v; + return true; + } + else + { + return false; + } +} const char* SystemTools::GetExecutableExtension() { diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index a4bdd82296aad3cd6db0e1fcaf5a1a93a667058b..50a67efe51cdfbd6407d6f233d6102595fd5e9fc 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -124,6 +124,10 @@ public: */ static void GetPath(kwsys_std::vector<kwsys_std::string>& path); + /** Read an environment variable. */ + static const char* GetEnv(const char* key); + static bool GetEnv(const char* key, std::string& result); + /** * Get the file extension (including ".") needed for an executable * on the current platform ("" for unix, ".exe" for Windows).