1 LIBARCHIVE(3) manual page
4 - functions for reading and writing streaming archives
8 library provides a flexible interface for reading and writing
9 archives in various formats such as tar and cpio.
11 also supports reading and writing archives compressed using
12 various compression filters such as gzip and bzip2.
13 The library is inherently stream-oriented; readers serially iterate through
14 the archive, writers serially add things to the archive.
15 In particular, note that there is currently no built-in support for
16 random access nor for in-place modification.
18 When reading an archive, the library automatically detects the
19 format and the compression.
20 The library currently has read support for:
23 old-style tar archives,
25 most variants of the POSIX
33 GNU-format tar archives,
35 most common cpio archive formats,
37 ISO9660 CD images (including RockRidge and Joliet extensions),
41 ar archives (including GNU/SysV and BSD extensions),
43 Microsoft CAB archives,
47 mtree file tree descriptions,
53 The library automatically detects archives compressed with
54 [[gzip(1)|http://www.freebsd.org/cgi/man.cgi?query=gzip&sektion=1]],
55 [[bzip2(1)|http://www.freebsd.org/cgi/man.cgi?query=bzip2&sektion=1]],
56 [[xz(1)|http://www.freebsd.org/cgi/man.cgi?query=xz&sektion=1]],
57 [[lzip(1)|http://www.freebsd.org/cgi/man.cgi?query=lzip&sektion=1]],
59 [[compress(1)|http://www.freebsd.org/cgi/man.cgi?query=compress&sektion=1]]
60 and decompresses them transparently.
61 It can similarly detect and decode archives processed with
62 [[uuencode(1)|http://www.freebsd.org/cgi/man.cgi?query=uuencode&sektion=1]]
64 [[rpm(1)|http://www.freebsd.org/cgi/man.cgi?query=rpm&sektion=1]]
67 When writing an archive, you can specify the compression
68 to be used and the format to use.
77 "pax interchange format"
80 POSIX octet-oriented cpio archives,
84 two different variants of shar archives,
92 mtree file tree descriptions,
96 Pax interchange format is an extension of the tar archive format that
97 eliminates essentially all of the limitations of historic tar formats
98 in a standard fashion that is supported
100 [[pax(1)|http://www.freebsd.org/cgi/man.cgi?query=pax&sektion=1]]
101 implementations on many systems as well as several newer implementations of
103 Note that the default write format will suppress the pax extended
104 attributes for most entries; explicitly requesting pax format will
105 enable those attributes for all entries.
107 The read and write APIs are accessed through the
108 '''archive_read_XXX'''()
110 '''archive_write_XXX'''()
111 functions, respectively, and either can be used independently
114 The rest of this manual page provides an overview of the library
116 More detailed information can be found in the individual manual
117 pages for each API or utility function.
118 == READING AN ARCHIVE ==
120 [[ManPagerchiveead3]].
121 == WRITING AN ARCHIVE ==
123 [[ManPagerchiverite3]].
124 == WRITING ENTRIES TO DISK ==
126 [[ManPagerchiveriteisk3]]
127 API allows you to write
128 [[ManPagerchiventry3]]
129 objects to disk using the same API used by
130 [[ManPagerchiverite3]].
132 [[ManPagerchiveriteisk3]]
133 API is used internally by
134 '''archive_read_extract'''('';'')
135 using it directly can provide greater control over how entries
137 This API also makes it possible to share code between
138 archive-to-archive copy and archive-to-disk extraction
140 == READING ENTRIES FROM DISK ==
142 [[ManPagerchiveeadisk3]]
143 supports for populating
144 [[ManPagerchiventry3]]
145 objects from information in the filesystem.
146 This includes the information accessible from the
147 [[stat(2)|http://www.freebsd.org/cgi/man.cgi?query=stat&sektion=2]]
148 system call as well as ACLs, extended attributes,
151 [[ManPagerchiveeadisk3]]
152 API also supports iterating over directory trees,
153 which allows directories of files to be read using
154 an API compatible with
156 [[ManPagerchiveead3]]
159 Detailed descriptions of each function are provided by the
160 corresponding manual pages.
162 All of the functions utilize an opaque
164 datatype that provides access to the archive contents.
167 '''struct archive_entry'''
168 structure contains a complete description of a single archive
170 It uses an opaque interface that is fully documented in
171 [[ManPagerchiventry3]].
173 Users familiar with historic formats should be aware that the newer
174 variants have eliminated most restrictions on the length of textual fields.
175 Clients should not assume that filenames, link names, user names, or
176 group names are limited in length.
177 In particular, pax interchange format can easily accommodate pathnames
178 in arbitrary character sets that exceed
181 Most functions return
183 (zero) on success, non-zero on error.
184 The return value indicates the general severity of the error, ranging
187 which indicates a minor problem that should probably be reported
190 which indicates a serious problem that will prevent any further
191 operations on this archive.
193 '''archive_errno'''()
194 function can be used to retrieve a numeric error code (see
195 [[errno(2)|http://www.freebsd.org/cgi/man.cgi?query=errno&sektion=2]]).
197 '''archive_error_string'''()
198 returns a textual error message suitable for display.
200 '''archive_read_new'''()
202 '''archive_write_new'''()
203 return pointers to an allocated and initialized
207 '''archive_read_data'''()
209 '''archive_write_data'''()
210 return a count of the number of bytes actually read or written.
211 A value of zero indicates the end of the data for this entry.
212 A negative value indicates an error, in which case the
213 '''archive_errno'''()
215 '''archive_error_string'''()
216 functions can be used to obtain more information.
218 There are character set conversions within the
219 [[ManPagerchiventry3]]
220 functions that are impacted by the currently-selected locale.
223 [[ManPagerchiventry3]],
224 [[ManPagerchiveead3]],
225 [[ManPagerchivetil3]],
226 [[ManPagerchiverite3]],
231 library first appeared in
236 library was originally written by
237 Tim Kientzle <kientzle@acm.org.>
239 Some archive formats support information that is not supported by
240 '''struct archive_entry .'''
241 Such information cannot be fully archived or restored using this library.
242 This includes, for example, comments, character sets,
243 or the arbitrary key/value pairs that can appear in
244 pax interchange format archives.
246 Conversely, of course, not all of the information that can be
248 '''struct archive_entry'''
249 is supported by all formats.
250 For example, cpio formats do not support nanosecond timestamps;
251 old tar formats do not support large device numbers.
253 The ISO9660 reader cannot yet read all ISO9660 images;
254 it should learn how to seek.
256 The AR writer requires the client program to use
257 two passes, unlike all other libarchive writers.