#include "IO.hpp" #include "Streams.hpp" #include using namespace std; vector readBytes(const size_t count) { vector bytes(count); size_t readByteCount; do { readByteCount = fread(bytes.data(), 1, count, getHostStream().get()); fwrite(bytes.data(), 1, bytes.size(), getComHostStream().get()); } while (readByteCount == 0); clog << "Read " << readByteCount << " bytes" << endl; if (readByteCount != count) throw runtime_error{ "Failed to read sufficient bytes" }; return bytes; }