MCPcopy Create free account
hub / github.com/clementgallet/libTAS / queryCmd

Function queryCmd

src/program/utils.cpp:134–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134std::string queryCmd(std::string_view cmd, int* status)
135{
136 std::string outputstr;
137 std::string cmd_str(cmd); // Convert string_view to std::string for popen
138 FILE *output = popen(cmd_str.c_str(), "r");
139 if (output != NULL) {
140 char buf[256];
141 if (fgets(buf, 256, output) != 0) {
142 outputstr = buf;
143 }
144 int s = pclose(output);
145 if (status) *status = s;
146 }
147
148 /* Trim the value */
149 size_t end = outputstr.find_last_not_of(" \n\r\t\f\v");
150 outputstr = (end == std::string::npos) ? "" : outputstr.substr(0, end + 1);
151 return outputstr;
152}
153
154std::string queryCmdPid(const char **command, pid_t* popen_pid)
155{

Callers 7

initMethod · 0.85
build_arg_listMethod · 0.85
game_librariesMethod · 0.85
game_engineMethod · 0.85
extractBinaryTypeFunction · 0.85
extractMacOSExecutableFunction · 0.85
checkArchTypeMethod · 0.85

Calls 3

find_last_not_ofMethod · 0.80
substrMethod · 0.80
c_strMethod · 0.45

Tested by

no test coverage detected