ARCHIVE_READ_DATA(3)
π ARCHIVE_READ_DATA π
okay bestie, so this is ARCHIVE_READ_DATA(3) β the libarchive streaming-archive-reading girlies. it's from the Library Functions Manual, and it's literally the four functions you need when you want to read data out of a streaming archive. no cap, this is the good stuff.
β¨ NAME β¨
archive_read_data, archive_read_data_block, archive_read_data_skip, archive_read_data_into_fd β functions for reading streaming archives π¦
π LIBRARY π
Streaming Archive Library (libarchive, -larchive) β link it and slay π
πΈ SYNOPSIS πΈ
#include <archive.h>
la_ssize_t
archive_read_data(struct archive *, void *buff, size_t len);
int
archive_read_data_block(struct archive *, const void **buff,
size_t *len, off_t *offset);
int
archive_read_data_skip(struct archive *);
int
archive_read_data_into_fd(struct archive *, int fd);
like, #include <archive.h> first obviously, that's the vibe check π
π DESCRIPTION π
okay so here's the tea on each one, bestie:
archive_read_data()β reads the data associated with the header you just read. internally? it's giving convenience function energy: it callsarchive_read_data_block()and then fills any gaps with nulls so that callers see one single continuous stream of data. smooth. continuous. iconic. β¨archive_read_data_block()β returns the next available block of data for this entry. and the way that it's different fromarchive_read_data()is that it avoids copying data and lets you correctly handle sparse files (as supported by some archive formats). the library guarantees that offsets will increase and that blocks will not overlap β periodt. note that the blocks returned from this function can be much larger than the block size read from disk, because of compression and internal buffer optimizations. so don't be shocked, it's normal πarchive_read_data_skip()β a convenience function that repeatedly callsarchive_read_data_block()to skip all of the data for this archive entry. and lowkey important: this function is invoked automatically byarchive_read_next_header2()if the previous entry was not completely consumed. so it's doing it behind your back, in a helpful way π«Άarchive_read_data_into_fd()β a convenience function that repeatedly callsarchive_read_data_block()to copy the entire entry to the provided file descriptor. easy. clean. main character energy π
β RETURN VALUES β
most functions return zero on success, non-zero on error. the possible return codes include:
ARCHIVE_OKβ the operation succeeded πARCHIVE_WARNβ the operation succeeded but a non-critical error was encountered πARCHIVE_EOFβ end-of-archive was encountered πARCHIVE_RETRYβ the operation failed but can be retried πARCHIVE_FATALβ there was a fatal error; the archive should be closed immediately. like, drop everything. close it. right now. π
and archive_read_data() specifically returns a count of bytes actually read, or zero at the end of the entry. on error, it returns a value of ARCHIVE_FATAL, ARCHIVE_WARN, or ARCHIVE_RETRY.
π ERRORS π
detailed error codes and textual descriptions are available from the archive_errno() and archive_error_string() functions. go read them, they'll tell you what went wrong π
π SEE ALSO π
tar(1)archive_read(3)archive_read_extract(3)archive_read_filter(3)archive_read_format(3)archive_read_header(3)archive_read_open(3)archive_read_set_options(3)archive_util(3)libarchive(3)tar(5)
that's the whole page bestie!! π this one came from Debian and it's dated February 2, 2012 β so like, vintage but still slaying. go read some archives, ily, bye!! πβ¨π¦
π¦ where this page comes from
- arch rolling: libarchive 3.8.9-1
- centos-stream 10: libarchive-devel 3.7.7-11.el10 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- debian trixie: libarchive-dev 3.7.4-4+deb13u1 Β· BSD-2-Clause
- fedora 43: libarchive-devel 3.8.1-3.fc43 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 43: libarchive-devel 3.8.1-3.fc43 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 43: libarchive-devel 3.8.4-1.fc43 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 43: libarchive-devel 3.8.4-1.fc43 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 44: libarchive-devel 3.8.4-2.fc44 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 44: libarchive-devel 3.8.4-2.fc44 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 44: libarchive-devel 3.8.7-1.fc44 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- fedora 44: libarchive-devel 3.8.7-1.fc44 Β· BSD-2-Clause AND FSFULLR AND GPL-2.0-or-later WITH Libtool-exception AND BSD-3-Clause AND FSFUL
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixos 26.05: libarchive 3.8.9
- nixpkgs unstable: libarchive 3.8.9
- opensuse-leap 16.0: libarchive-devel 3.8.1-160000.4.1 Β· BSD-2-Clause
- opensuse-leap 16.0: libarchive-devel 3.8.1-160000.4.1 Β· BSD-2-Clause
- opensuse-leap 16.0: libarchive-devel 3.8.1-160000.4.1 Β· BSD-2-Clause
- opensuse-leap 16.0: libarchive-devel 3.8.1-160000.4.1 Β· BSD-2-Clause
- ubuntu questing: libarchive-dev 3.7.7-0ubuntu3
- ubuntu questing: libarchive-dev 3.7.7-0ubuntu3.2
- ubuntu resolute: libarchive-dev 3.8.5-1ubuntu2 Β· BSD-2-Clause
- ubuntu resolute: libarchive-dev 3.8.5-1ubuntu2.3 Β· BSD-2-Clause
- ubuntu stonking: libarchive-dev 3.8.9-1 Β· BSD-2-Clause
- Copyright (c) 2003-2011 Tim Kientzle
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms