| 557 | #endif |
| 558 | |
| 559 | static ssize_t |
| 560 | tar_write(Walfile f, const void *buf, size_t count) |
| 561 | { |
| 562 | ssize_t r; |
| 563 | |
| 564 | Assert(f != NULL); |
| 565 | tar_clear_error(); |
| 566 | |
| 567 | /* Tarfile will always be positioned at the end */ |
| 568 | if (!tar_data->compression) |
| 569 | { |
| 570 | errno = 0; |
| 571 | r = write(tar_data->fd, buf, count); |
| 572 | if (r != count) |
| 573 | { |
| 574 | /* If write didn't set errno, assume problem is no disk space */ |
| 575 | tar_data->lasterrno = errno ? errno : ENOSPC; |
| 576 | return -1; |
| 577 | } |
| 578 | ((TarMethodFile *) f)->currpos += r; |
| 579 | return r; |
| 580 | } |
| 581 | #ifdef HAVE_LIBZ |
| 582 | else |
| 583 | { |
| 584 | if (!tar_write_compressed_data(unconstify(void *, buf), count, false)) |
| 585 | return -1; |
| 586 | ((TarMethodFile *) f)->currpos += count; |
| 587 | return count; |
| 588 | } |
| 589 | #else |
| 590 | else |
| 591 | { |
| 592 | /* Can't happen - compression enabled with no libz */ |
| 593 | tar_data->lasterrno = ENOSYS; |
| 594 | return -1; |
| 595 | } |
| 596 | #endif |
| 597 | } |
| 598 | |
| 599 | static bool |
| 600 | tar_write_padding_data(TarMethodFile *f, size_t bytes) |
no test coverage detected