From cea1f15eab01a10a0bdd1974c1015ac9a345c9cd Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 18 Jul 2018 02:01:24 +0200 Subject: [PATCH] [util] Don't use std::wstring. std::wstring is problematic, because wchar_t on other platforms might not be what we need. -fshort-wchar can mitigate that partially, but it's more problematic for stdc++ classes. --- src/util/util_env.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util/util_env.cpp b/src/util/util_env.cpp index c4a02477..3eab0506 100644 --- a/src/util/util_env.cpp +++ b/src/util/util_env.cpp @@ -1,4 +1,5 @@ #include "util_env.h" +#include #include "./com/com_include.h" @@ -7,12 +8,12 @@ namespace dxvk::env { std::string getEnvVar(const wchar_t* name) { DWORD len = ::GetEnvironmentVariableW(name, nullptr, 0); - std::wstring result; + std::vector result; while (len > result.size()) { result.resize(len); len = ::GetEnvironmentVariableW( - name, &result.at(0), result.size()); + name, result.data(), result.size()); } result.resize(len); @@ -21,10 +22,10 @@ namespace dxvk::env { std::string getExeName() { - std::wstring exePath; + std::vector exePath; exePath.resize(MAX_PATH + 1); - DWORD len = ::GetModuleFileNameW(NULL, &exePath.at(0), MAX_PATH); + DWORD len = ::GetModuleFileNameW(NULL, exePath.data(), MAX_PATH); exePath.resize(len); std::string fullPath = str::fromws(exePath.data());