| 64 | } |
| 65 | |
| 66 | auto ReadFileAsString(std::string_view path) -> std::string { |
| 67 | constexpr auto read_size = std::size_t(65536); |
| 68 | auto stream = std::ifstream(path.data()); |
| 69 | stream.exceptions(std::ios_base::badbit); |
| 70 | |
| 71 | if (!stream) { |
| 72 | throw std::ios_base::failure("file does not exist"); |
| 73 | } |
| 74 | |
| 75 | auto out = std::string(); |
| 76 | auto buf = std::string(read_size, '\0'); |
| 77 | while (stream.read(&buf[0], read_size)) { |
| 78 | out.append(buf, 0, stream.gcount()); |
| 79 | } |
| 80 | out.append(buf, 0, stream.gcount()); |
| 81 | return out; |
| 82 | } |
| 83 | |
| 84 | static ByteArray ReadFileData(const std::string& file) { |
| 85 |
no test coverage detected