| 69 | } |
| 70 | |
| 71 | fory::Result<void, fory::Error> WriteFile(const std::string &path, |
| 72 | const std::vector<uint8_t> &data) { |
| 73 | std::ofstream output(path, std::ios::binary | std::ios::trunc); |
| 74 | if (FORY_PREDICT_FALSE(!output)) { |
| 75 | return fory::Unexpected( |
| 76 | fory::Error::invalid("failed to open data file for writing")); |
| 77 | } |
| 78 | output.write(reinterpret_cast<const char *>(data.data()), |
| 79 | static_cast<std::streamsize>(data.size())); |
| 80 | if (FORY_PREDICT_FALSE(!output)) { |
| 81 | return fory::Unexpected(fory::Error::invalid("failed to write data file")); |
| 82 | } |
| 83 | return fory::Result<void, fory::Error>(); |
| 84 | } |
| 85 | |
| 86 | template <typename T> std::string VectorDebugString(const std::vector<T> &v) { |
| 87 | std::ostringstream out; |
no test coverage detected