9std::unordered_map<std::string, std::string>
utl::getEnvMap(
const char *
const *env)
11 std::unordered_map<std::string, std::string> cpyEnv;
14 const LPCH envStrings = GetEnvironmentStringsA();
15 if (envStrings ==
nullptr)
20 for (LPCH var = envStrings; *var != 0; var += std::strlen(var) + 1)
22 std::string entry(var);
23 if (
const auto pos = entry.find(
'='); pos != std::string::npos)
25 cpyEnv.emplace(entry.substr(0, pos), entry.substr(pos + 1));
29 FreeEnvironmentStringsA(envStrings);
31 for (
const char *
const *current = env; (current !=
nullptr) && (*current !=
nullptr); ++current)
33 std::string entry(*current);
34 if (
const auto pos = entry.find(
'='); pos != std::string::npos)
36 cpyEnv.emplace(entry.substr(0, pos), entry.substr(pos + 1));