Moved getenv usage across to safer osg::getEnvVar() usage
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <osg/Config>
|
||||
|
||||
#ifdef OSG_ENVVAR_SUPPORTED
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
@@ -29,6 +30,15 @@ inline unsigned int getClampedLength(const char* str, unsigned int maxNumChars=4
|
||||
return i;
|
||||
}
|
||||
|
||||
inline std::string getEnvVar(const char* name)
|
||||
{
|
||||
std::string value;
|
||||
const char* ptr = getenv(name);
|
||||
if (ptr) value.assign(ptr, getClampedLength(ptr));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline bool getEnvVar(const char* name, T& value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user