Helper function to execute a shell command and return the output
| 37 | #include "wb_link.h" |
| 38 | // Helper function to execute a shell command and return the output |
| 39 | std::string exec(const std::string& cmd) { |
| 40 | std::array<char, 128> buffer; |
| 41 | std::string result; |
| 42 | std::shared_ptr<FILE> pipe(popen(cmd.c_str(), "r"), pclose); |
| 43 | if (!pipe) { |
| 44 | throw std::runtime_error("popen() failed!"); |
| 45 | } |
| 46 | while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { |
| 47 | result += buffer.data(); |
| 48 | } |
| 49 | return result; |
| 50 | } |
| 51 | |
| 52 | // Helper function to check if a Microhard device is present |
| 53 | bool is_microhard_device_present() { |
no test coverage detected