barretenberg
Loading...
Searching...
No Matches
exec_pipe.hpp
1#pragma once
2#include <cstdint>
3#include <cstdio>
4#include <iostream>
5#include <vector>
6
7inline std::vector<uint8_t> exec_pipe(std::string const& command)
8{
9 FILE* pipe = popen(command.c_str(), "r");
10 if (!pipe) {
11 throw std::runtime_error("popen() failed!");
12 }
13
14 std::vector<uint8_t> result;
15 while (!feof(pipe)) {
16 uint8_t buffer[128];
17 size_t count = fread(buffer, 1, sizeof(buffer), pipe);
18 result.insert(result.end(), buffer, buffer + count);
19 }
20
21 pclose(pipe);
22 return result;
23}