| 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 | { |
no test coverage detected