Browse Source

ENH: Add access for all environment variables

Andy Cedilnik 19 years ago
parent
commit
f44fedd3e9
2 changed files with 14 additions and 0 deletions
  1. 13 0
      Source/cmSystemTools.cxx
  2. 1 0
      Source/cmSystemTools.h

+ 13 - 0
Source/cmSystemTools.cxx

@@ -56,6 +56,8 @@
 # pragma set woff 1375 /* base class destructor not virtual */
 #endif
 
+extern char** environ; // For GetEnvironmentVariables
+
 bool cmSystemTools::s_RunCommandHideConsole = false;
 bool cmSystemTools::s_DisableRunCommandOutput = false;
 bool cmSystemTools::s_ErrorOccured = false;
@@ -1278,6 +1280,17 @@ bool cmSystemTools::PutEnv(const char* value)
   return ret == 0;
 }
 
+std::vector<cmStdString> cmSystemTools::GetEnvironmentVariables()
+{
+  std::vector<cmStdString> env;
+  int cc;
+  for ( cc = 0; environ[cc]; ++ cc )
+    {
+    env.push_back(environ[cc]);
+    }
+  return env;
+}
+
 void cmSystemTools::EnableVSConsoleOutput()
 {
   // Visual Studio 8 2005 (devenv.exe or VCExpress.exe) will not

+ 1 - 0
Source/cmSystemTools.h

@@ -294,6 +294,7 @@ public:
   /** put a string into the environment
       of the form var=value */
   static bool PutEnv(const char* value);
+  static std::vector<cmStdString> GetEnvironmentVariables();
 
   /** Setup the environment to enable VS 8 IDE output.  */
   static void EnableVSConsoleOutput();