Silicium
environment_variables.hpp
Go to the documentation of this file.
1 #ifndef SILICIUM_DYNAMIC_LIBRARY_HPP
2 #define SILICIUM_DYNAMIC_LIBRARY_HPP
3 
4 #include <silicium/c_string.hpp>
6 #ifdef _WIN32
7 # include <silicium/win32/win32.hpp>
8 #endif
9 
10 namespace Si
11 {
13  boost::system::error_code set_environment_variable(os_c_string key, os_c_string value)
14  {
15 #ifdef _WIN32
16  if (!SetEnvironmentVariableW(key.c_str(), value.c_str()))
17  {
18  return get_last_error();
19  }
20 #else
21  if (setenv(key.c_str(), value.c_str(), 1) != 0)
22  {
23  return get_last_error();
24  }
25 #endif
26  return{};
27  }
28 }
29 
30 #endif
Definition: c_string.hpp:10
SILICIUM_USE_RESULT boost::system::error_code set_environment_variable(os_c_string key, os_c_string value)
Definition: environment_variables.hpp:13
Definition: absolute_path.hpp:19
SILICIUM_USE_RESULT char_type const * c_str() const BOOST_NOEXCEPT
Definition: c_string.hpp:45
SILICIUM_USE_RESULT boost::system::error_code get_last_error()
Definition: get_last_error.hpp:16
#define SILICIUM_USE_RESULT
Definition: config.hpp:147