MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / Setenv

Function Setenv

src/OpenColorIO/Platform.cpp:99–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99void 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
123void Unsetenv(const char * name)
124{

Callers 6

SetEnvVariableFunction · 0.85
InactiveCSGuardMethod · 0.85
OCIO_ADD_TESTFunction · 0.85
GuardMethod · 0.85
OCIO_ADD_TESTFunction · 0.85

Calls 1

Utf8ToUtf16Function · 0.85

Tested by 5

InactiveCSGuardMethod · 0.68
OCIO_ADD_TESTFunction · 0.68
GuardMethod · 0.68
OCIO_ADD_TESTFunction · 0.68