Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
exec_pipe.hpp
Go to the documentation of this file.
1
#pragma once
2
#include "
barretenberg/common/throw_or_abort.hpp
"
3
#include <cstdint>
4
#include <cstdio>
5
#include <cstring>
6
#include <memory>
7
#include <vector>
8
9
namespace
bb
{
10
inline
std::vector<uint8_t>
exec_pipe
([[maybe_unused]]
const
std::string& command)
11
{
12
#ifdef __wasm__
13
throw_or_abort
(
"Can't use popen() in wasm! Implement this functionality natively."
);
14
#else
15
// popen() with "r" captures only stdout; stderr is inherited unchanged.
16
std::unique_ptr<FILE, int (*)(FILE*)> pipe(popen(command.c_str(),
"r"
), pclose);
// NOLINT
17
if
(!pipe) {
18
throw_or_abort
(
"popen() failed: '"
+ command +
"' due to "
+ strerror(errno));
19
}
20
21
std::vector<uint8_t> output;
22
uint8_t
buf
[4096];
// NOLINT
23
24
while
(
size_t
n = fread(
buf
, 1,
sizeof
(
buf
), pipe.get())) {
25
output.insert(output.end(),
buf
,
buf
+ n);
26
}
27
return
output;
28
#endif
29
}
30
}
// namespace bb
buf
uint8_t const * buf
Definition
data_store.hpp:9
bb
Entry point for Barretenberg command-line interface.
Definition
acir_format_getters.cpp:6
bb::exec_pipe
std::vector< uint8_t > exec_pipe(const std::string &command)
Definition
exec_pipe.hpp:10
throw_or_abort.hpp
throw_or_abort
void throw_or_abort(std::string const &err)
Definition
throw_or_abort.hpp:6
src
barretenberg
api
exec_pipe.hpp
Generated by
1.9.8