szaszm commented on code in PR #1895:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1895#discussion_r1992012051
##########
utils/src/utils/Environment.cpp:
##########
@@ -123,4 +130,47 @@ bool Environment::isRunningAsService() {
return runningAsService;
}
+std::unordered_map<std::string, std::string>
Environment::getEnvironmentVariables() {
+ std::unordered_map<std::string, std::string> env_var_map;
+
+ Environment::accessEnvironment([&env_var_map](){
+#ifdef WIN32
+ LPWCH env_strings = GetEnvironmentStringsW();
+ if (!env_strings) {
+ return;
+ }
+
+ LPWCH env = env_strings;
+
+ while (*env) {
+ std::wstring wstring_variable_key_value_pair(env);
+
+ int size_needed = WideCharToMultiByte(CP_UTF8, 0,
wstring_variable_key_value_pair.c_str(), -1, nullptr, 0, nullptr, nullptr);
+ std::vector<char> buffer(size_needed);
+ WideCharToMultiByte(CP_UTF8, 0, wstring_variable_key_value_pair.c_str(),
-1, buffer.data(), size_needed, nullptr, nullptr);
+
+ std::string variable_key_value_pair(buffer.data(), size_needed - 1);
Review Comment:
it only seems to work on windows :/ (see build error)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]