MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / read_binary_file

Function read_binary_file

examples/wasip1/main.cc:20–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18using namespace wasmtime;
19
20static std::vector<uint8_t> read_binary_file(const char *path) {
21 std::ifstream file(path, std::ios::in | std::ios::binary);
22 if (!file.is_open()) {
23 throw std::runtime_error(std::string("failed to open wasm file: ") + path);
24 }
25 std::vector<uint8_t> data((std::istreambuf_iterator<char>(file)),
26 std::istreambuf_iterator<char>());
27 return data;
28}
29
30int main() {
31 // Define the WASI functions globally on the `Config`.

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected