| 357 | } |
| 358 | |
| 359 | std::string to_string() { |
| 360 | fseek(file, 0, SEEK_END); |
| 361 | const size_t size = ftell(file); |
| 362 | fseek(file, 0, SEEK_SET); |
| 363 | std::string out; |
| 364 | out.resize(size); |
| 365 | const size_t read_size = fread(&out[0], 1, size, file); |
| 366 | if (read_size != size) { |
| 367 | printe("Error reading file: %s", strerror(errno)); |
| 368 | } |
| 369 | |
| 370 | return out; |
| 371 | } |
| 372 | |
| 373 | ~File() { |
| 374 | if (fd >= 0) { |
no test coverage detected