MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / GetEnvironmentVariable

Function GetEnvironmentVariable

src/openrct2/platform/Platform.Win32.cpp:61–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 static u8string WIN32_GetModuleFileNameUTF8(HMODULE hModule);
60
61 std::string GetEnvironmentVariable(std::string_view name)
62 {
63 std::wstring result;
64 auto wname = String::toWideChar(name);
65 wchar_t wvalue[256];
66 auto valueSize = GetEnvironmentVariableW(wname.c_str(), wvalue, static_cast<DWORD>(std::size(wvalue)));
67 if (valueSize < std::size(wvalue))
68 {
69 result = wvalue;
70 }
71 else
72 {
73 const auto wBuffer = std::make_unique_for_overwrite<wchar_t[]>(valueSize);
74 GetEnvironmentVariableW(wname.c_str(), wBuffer.get(), valueSize);
75 result = wBuffer.get();
76 }
77 return String::toUtf8(result);
78 }
79
80 static std::string GetHomePathViaEnvironment()
81 {

Callers 1

Calls 3

toWideCharFunction · 0.85
toUtf8Function · 0.85
getMethod · 0.65

Tested by

no test coverage detected