diff --git a/src/util/util_env.cpp b/src/util/util_env.cpp index a4c40b31..42ab8b86 100644 --- a/src/util/util_env.cpp +++ b/src/util/util_env.cpp @@ -1,29 +1,16 @@ #include "util_env.h" #include +#include #include "./com/com_include.h" namespace dxvk::env { - std::string getEnvVar(const std::string& name) { - int nameLen = ::MultiByteToWideChar(CP_ACP, 0, name.c_str(), name.length() + 1, nullptr, 0); - - std::vector wideName(nameLen); - - ::MultiByteToWideChar(CP_ACP, 0, name.c_str(), name.length() + 1, wideName.data(), nameLen); - - DWORD len = ::GetEnvironmentVariableW(wideName.data(), nullptr, 0); - - std::vector result; - - while (len > result.size()) { - result.resize(len); - len = ::GetEnvironmentVariableW( - wideName.data(), result.data(), result.size()); - } - - result.resize(len); - return str::fromws(result.data()); + std::string getEnvVar(const char* name) { + char* result = std::getenv(name); + return (result) + ? result + : ""; } diff --git a/src/util/util_env.h b/src/util/util_env.h index d672c646..bbbfa3a1 100644 --- a/src/util/util_env.h +++ b/src/util/util_env.h @@ -13,7 +13,7 @@ namespace dxvk::env { * \param [in] name Name of the variable * \returns Value of the variable */ - std::string getEnvVar(const std::string& name); + std::string getEnvVar(const char* name); /** * \brief Gets the executable name