diff options
author | kientzle <kientzle@FreeBSD.org> | 2007-12-30 04:58:22 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2007-12-30 04:58:22 +0000 |
commit | 2b8395148ff378e52a5e00c0d2ac0123258b759b (patch) | |
tree | 743c28601a2502c30676ab2adfbbb665fa3f38b7 /lib/libarchive/archive_write_set_compression_none.c | |
parent | b1a3a611be764b44dbdd47a17ec5076bcfbe6e88 (diff) | |
download | FreeBSD-src-2b8395148ff378e52a5e00c0d2ac0123258b759b.zip FreeBSD-src-2b8395148ff378e52a5e00c0d2ac0123258b759b.tar.gz |
Update libarchive to 2.4.10. This includes a number of improvements
that I've been working on but put off committing until after the
RELENG_7 branch, including:
* New manpages: cpio.5 mtree.5
* New archive_entry_strmode()
* New archive_entry_link_resolver()
* New read support: mtree format
* Internal API change: read format auction only runs once
* Running the auction only once allowed simplifying a lot of bid logic.
* Cpio robustness: search for next header after a sync error
* Support device nodes on ISO9660 images
* Eliminate a lot of unnecessary copies for uncompressed archives
* Corrected handling of new GNU --sparse --posix formats
* Correctly handle a zero-byte write to a compressed archive
* Fixed memory leaks
Many of these improvements were motivated by the upcoming bsdcpio
front-end.
There have also been extensive improvements to the libarchive_test
test harness, which I'll commit separately.
Diffstat (limited to 'lib/libarchive/archive_write_set_compression_none.c')
-rw-r--r-- | lib/libarchive/archive_write_set_compression_none.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/lib/libarchive/archive_write_set_compression_none.c b/lib/libarchive/archive_write_set_compression_none.c index 1fc8f11..36828c2 100644 --- a/lib/libarchive/archive_write_set_compression_none.c +++ b/lib/libarchive/archive_write_set_compression_none.c @@ -151,11 +151,18 @@ archive_compressor_none_write(struct archive_write *a, const void *vbuff, return (ARCHIVE_OK); } - while ((remaining > 0) || (state->avail == 0)) { - /* - * If we have a full output block, write it and reset the - * output buffer. - */ + /* If the copy buffer isn't empty, try to fill it. */ + if (state->avail < state->buffer_size) { + /* If buffer is not empty... */ + /* ... copy data into buffer ... */ + to_copy = (remaining > state->avail) ? + state->avail : remaining; + memcpy(state->next, buff, to_copy); + state->next += to_copy; + state->avail -= to_copy; + buff += to_copy; + remaining -= to_copy; + /* ... if it's full, write it out. */ if (state->avail == 0) { bytes_written = (a->client_writer)(&a->archive, a->client_data, state->buffer, state->buffer_size); @@ -166,16 +173,26 @@ archive_compressor_none_write(struct archive_write *a, const void *vbuff, state->next = state->buffer; state->avail = state->buffer_size; } + } - /* Now we have space in the buffer; copy new data into it. */ - to_copy = (remaining > state->avail) ? - state->avail : remaining; - memcpy(state->next, buff, to_copy); - state->next += to_copy; - state->avail -= to_copy; - buff += to_copy; - remaining -= to_copy; + while (remaining > state->buffer_size) { + /* Write out full blocks directly to client. */ + bytes_written = (a->client_writer)(&a->archive, + a->client_data, buff, state->buffer_size); + if (bytes_written <= 0) + return (ARCHIVE_FATAL); + a->archive.raw_position += bytes_written; + buff += bytes_written; + remaining -= bytes_written; } + + if (remaining > 0) { + /* Copy last bit into copy buffer. */ + memcpy(state->next, buff, remaining); + state->next += remaining; + state->avail -= remaining; + } + a->archive.file_position += length; return (ARCHIVE_OK); } |