! fread_orDie() : * * Read sizeToRead bytes from a given file, storing them at the * location given by buffer. * * @return The number of bytes read. */
| 124 | * @return The number of bytes read. |
| 125 | */ |
| 126 | static size_t fread_orDie(void* buffer, size_t sizeToRead, FILE* file) |
| 127 | { |
| 128 | size_t const readSize = fread(buffer, 1, sizeToRead, file); |
| 129 | if (readSize == sizeToRead) return readSize; /* good */ |
| 130 | if (feof(file)) return readSize; /* good, reached end of file */ |
| 131 | /* error */ |
| 132 | perror("fread"); |
| 133 | exit(ERROR_fread); |
| 134 | } |
| 135 | |
| 136 | /*! fwrite_orDie() : |
| 137 | * |
no outgoing calls
no test coverage detected