MCPcopy Create free account
hub / github.com/Xtra-Computing/thundersvm / getEnvironmentVariable

Method getEnvironmentVariable

src/thundersvm/util/log.cpp:1014–1036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1012 }
1013
1014 std::string OS::getEnvironmentVariable(const char* variableName, const char* defaultVal,
1015 const char* alternativeBashCommand) {
1016#if ELPP_OS_UNIX
1017 const char* val = getenv(variableName);
1018#elif ELPP_OS_WINDOWS
1019 const char* val = getWindowsEnvironmentVariable(variableName);
1020#endif // ELPP_OS_UNIX
1021 if ((val == nullptr) || ((strcmp(val, "") == 0))) {
1022#if ELPP_OS_UNIX && defined(ELPP_FORCE_ENV_VAR_FROM_BASH)
1023 // Try harder on unix-based systems
1024 std::string valBash = base::utils::OS::getBashOutput(alternativeBashCommand);
1025 if (valBash.empty()) {
1026 return std::string(defaultVal);
1027 } else {
1028 return valBash;
1029 }
1030#elif ELPP_OS_WINDOWS || ELPP_OS_UNIX
1031 ELPP_UNUSED(alternativeBashCommand);
1032 return std::string(defaultVal);
1033#endif // ELPP_OS_UNIX && defined(ELPP_FORCE_ENV_VAR_FROM_BASH)
1034 }
1035 return std::string(val);
1036 }
1037
1038 std::string OS::currentUser(void) {
1039#if ELPP_OS_UNIX && !ELPP_OS_ANDROID

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected