ARCHIVE_READ_HEADER(3)

πŸ“¦
version 3.8.11 Β· 2 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, freebsd 14.5, freebsd 15.1, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ARCHIVE_READ_HEADER πŸ’–

okay bestie, welcome to archive_read_next_header(3) β€” the libarchive page that's literally just two functions for reading streaming archives. no cap, this is the manual for the Streaming Archive Library (that's libarchive, and you link it with -larchive 🫢).


✨ SYNOPSIS ✨

#include <archive.h>

int
archive_read_next_header(struct archive *, struct archive_entry **);

int
archive_read_next_header2(struct archive *, struct archive_entry *);

🌸 DESCRIPTION 🌸

so there's these two functions and they're basically sisters, okay? let me introduce you πŸ’…

  • archive_read_next_header() β€” this one reads the header for the next entry and hands you back a pointer to a struct archive_entry. and the way it does that is so cute: it's a convenience wrapper around archive_read_next_header2(), and it reuses one internal struct archive_entry object for every single request. iconic behaviour honestly. πŸŽ€
  • archive_read_next_header2() β€” this one reads the header for the next entry too, but instead of handing you back a pointer, it populates the struct archive_entry that you provided. you brought your own entry, she fills it in. main character energy ✨

πŸ‘‘ RETURN VALUES πŸ‘‘

these functions are not shy, they will tell you exactly what happened:

  • ARCHIVE_OK β€” slay, the operation succeeded πŸ’–
  • ARCHIVE_WARN β€” the operation succeeded BUT a non-critical error was encountered. so like, it worked, but she's a little messy πŸ™ˆ
  • ARCHIVE_EOF β€” end-of-archive was encountered. that's it, that's the whole archive, we're done here πŸ¦‹
  • ARCHIVE_RETRY β€” the operation failed but can be retried. not over yet bestie, run it back πŸ”₯
  • ARCHIVE_FATAL β€” there was a fatal error and the archive should be closed immediately. no seriously. close it. right now. πŸ˜­πŸ’€

πŸŽ€ ERRORS πŸŽ€

want the juicy details? the detailed error codes and textual descriptions are available from the archive_errno() and archive_error_string() functions. go ask them, they'll spill everything ✨


🌈 SEE ALSO 🌈

the whole friend group, fr fr:

tar(1), archive_read(3), archive_read_data(3), archive_read_extract(3), archive_read_filter(3), archive_read_format(3), archive_read_open(3), archive_read_set_options(3), archive_util(3), libarchive(3), tar(5)


and that's the page!! this one came from Debian, dated February 2, 2012 β€” vintage but still serving πŸ’… go read some headers bestie, you got this πŸ«ΆπŸ’–βœ¨
πŸ“¦ where this page comes from