From 8ca149d34f7150251a6fc32856ce5ac4968fce68 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 16 Dec 2003 15:55:18 -0500 Subject: ENH: Added GetEnv method. --- Source/kwsys/SystemTools.cxx | 18 ++++++++++++++++++ Source/kwsys/SystemTools.hxx.in | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 5a318aa..2f7a54e 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -190,6 +190,24 @@ void SystemTools::GetPath(kwsys_std::vector& 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/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 98556d1..1870609 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -124,6 +124,10 @@ public: */ static void GetPath(kwsys_std::vector& 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). -- cgit v0.12