MCPcopy Create free account
hub / github.com/adobe/hyde / exec

Function exec

sources/autodetect.cpp:94–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92/**************************************************************************************************/
93
94std::string exec(const char* cmd) {
95 struct pclose_t {
96 void operator()(std::FILE* p) const { (void)pclose(p); }
97 };
98 std::unique_ptr<std::FILE, pclose_t> pipe{popen(cmd, "r")};
99
100 if (!pipe) {
101 throw std::runtime_error("popen() failed!");
102 }
103
104 std::array<char, 128> buffer;
105 std::string result;
106 while (fgets(buffer.data(), buffer.size(), pipe.get())) {
107 result += buffer.data();
108 }
109
110 return chomp(std::move(result));
111}
112
113/**************************************************************************************************/
114

Callers 2

Calls 1

chompFunction · 0.70

Tested by

no test coverage detected