Moved exec function in to logging.h

pull/234/head
FlightlessMango 4 years ago
parent 441f1d3f3f
commit f14c9a7587

@ -27,6 +27,28 @@ int num;
bool loggingOn;
uint64_t log_start, log_end;
string exec(string command) {
char buffer[128];
string result = "";
// Open pipe to file
FILE* pipe = popen(command.c_str(), "r");
if (!pipe) {
return "popen failed!";
}
// read till end of process:
while (!feof(pipe)) {
// use buffer to read and add to result
if (fgets(buffer, 128, pipe) != NULL)
result += buffer;
}
pclose(pipe);
return result;
}
void writeFile(string filename){
out.open(filename, ios::out | ios::app);
out << "os," << "cpu," << "gpu," << "ram," << "kernel," << "driver" << endl;

@ -520,28 +520,6 @@ struct overlay_draw *get_overlay_draw(struct swapchain_data *data)
return draw;
}
string exec(string command) {
char buffer[128];
string result = "";
// Open pipe to file
FILE* pipe = popen(command.c_str(), "r");
if (!pipe) {
return "popen failed!";
}
// read till end of process:
while (!feof(pipe)) {
// use buffer to read and add to result
if (fgets(buffer, 128, pipe) != NULL)
result += buffer;
}
pclose(pipe);
return result;
}
void init_cpu_stats(overlay_params& params)
{
auto& enabled = params.enabled;

Loading…
Cancel
Save