! saveFile_orDie() : * * Save buffSize bytes to a given file path, obtaining them from a location pointed * to by buff. * * Note: This function will send an error to stderr and exit if it * cannot write to a given file. */
| 218 | * cannot write to a given file. |
| 219 | */ |
| 220 | static void saveFile_orDie(const char* fileName, const void* buff, size_t buffSize) |
| 221 | { |
| 222 | FILE* const oFile = fopen_orDie(fileName, "wb"); |
| 223 | size_t const wSize = fwrite(buff, 1, buffSize, oFile); |
| 224 | if (wSize != (size_t)buffSize) { |
| 225 | fprintf(stderr, "fwrite: %s : %s \n", fileName, strerror(errno)); |
| 226 | exit(ERROR_fwrite); |
| 227 | } |
| 228 | if (fclose(oFile)) { |
| 229 | perror(fileName); |
| 230 | exit(ERROR_fclose); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | #endif |
no test coverage detected