X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Funix%2Fenviron.cpp;fp=source%2Fcore%2Funix%2Fenviron.cpp;h=037a0e943558bbcfc86eca241530dcd9f7adc77a;hp=0000000000000000000000000000000000000000;hb=f804a61c1c58529e7c98555a921b56bc05059d5e;hpb=31cc8f0c6e874e2417e76eda50af34fd17bcd90c diff --git a/source/core/unix/environ.cpp b/source/core/unix/environ.cpp new file mode 100644 index 0000000..037a0e9 --- /dev/null +++ b/source/core/unix/environ.cpp @@ -0,0 +1,34 @@ +#include +#include "environ.h" +#include "mutex.h" + +using namespace std; + +namespace Msp { + +static Mutex &env_mutex() +{ + static Mutex mutex; + return mutex; +} + +string getenv(const string &name) +{ + MutexLock _lock(env_mutex()); + const char *value = std::getenv(name.c_str()); + return (value ? string(value) : string()); +} + +void setenv(const string &name, const string &value) +{ + MutexLock _lock(env_mutex()); + ::setenv(name.c_str(), value.c_str(), true); +} + +void unsetenv(const string &name) +{ + MutexLock _lock(env_mutex()); + ::unsetenv(name.c_str()); +} + +}