MCPcopy Create free account
hub / github.com/OpenPrinting/cups / overwrite_data

Function overwrite_data

scheduler/file.c:408–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406 */
407
408static int /* O - 0 on success, -1 on error */
409overwrite_data(int fd, /* I - File descriptor */
410 const char *buffer, /* I - Buffer to write */
411 int bufsize, /* I - Size of buffer */
412 int filesize) /* I - Size of file */
413{
414 int bytes; /* Bytes to write/written */
415
416
417 /*
418 * Start at the beginning of the file...
419 */
420
421 if (lseek(fd, 0, SEEK_SET) < 0)
422 return (-1);
423
424 /*
425 * Fill the file with the provided data...
426 */
427
428 while (filesize > 0)
429 {
430 if (filesize > bufsize)
431 bytes = bufsize;
432 else
433 bytes = filesize;
434
435 if ((bytes = write(fd, buffer, (size_t)bytes)) < 0)
436 return (-1);
437
438 filesize -= bytes;
439 }
440
441 /*
442 * Force the changes to disk...
443 */
444
445 return (fsync(fd));
446}
447#endif /* HAVE_REMOVEFILE */

Callers 1

cupsdRemoveFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected