| 61 | #define BUFFER_SIZE 2048 |
| 62 | |
| 63 | void readFile(std::string_view path) |
| 64 | { |
| 65 | constexpr auto read_size = std::size_t(BUFFER_SIZE); |
| 66 | auto stream = std::ifstream(path.data()); |
| 67 | stream.exceptions(std::ios_base::badbit); |
| 68 | |
| 69 | if (not stream) |
| 70 | { |
| 71 | std::cerr << "CPP_ERROR_CANNOT_OPEN_FILE " << path << "\n"; |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | auto out = std::string(); |
| 76 | auto buf = std::string(read_size, '\0'); |
| 77 | while (stream.read(&buf[0], read_size)) |
| 78 | { |
| 79 | out.append(buf, 0, stream.gcount()); |
| 80 | } |
| 81 | out.append(buf, 0, stream.gcount()); |
| 82 | |
| 83 | log(out); |
| 84 | } |
no test coverage detected