| 6620 | auto to_microseconds(auto duration) { return std::chrono::duration_cast<std::chrono::microseconds>(duration); } |
| 6621 | |
| 6622 | std::string execute_system_call(std::string const &command) { |
| 6623 | std::array<char, 1024> buffer {}; |
| 6624 | std::string result; |
| 6625 | if (FILE *pipe = popen(command.c_str(), "r")) { |
| 6626 | while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe)) result += buffer.data(); |
| 6627 | pclose(pipe); |
| 6628 | } |
| 6629 | return result; |
| 6630 | } |
| 6631 | |
| 6632 | std::string raise_system_error(std::string const &message) { |
| 6633 | std::string error_message = message + ": " + std::strerror(errno) + " (" + std::to_string(errno) + ")"; |