11 std::ifstream file(filename, std::ios::binary | std::ios::ate);
14 throw std::runtime_error(
"failed to open file " + filename);
16 const long int fileSize = file.tellg();
19 throw std::runtime_error(
"file " + filename +
" is empty");
21 std::vector<char> buffer(
static_cast<long unsigned int>(fileSize));
22 file.seekg(0, std::ios::beg);
23 if (!file.read(buffer.data(), fileSize))
25 throw std::runtime_error(
"failed to read file " + filename);
30std::unordered_map<std::string, std::string>
utl::getEnvMap(
const char *
const *env)
32 std::unordered_map<std::string, std::string> cpyEnv;
35 LPCH envStrings = GetEnvironmentStringsA();
41 for (LPCH var = envStrings; *var; var += std::strlen(var) + 1)
43 std::string entry(var);
44 if (
const auto pos = entry.find(
'='); pos != std::string::npos)
46 cpyEnv.emplace(entry.substr(0, pos), entry.substr(pos + 1));
50 FreeEnvironmentStringsA(envStrings);
52 for (
const char *
const *current = env; (current !=
nullptr) && (*current !=
nullptr); ++current)
54 std::string entry(*current);
55 if (
const auto pos = entry.find(
'='); pos != std::string::npos)
57 cpyEnv.emplace(entry.substr(0, pos), entry.substr(pos + 1));