13 #ifndef __STOUT_OS_WINDOWS_GETENV_HPP__ 14 #define __STOUT_OS_WINDOWS_GETENV_HPP__ 32 std::wstring wide_key = wide_stringify(key);
39 const DWORD buffer_size =
40 ::GetEnvironmentVariableW(wide_key.data(),
nullptr, 0);
41 if (buffer_size == 0) {
42 if (::GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
50 environment.reserve(static_cast<size_t>(buffer_size));
53 ::GetEnvironmentVariableW(wide_key.data(), environment.data(), buffer_size);
55 if (value_size == 0) {
58 if (::GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
65 return stringify(std::wstring(environment.data()));
70 #endif // __STOUT_OS_WINDOWS_GETENV_HPP__
Definition: posix_signalhandler.hpp:23
Option< std::string > getenv(const std::string &key)
Definition: getenv.hpp:29
std::map< std::string, std::string > environment()
Definition: environment.hpp:24
std::string stringify(int flags)