| 33 | namespace { |
| 34 | |
| 35 | std::vector<uint8_t> ReadFile(const std::string& path) { |
| 36 | ABSL_CHECK(!path.empty()) << "--in is required"; |
| 37 | std::ifstream file(path, std::ifstream::binary); |
| 38 | ABSL_CHECK(file.is_open()) << path; |
| 39 | file.seekg(0, file.end); |
| 40 | ABSL_CHECK(file.good()); |
| 41 | size_t size = static_cast<size_t>(file.tellg()); |
| 42 | file.seekg(0, file.beg); |
| 43 | ABSL_CHECK(file.good()); |
| 44 | std::vector<uint8_t> buffer; |
| 45 | buffer.resize(size); |
| 46 | file.read(reinterpret_cast<char*>(buffer.data()), size); |
| 47 | ABSL_CHECK(file.good()); |
| 48 | return buffer; |
| 49 | } |
| 50 | |
| 51 | void WriteFile(const std::string& path, absl::Span<const char> data) { |
| 52 | ABSL_CHECK(!path.empty()) << "--out is required"; |