| 97 | } |
| 98 | |
| 99 | void Setenv(const char * name, const std::string & value) |
| 100 | { |
| 101 | if (!name || !*name) |
| 102 | { |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | // Note that the Windows _putenv_s() removes the env. variable if the value is empty. But |
| 107 | // the Linux ::setenv() sets the env. variable to empty if the value is empty i.e. it still |
| 108 | // exists. To avoid the ambiguity, use Unsetenv() when the env. variable removal if needed. |
| 109 | |
| 110 | #ifdef _WIN32 |
| 111 | |
| 112 | #ifdef UNICODE |
| 113 | _wputenv_s(Utf8ToUtf16(name).c_str(), Utf8ToUtf16(value).c_str()); |
| 114 | #else |
| 115 | _putenv_s(name, value.c_str()); |
| 116 | #endif |
| 117 | |
| 118 | #else |
| 119 | ::setenv(name, value.c_str(), 1); |
| 120 | #endif |
| 121 | } |
| 122 | |
| 123 | void Unsetenv(const char * name) |
| 124 | { |