MCPcopy Create free account
hub / github.com/F-Stack/f-stack / saveFile_orDie

Function saveFile_orDie

freebsd/contrib/zstd/examples/common.h:220–232  ·  view source on GitHub ↗

! 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. */

Source from the content-addressed store, hash-verified

218 * cannot write to a given file.
219 */
220static 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

Callers 3

compressFile_orDieFunction · 0.85
compress_orDieFunction · 0.85
compressFunction · 0.85

Calls 1

fopen_orDieFunction · 0.85

Tested by

no test coverage detected