MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / exec

Function exec

OpenHD/ohd_interface/src/ohd_interface.cpp:39–50  ·  view source on GitHub ↗

Helper function to execute a shell command and return the output

Source from the content-addressed store, hash-verified

37#include "wb_link.h"
38// Helper function to execute a shell command and return the output
39std::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
53bool is_microhard_device_present() {

Callers 1

Calls 2

sizeMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected