Import Geant4 11.0.0.beta source tree
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
||||
// See the file tools.license for terms.
|
||||
|
||||
#ifndef tools_put_env
|
||||
#define tools_put_env
|
||||
|
||||
//WARNING : CYGWIN/gnu/std=c++11 : putenv, setenv not found.
|
||||
|
||||
#include "get_env"
|
||||
|
||||
#include "cstr"
|
||||
|
||||
namespace tools {
|
||||
|
||||
inline bool put_env(const std::string& a_env,const std::string& a_value){
|
||||
std::string value = a_env+"="+a_value;
|
||||
#ifdef TOOLS_MEM
|
||||
if(::putenv(str_dup(value.c_str(),false))) return false;
|
||||
#else
|
||||
if(::putenv(str_dup(value.c_str()))) return false;
|
||||
#endif
|
||||
//check:
|
||||
std::string s;
|
||||
if(!get_env(a_env,s)) return false;
|
||||
if(s!=a_value) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool rm_env(const std::string& a_env){
|
||||
#ifdef _MSC_VER
|
||||
std::string value = a_env+"=";
|
||||
#ifdef TOOLS_MEM
|
||||
if(::putenv(str_dup(value.c_str(),false))) return false;
|
||||
#else
|
||||
if(::putenv(str_dup(value.c_str()))) return false;
|
||||
#endif
|
||||
#else
|
||||
::unsetenv(a_env.c_str());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user