Пример #1
0
void write_short(FileHandle& fh, uint16_t value) {
  auto bytes_written = fh.fwrite(&value, sizeof(value), 1) * sizeof(value);
  if (bytes_written != sizeof(value)) {
    fprintf(stderr, "fwrite wrote %zd, not %zd\n", bytes_written,
            sizeof(value));
  }
  CHECK(bytes_written == sizeof(value));
}
Пример #2
0
void write_str(FileHandle& fh, const std::string& str) {
  const auto len = str.size();
  CHECK(fh.fwrite(str.c_str(), sizeof(char), len) == len);
}