Enables auto-detection code and decompression support for the specified compression. Note that "none" is always enabled by default. For convenience, archive_read_support_compression_all enables all available decompression code.
Enables support---including auto-detection code---for the specified archive format. 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. For convenience, archive_read_support_format_all enables support for all available formats. Note that there is no default.
Freeze the settings, open the archive, and prepare for reading entries. This is the most generic version of this call, which accepts three callback functions. Most clients will want to use archive_read_open_file or archive_read_open_fd instead. The library invokes the client-provided functions to obtain raw bytes from the archive. Note: The API permits a decompression method to fork and invoke the callbacks from another process. Although none of the current decompression methods use this technique, future decompression methods may utilize this technique. If the decompressor forks, it will ensure that the open and close callbacks are invoked within the same process as the read callback. In particular, clients should not attempt to use shared variables to communicate between the open/read/close callbacks and the mainline code.
Like archive_read_open, except that it accepts a file descriptor and block size rather than a trio of function pointers. Note that the file descriptor will not be automatically closed at end-of-archive.
Like archive_read_open, except that it accepts a simple filename and a block size. A NULL filename represents standard input.
Read the header for the next entry and return a pointer to a struct archive_entry.
Read data associated with the header just read. Internally, this is a convenience function that calls archive_read_data_block and fills any gaps with nulls so that callers see a single continuous stream of data.
Return the next available block of data for this entry. Unlike archive_read_data, the archive_read_data_block function avoids copying data and allows you to correctly handle sparse files, as supported by some archive formats. The library guarantees that offsets will increase and that blocks will not overlap. Note that the blocks returned from this function can be much larger than the block size read from disk, due to compression and internal buffer optimizations.
A convenience function that repeatedly calls archive_read_data_block to skip all of the data for this archive entry.
A convenience function that repeatedly calls archive_read_data_block to copy the entire entry into the client-supplied buffer. Note that the client is responsible for sizing the buffer appropriately.
A convenience function that repeatedly calls archive_read_data_block to copy the entire entry to the provided file descriptor.
A convenience function that recreates the specified object on disk and reads the entry data into that object. The filename, permissions, and other critical information are taken from the provided archive_entry object. The flags argument modifies how the object is recreated. It consists of a bitwise OR of one or more of the following values:
The user and group IDs should be set on the restored file. By default, the user and group IDs are not restored.
The permissions (mode bits) should be restored for all objects. By default, permissions are only restored for regular files.
The timestamps (mtime, ctime, and atime) should be restored. By default, they are ignored. Note that restoring of atime is not currently supported.
Existing files on disk will not be overwritten. By default, existing regular files are truncated and overwritten; existing directories will have their permissions updated; other pre-existing objects are unlinked and recreated from scratch.
Existing files on disk will be unlinked and recreated from scratch. By default, existing files are truncated and rewritten, but the file is not recreated. In particular, the default behavior does not break existing hard links.
Attempt to restore ACLs. By default, extended ACLs are ignored.
Attempt to restore extended file flags. By default, file flags are ignored.
Note that not all attributes are set immediately; some attributes are cached in memory and written to disk only when the archive is closed. (For example, read-only directories are initially created writable so that files within those directories can be restored. The final permissions are set when the archive is closed.)
Sets a pointer to a user-defined callback that can be used for updating progress displays during extraction. The progress function will be invoked during the extraction of large regular files. The progress function will be invoked with the pointer provided to this call. Generally, the data pointed to should include a reference to the archive object and the archive_entry object so that various statistics can be retrieved for the progress display.
Complete the archive and invoke the close callback.
Invokes archive_read_close if it was not invoked manually, then release all resources.
Note that the library determines most of the relevant information about the archive by inspection. In particular, it automatically detects gzip(1) or bzip2(1) compression and transparently performs the appropriate decompression. It also automatically detects the archive format.
A complete description of the struct archive and struct archive_entry objects can be found in the overview manual page for libarchive(3).
typedef int archive_open_callback "struct archive *" "void *client_data"
typedef int archive_close_callback "struct archive *" "void *client_data"
The open callback is invoked by archive_open. It should return ARCHIVE_OK if the underlying file or data source is successfully opened. If the open fails, it should call archive_set_error to register an error code and message and return ARCHIVE_FATAL.
The read callback is invoked whenever the library requires raw bytes from the archive. The read callback should read data into a buffer, set the const void **buffer argument to point to the available data, and return a count of the number of bytes available. The library will invoke the read callback again only after it has consumed this data. The library imposes no constraints on the size of the data blocks returned. On end-of-file, the read callback should return zero. On error, the read callback should invoke archive_set_error to register an error code and message and return -1.
The close callback is invoked by archive_close when the archive processing is complete. The callback should return ARCHIVE_OK on success. On failure, the callback should invoke archive_set_error to register an error code and message and return ARCHIVE_FATAL.