| 985 | #endif // ELPP_OS_ANDROID |
| 986 | |
| 987 | const std::string OS::getBashOutput(const char* command) { |
| 988 | #if (ELPP_OS_UNIX && !ELPP_OS_ANDROID && !ELPP_CYGWIN) |
| 989 | if (command == nullptr) { |
| 990 | return std::string(); |
| 991 | } |
| 992 | FILE* proc = nullptr; |
| 993 | if ((proc = popen(command, "r")) == nullptr) { |
| 994 | ELPP_INTERNAL_ERROR("\nUnable to run command [" << command << "]", true); |
| 995 | return std::string(); |
| 996 | } |
| 997 | char hBuff[4096]; |
| 998 | if (fgets(hBuff, sizeof(hBuff), proc) != nullptr) { |
| 999 | pclose(proc); |
| 1000 | if (hBuff[strlen(hBuff) - 1] == '\n') { |
| 1001 | hBuff[strlen(hBuff) - 1] = '\0'; |
| 1002 | } |
| 1003 | return std::string(hBuff); |
| 1004 | } else { |
| 1005 | pclose(proc); |
| 1006 | } |
| 1007 | return std::string(); |
| 1008 | #else |
| 1009 | ELPP_UNUSED(command); |
| 1010 | return std::string(); |
| 1011 | #endif // (ELPP_OS_UNIX && !ELPP_OS_ANDROID && !ELPP_CYGWIN) |
| 1012 | } |
| 1013 | |
| 1014 | std::string OS::getEnvironmentVariable(const char* variableName, const char* defaultVal, |
| 1015 | const char* alternativeBashCommand) { |
nothing calls this directly
no outgoing calls
no test coverage detected