Commit 743eb4dd authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: move PutEnv to SystemTools

parent bc2155ba
......@@ -402,6 +402,33 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result)
}
}
class kwsysDeletingCharVector : public kwsys_stl::vector<char*>
{
public:
~kwsysDeletingCharVector()
{
for(kwsys_stl::vector<char*>::iterator i = this->begin();
i != this->end(); ++i)
{
delete []*i;
}
}
};
bool SystemTools::PutEnv(const char* value)
{
static kwsysDeletingCharVector localEnvironment;
char* envVar = new char[strlen(value)+1];
strcpy(envVar, value);
int ret = putenv(envVar);
// save the pointer in the static vector so that it can
// be deleted on exit
localEnvironment.push_back(envVar);
return ret == 0;
}
const char* SystemTools::GetExecutableExtension()
{
#if defined(_WIN32) || defined(__CYGWIN__)
......
......@@ -754,6 +754,10 @@ public:
static const char* GetEnv(const char* key);
static bool GetEnv(const char* key, kwsys_stl::string& result);
/** Put a string into the environment
of the form var=value */
static bool PutEnv(const char* value);
/**
* Get current working directory CWD
*/
......
......@@ -4,7 +4,7 @@
SET(KWSYS_DATE_STAMP_YEAR 2009)
# KWSys version date month component. Format is MM.
SET(KWSYS_DATE_STAMP_MONTH 05)
SET(KWSYS_DATE_STAMP_MONTH 06)
# KWSys version date day component. Format is DD.
SET(KWSYS_DATE_STAMP_DAY 20)
SET(KWSYS_DATE_STAMP_DAY 05)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment