ARCHIVE_READ_FORMAT(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

✨ ARCHIVE_READ_FORMAT(3) ✨

okay bestie, welcome to archive_read_format(3) from the Library Functions Manual β€” it's the streaming archive library's whole format-support era and honestly? it ate πŸ’…

libarchive girlies, this one's for you 🫢


🌸 NAME 🌸

so basically, this page is all about the functions for reading streaming archives. there's a whole squad of them, and here's every single one, no cap:

  • archive_read_support_format_7zip
  • archive_read_support_format_all
  • archive_read_support_format_ar
  • archive_read_support_format_by_code
  • archive_read_support_format_cab
  • archive_read_support_format_cpio
  • archive_read_support_format_empty
  • archive_read_support_format_iso9660
  • archive_read_support_format_lha
  • archive_read_support_format_mtree
  • archive_read_support_format_rar
  • archive_read_support_format_rar5
  • archive_read_support_format_raw
  • archive_read_support_format_tar
  • archive_read_support_format_warc
  • archive_read_support_format_xar
  • archive_read_support_format_zip

πŸŽ€ LIBRARY πŸŽ€

Streaming Archive Library (libarchive, -larchive) β€” yeah, that's the one, the icon herself πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <archive.h>

int
archive_read_support_format_7zip(struct archive *);

int
archive_read_support_format_all(struct archive *);

int
archive_read_support_format_ar(struct archive *);

int
archive_read_support_format_by_code(struct archive *, int);

int
archive_read_support_format_cab(struct archive *);

int
archive_read_support_format_cpio(struct archive *);

int
archive_read_support_format_empty(struct archive *);

int
archive_read_support_format_iso9660(struct archive *);

int
archive_read_support_format_lha(struct archive *);

int
archive_read_support_format_mtree(struct archive *);

int
archive_read_support_format_rar(struct archive *);

int
archive_read_support_format_rar5(struct archive *);

int
archive_read_support_format_raw(struct archive *);

int
archive_read_support_format_tar(struct archive *);

int
archive_read_support_format_warc(struct archive *);

int
archive_read_support_format_xar(struct archive *);

int
archive_read_support_format_zip(struct archive *);

πŸ’– DESCRIPTION πŸ’–

okay so this is the part where it gets juicy. listen up πŸ“’

🌈 the format-enabler girlies 🌈

these ones all do the same iconic thing β€” they enable support, including auto-detection code, for the archive format in question:

  • archive_read_support_format_7zip()
  • archive_read_support_format_ar()
  • archive_read_support_format_cab()
  • archive_read_support_format_cpio()
  • archive_read_support_format_iso9660()
  • archive_read_support_format_lha()
  • archive_read_support_format_mtree()
  • archive_read_support_format_rar()
  • archive_read_support_format_rar5()
  • archive_read_support_format_raw()
  • archive_read_support_format_tar()
  • archive_read_support_format_warc()
  • archive_read_support_format_xar()
  • archive_read_support_format_zip()

like, for example, archive_read_support_format_tar() enables support for a variety of standard tar formats, old-style tar, ustar, pax interchange format, and many common variants. she's versatile, she contains multitudes ✨

and archive_read_support_format_zip() enables support for both the streaming and the seeking zip readers, which can separately be enabled by respectively archive_read_support_format_zip_streamable() and archive_read_support_format_zip_seekable() β€” yes, two whole zip moods, pick your fighter πŸŽ€

🌟 the special ones 🌟

  • archive_read_support_format_all() β€” enables support for all available formats except the "raw" format (see below, bestie, don't skip it).
  • archive_read_support_format_by_code() β€” enables a single format specified by the format code. this one's lowkey useful when you're reading a single archive twice: use archive_format() after reading the first time and pass the resulting code to this function to selectively enable only the necessary format support.
⚠️ Note: in statically-linked executables, this will cause your program to include support for every format. if executable size is a concern, you may wish to avoid using this function. it's giving "small price to pay, huge binary to carry" πŸ’€
  • archive_read_support_format_empty() β€” enables support for treating empty files as empty archives. because empty files are valid for several different formats, it is not possible to accurately determine a format for an empty file based purely on contents. so empty files are treated by libarchive as a distinct format. she gets her own category, main character energy fr πŸ’…
  • archive_read_support_format_raw() β€” the "raw" format handler allows libarchive to be used to read arbitrary data. it treats any data stream as an archive with a single entry. the pathname of this entry is "data"; all other entry fields are unset. this is not enabled by archive_read_support_format_all() in order to avoid erroneous handling of damaged archives. so if you want her, you gotta ask for her directly 🫢

⭐ RETURN VALUES ⭐

these functions return ARCHIVE_OK on success, or ARCHIVE_FATAL. that's it, that's the vibe check 🌈

πŸ“ ERRORS πŸ“

detailed error codes and textual descriptions are available from the archive_errno() and archive_error_string() functions. go read them if something's giving unhinged 😭

πŸ”₯ SEE ALSO πŸ”₯

πŸ’€ BUGS πŸ’€

many traditional archiver programs treat empty files as valid empty archives. for example, many implementations of tar(1) allow you to append entries to an empty file. of course, it is impossible to determine the format of an empty file by inspecting the contents, so this library treats empty files as having a special "empty" format. it's giving "we made a whole format because we literally cannot tell" πŸ™ˆ

using the "raw" handler together with any other handler will often work but can produce surprising results. so like... proceed with caution, bestie, and maybe don't do that unless you know exactly what you're doing πŸ’œ


k that's the whole page!! this beauty came from Debian, dated February 2, 2012, and she's still serving ARCHIVE_READ_FORMAT(3) realness to this very day ✨ mwah, slay, go read some archives πŸŽ€πŸ’…πŸ¦‹

πŸ“¦ where this page comes from