ARCHIVE_READ_FORMAT(3)
β¨ 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_7ziparchive_read_support_format_allarchive_read_support_format_ararchive_read_support_format_by_codearchive_read_support_format_cabarchive_read_support_format_cpioarchive_read_support_format_emptyarchive_read_support_format_iso9660archive_read_support_format_lhaarchive_read_support_format_mtreearchive_read_support_format_rararchive_read_support_format_rar5archive_read_support_format_rawarchive_read_support_format_tararchive_read_support_format_warcarchive_read_support_format_xararchive_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: usearchive_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 byarchive_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 π₯
tar(1)archive_read_data(3)archive_read_filter(3)archive_read_set_options(3)archive_util(3)libarchive(3)tar(5)
π 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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- 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