Archive::Libarchive::API - Comprehensive API documentation for Archive::Libarchive
version 0.09
use 5.020; use Archive::Libarchive qw( :const ); my $r = Archive::Libarchive::ArchiveRead->new; $r->support_filter_all; $r->support_format_all; $r->open_filename("archive.tar", 10240) == ARCHIVE_OK or die $r->error_string; my $e = Archive::Libarchive::Entry->new; say $e->pathname while $r->next_header($e) == ARCHIVE_OK;
This document covers comprehensive list of methods and constants provided by Archive::Libarchive classes. The top level document Archive::Libarchive is a better place to start, along with the main documentation pages for each class, as while not comprehensive, do cover in more detail the methods and features that you are most likely to use in practice, and they include examples. This document is intended primarily for reference.
This document includes method signatures for each method provided by the API, but because of the large number of methods, the exact function of all methods is not provided. You can usually get the idea from the method names, or consult the libarchive
documentation. A familiarity with the libarchive
API is therefore helpful.
Because libarchive
contains class name prefixes for its methods to provide a pseudo object oriented interface in C, and because this Perl interface is properly object oriented, the names of all methods have been changed. (Mostly by removing the class prefix, although, some have been modified beyond that because simply removing the class prefix makes some method names confusing). To help you find the equivalent libarchive
documentation, the original libarchive
function names are included in the method usage.
Some methods are marked as (optional)
. These methods were added to libarchive
after the current minimum supported by Archive::Libarchive, and therefore might not be available depending on the version of libarchive
you have installed. If you need your code to work on both old code and to take advantage of these methods on new versions you can use the can
method to see if these methods are available.
If you need one or more of these methods and your system libarchive
is too old, then you can force a share install of Alien::Libarchive3.
env ALIEN_INSTALL_TYPE=share cpanm --reinstall Alien::Libarchive3
# archive_bzlib_version my $string = archive_bzlib_version();
The bzlib
version that libarchive
was built with. This will return undef
if the library was not found at build time.
# archive_liblz4_version my $string = archive_liblz4_version();
The liblz4
version that libarchive
was built with. This will return undef
if the library was not found at build time.
# archive_liblzma_version my $string = archive_liblzma_version();
The liblzma
version that libarchive
was built with. This will return undef
if the library was not found at build time.
# archive_libzstd_version (optional) my $string = archive_libzstd_version();
The zstd
version that libarchive
was built with. This will return undef
if the library was not found at build time.
# archive_version_details my $string = archive_version_details();
Detailed textual name/version of the library and its dependencies. This has the form:
libarchive x.y.z zlib/a.b.c liblzma/d.e.f ... etc ...
the list of libraries described here will vary depending on how libarchive was compiled.
# archive_version_number my $int = archive_version_number();
The libarchive
version expressed as an integer. This will be the major, minor and patch levels each using up to three digits, so 3.5.1 will be 3005001
.
# archive_version_string my $string = archive_version_string();
The libarchive
version as a string.
# archive_zlib_version my $string = archive_zlib_version();
The zlib
version that libarchive
was built with. This will return undef
if the library was not found at build time.
my %versions = Archive::Libarchive->versions();
This returns a hash of libarchive
and Archive::Libarchive versions and dependency versions. This may be useful in a test report diagnostic.
# archive_clear_error $ar->clear_error;
Clear the error for the corresponding archive instance.
# archive_copy_error $ar->copy_error($ar);
# archive_entry_new2 my $e = $ar->entry;
This method creates a new Archive::Libarchive::Entry instance, like when you create an instance with that class' new method, except this form will pull character-set conversion information from the specified archive instance.
# archive_errno my $int = $ar->errno;
Returns the system errno
code for the archive instance. For non-system level errors, this will not have a sensible value.
# archive_error_string my $string = $ar->error_string;
Returns a human readable diagnostic of error for the corresponding archive instance.
# archive_file_count my $int = $ar->file_count;
# archive_filter_bytes my $sint64 = $ar->filter_bytes($int);
# archive_filter_code my $code = $ar->filter_code($num);
This will return the filter code at position $num
. For the total number of positions see the filter_count method.
The constant prefix for this method is ARCHIVE_FILTER_
. This will return a dualvar where the string is the lowercase name without the prefix and the integer is the constant value. For the full list see "CONSTANTS" in Archive::Libarchive::API.
# archive_filter_count my $int = $ar->filter_count;
# archive_filter_name my $string = $ar->filter_name($int);
# archive_format my $code = $ar->format;
This will return the format code at position $num
.
The constant prefix for this method is ARCHIVE_FORMAT_
. This will return a dualvar where the string is the lowercase name without the prefix and the integer is the constant value. For the full list see "CONSTANTS" in Archive::Libarchive::API.
# archive_format_name my $string = $ar->format_name;
# archive_seek_data my $sint64_1 = $ar->seek_data($sint64_2, $int);
# archive_set_error $ar->set_error($errno, $string);
This will set the errno
code and human readable diagnostic for the archive instance. Not all errors have a corresponding errno
code, so you can set that to zero (0
) in that case.
# archive_read_add_passphrase my $int = $r->add_passphrase($string);
# archive_read_append_filter my $int = $r->append_filter($code);
Append filter to manually specify the order in which filters will be applied. This will accept either a string representation of the filter code, or the constant. The constant prefix is ARCHIVE_FILTER_
. So for a gzipped file this would be either 'gzip'
or ARCHIVE_FILTER_GZIP
. For the full list see "CONSTANTS" in Archive::Libarchive::API.
# archive_read_append_filter_program my $int = $r->append_filter_program($string);
# archive_read_append_filter_program_signature my $int = $r->append_filter_program_signature($string, $opaque, $size_t);
# archive_read_close my $int = $r->close;
# archive_read_extract my $int1 = $r->extract($e, $int2);
# archive_read_extract2 my $int = $r->extract2($e, $ar);
# archive_read_extract_set_skip_file $r->extract_set_skip_file($sint64_1, $sint64_2);
# archive_read_format_capabilities my $int = $r->format_capabilities;
# archive_read_has_encrypted_entries my $int = $r->has_encrypted_entries;
# archive_read_header_position my $sint64 = $r->header_position;
# archive_read_new my $r = Archive::Libarchive::ArchiveRead->new;
Create a new archive read object.
# archive_read_next_header my $code = $r->next_header($e);
Returns the next Archive::Libarchive::Entry object.
# archive_read_open1 # archive_read_set_callback_data # archive_read_set_close_callback # archive_read_set_open_callback # archive_read_set_read_callback # archive_read_set_seek_callback # archive_read_set_skip_callback $r->open(%callbacks);
This is a basic open method, which relies on callbacks for its implementation. The only callback that is required is the read
callback. The open
and close
callbacks are made available mostly for the benefit of the caller. The skip
and seek
callbacks are used if available for some formats like zip
to improve performance. All callbacks should return a normal status code, which is ARCHIVE_OK
on success.
Unlike the libarchive
C-API, this interface doesn't provide a facility for passing in "client" data. In Perl this is implemented using a closure, which should allow you to pass in arbitrary variables via proper scoping.
$r->open(open => sub ($r) { ... });
Called immediately when the archive is "opened";
$r->open(read => sub ($r, $ref) { $$ref = ...; ... return $size. });
Called when new data is required. What is passed in is a scalar reference. You should set this scalar to the next block of data. On success you should return the size of the data in bytes, and on failure return a normal status code.
$r->open(seek => sub ($r, $offset, $whence) { ... });
Called to seek to the new location. The $offset
and $whence
arguments work exactly like the libc
fseek
function.
$r->open(skip => sub ($r, $request) { ... });
Called to skip the next $request
bytes. Should return the actual number of bytes skipped on success (which can be less than or equal to $request
), and on failure return a normal status code.
$r->open(close => sub ($r) { ... });
This is called when the archive instance is closed.
$r->open_FILE($file_pointer);
This takes either a FFI::C::File, or an opaque pointer to a libc file pointer.
# archive_read_open_fd my $int1 = $r->open_fd($int2, $size_t);
# archive_read_open_filename my $int = $r->open_filename($string, $size_t);
Open a single-file archive. The $size_t
argument is the block size.
# archive_read_open_filename my $int = $r->open_filename($string, $size_t);
# archive_read_open_filename_w my $int = $r->open_filename_w($wstring, $size_t);
# archive_read_open_filenames my $int = $r->open_filenames(\@filenames, $size_t);
Open a multi-file archive (typically for RAR format). The $size_t
argument is the block size.
# archive_write_open_memory my $code = $r->open_memory(\$buffer);
Open's the in-memory archive.
$r->open_perlfile(*FILE);
This takes a perl file handle and reads the archive from there.
# archive_read_data my $size_or_code = $r->read_data(\$buffer, $size); my $size_or_code = $r->read_data(\$buffer);
Read in data from the content section of the archive entry. The output is written into $buffer
. Up to $size
bytes will be read. This will return the number of bytes read on success, zero (0
) on EOF and a normal status code on error.
# archive_read_data_block my $int = $r->read_data_block(\$buffer, \$offset);
A zero-copy version of archive_read_data that also exposes the file offset of each returned block. Note that the client has no way to specify the desired size of the block. The API does guarantee that offsets will be strictly increasing and that returned blocks will not overlap.
Gotcha with this method is that it returns ARCHIVE_EOF
when there is no more data to read instead of the number of bytes. The size can be determined from the length of the newly resized $buffer
.
# archive_read_data_into_fd my $int1 = $r->read_data_into_fd($int2);
# archive_read_data_skip my $int = $r->read_data_skip;
# archive_read_set_filter_option my $int = $r->set_filter_option($string1, $string2, $string3);
# archive_read_set_format my $int = $r->set_format($code);
Set the format manually. This will accept either a string representation of the format, or the constant. The constant prefix is ARCHIVE_FORMAT_
. So for a tar file this would be either 'tar'
or ARCHIVE_FORMAT_TAR
.
# archive_read_set_format_option my $int = $r->set_format_option($string1, $string2, $string3);
# archive_read_set_option my $int = $r->set_option($string1, $string2, $string3);
# archive_read_set_options my $int = $r->set_options($string);
# archive_read_set_passphrase_callback my $int = $r->set_passphrase_callback(sub ($r) { ... return $passphrase; });
Set a callback that will be called when a passphrase is required, for example with a .zip file with encrypted entries.
# archive_read_support_filter_all my $int = $r->support_filter_all;
# archive_read_support_filter_by_code (optional) my $int1 = $r->support_filter_by_code($int2);
# archive_read_support_filter_bzip2 my $int = $r->support_filter_bzip2;
# archive_read_support_filter_compress my $int = $r->support_filter_compress;
# archive_read_support_filter_grzip my $int = $r->support_filter_grzip;
# archive_read_support_filter_gzip my $int = $r->support_filter_gzip;
# archive_read_support_filter_lrzip my $int = $r->support_filter_lrzip;
# archive_read_support_filter_lz4 my $int = $r->support_filter_lz4;
# archive_read_support_filter_lzip my $int = $r->support_filter_lzip;
# archive_read_support_filter_lzma my $int = $r->support_filter_lzma;
# archive_read_support_filter_lzop my $int = $r->support_filter_lzop;
# archive_read_support_filter_none my $int = $r->support_filter_none;
# archive_read_support_filter_program my $int = $r->support_filter_program($string);
# archive_read_support_filter_program_signature my $int = $r->support_filter_program_signature($string, $opaque, $size_t);
# archive_read_support_filter_rpm my $int = $r->support_filter_rpm;
# archive_read_support_filter_uu my $int = $r->support_filter_uu;
# archive_read_support_filter_xz my $int = $r->support_filter_xz;
# archive_read_support_filter_zstd (optional) my $int = $r->support_filter_zstd;
# archive_read_support_format_7zip my $int = $r->support_format_7zip;
# archive_read_support_format_all my $int = $r->support_format_all;
# archive_read_support_format_ar my $int = $r->support_format_ar;
# archive_read_support_format_by_code my $int1 = $r->support_format_by_code($int2);
# archive_read_support_format_cab my $int = $r->support_format_cab;
# archive_read_support_format_cpio my $int = $r->support_format_cpio;
# archive_read_support_format_empty my $int = $r->support_format_empty;
# archive_read_support_format_gnutar my $int = $r->support_format_gnutar;
# archive_read_support_format_iso9660 my $int = $r->support_format_iso9660;
# archive_read_support_format_lha my $int = $r->support_format_lha;
# archive_read_support_format_mtree my $int = $r->support_format_mtree;
# archive_read_support_format_rar my $int = $r->support_format_rar;
# archive_read_support_format_rar5 (optional) my $int = $r->support_format_rar5;
# archive_read_support_format_raw my $int = $r->support_format_raw;
# archive_read_support_format_tar my $int = $r->support_format_tar;
# archive_read_support_format_warc my $int = $r->support_format_warc;
# archive_read_support_format_xar my $int = $r->support_format_xar;
# archive_read_support_format_zip my $int = $r->support_format_zip;
# archive_read_support_format_zip_seekable my $int = $r->support_format_zip_seekable;
# archive_read_support_format_zip_streamable my $int = $r->support_format_zip_streamable;
# archive_write_add_filter my $int = $w->add_filter($code);
Add filter to be applied when writing the archive. This will accept either a string representation of the filter code, or the constant. The constant prefix is ARCHIVE_FILTER_
. So for a gzipped file this would be either 'gzip'
or ARCHIVE_FILTER_GZIP
. For the full list see "CONSTANTS" in Archive::Libarchive::API.
# archive_write_add_filter_b64encode my $int = $w->add_filter_b64encode;
# archive_write_add_filter_by_name my $int = $w->add_filter_by_name($string);
# archive_write_add_filter_bzip2 my $int = $w->add_filter_bzip2;
# archive_write_add_filter_compress my $int = $w->add_filter_compress;
# archive_write_add_filter_grzip my $int = $w->add_filter_grzip;
# archive_write_add_filter_gzip my $int = $w->add_filter_gzip;
# archive_write_add_filter_lrzip my $int = $w->add_filter_lrzip;
# archive_write_add_filter_lz4 my $int = $w->add_filter_lz4;
# archive_write_add_filter_lzip my $int = $w->add_filter_lzip;
# archive_write_add_filter_lzma my $int = $w->add_filter_lzma;
# archive_write_add_filter_lzop my $int = $w->add_filter_lzop;
# archive_write_add_filter_none my $int = $w->add_filter_none;
# archive_write_add_filter_program my $int = $w->add_filter_program($string);
# archive_write_add_filter_uuencode my $int = $w->add_filter_uuencode;
# archive_write_add_filter_xz my $int = $w->add_filter_xz;
# archive_write_add_filter_zstd (optional) my $int = $w->add_filter_zstd;
# archive_write_close my $int = $w->close;
# archive_write_fail my $int = $w->fail;
# archive_write_finish_entry my $int = $w->finish_entry;
# archive_write_get_bytes_in_last_block my $int = $w->get_bytes_in_last_block;
# archive_write_get_bytes_per_block my $int = $w->get_bytes_per_block;
# archive_write_new my $w = Archive::Libarchive::ArchiveWrite->new;
Create a new archive write object.
# archive_write_open $w->open(%callbacks);
This is a basic open method, which relies on callbacks for its implementation. The only callback that is required is the write
callback. The open
and close
callbacks are made available mostly for the benefit of the caller. All callbacks should return a normal status code, which is ARCHIVE_OK
on success.
Unlike the libarchive
C-API, this interface doesn't provide a facility for passing in "client" data. In Perl this is implemented using a closure, which should allow you to pass in arbitrary variables via proper scoping.
$w->open(open => sub ($w) { ... });
Called immediately when the archive is "opened";
$w->open(write => sub ($w, $ref) { ... = $$ref; return $size; });
This callback is called when data needs to be written to the archive. It is passed in as a reference to a scalar that contains the raw data. On success you should return the actual size of the data written in bytes, and on failure return a normal status code.
$w->open(open => sub ($w) { ... });
This is called when the archive instance is closed.
# archive_write_open_FILE $w->open_FILE($file_pointer);
This takes either a FFI::C::File, or an opaque pointer to a libc file pointer.
# archive_write_open_fd my $int1 = $w->open_fd($int2);
# archive_write_open_filename my $int = $w->open_filename($string);
# archive_write_open_filename_w my $int = $w->open_filename_w($wstring);
# archive_write_open_memory $w->open_memory(\$buffer);
This takes a reference to scalar and stores the archive in memory there.
$w->open_perlfile(*FILE);
This takes a perl file handle and stores the archive there.
# archive_write_set_bytes_in_last_block my $int1 = $w->set_bytes_in_last_block($int2);
# archive_write_set_bytes_per_block my $int1 = $w->set_bytes_per_block($int2);
# archive_write_set_filter_option my $int = $w->set_filter_option($string1, $string2, $string3);
# archive_write_set_format my $int = $w->set_format($code);
Set the output format. This will accept either a string representation of the format, or the constant. The constant prefix is ARCHIVE_FORMAT_
. So for a tar file this would be either 'tar'
or ARCHIVE_FORMAT_TAR
.
# archive_write_set_format_7zip my $int = $w->set_format_7zip;
# archive_write_set_format_ar_bsd my $int = $w->set_format_ar_bsd;
# archive_write_set_format_ar_svr4 my $int = $w->set_format_ar_svr4;
# archive_write_set_format_by_name my $int = $w->set_format_by_name($string);
# archive_write_set_format_cpio my $int = $w->set_format_cpio;
# archive_write_set_format_cpio_bin (optional) my $int = $w->set_format_cpio_bin;
# archive_write_set_format_cpio_newc my $int = $w->set_format_cpio_newc;
# archive_write_set_format_cpio_odc (optional) my $int = $w->set_format_cpio_odc;
# archive_write_set_format_cpio_pwb (optional) my $int = $w->set_format_cpio_pwb;
# archive_write_set_format_filter_by_ext my $int = $w->set_format_filter_by_ext($string);
# archive_write_set_format_filter_by_ext_def my $int = $w->set_format_filter_by_ext_def($string1, $string2);
# archive_write_set_format_gnutar my $int = $w->set_format_gnutar;
# archive_write_set_format_iso9660 my $int = $w->set_format_iso9660;
# archive_write_set_format_mtree my $int = $w->set_format_mtree;
# archive_write_set_format_mtree_classic my $int = $w->set_format_mtree_classic;
# archive_write_set_format_option my $int = $w->set_format_option($string1, $string2, $string3);
# archive_write_set_format_pax my $int = $w->set_format_pax;
# archive_write_set_format_pax_restricted my $int = $w->set_format_pax_restricted;
# archive_write_set_format_raw my $int = $w->set_format_raw;
# archive_write_set_format_shar my $int = $w->set_format_shar;
# archive_write_set_format_shar_dump my $int = $w->set_format_shar_dump;
# archive_write_set_format_ustar my $int = $w->set_format_ustar;
# archive_write_set_format_v7tar my $int = $w->set_format_v7tar;
# archive_write_set_format_warc my $int = $w->set_format_warc;
# archive_write_set_format_xar my $int = $w->set_format_xar;
# archive_write_set_format_zip my $int = $w->set_format_zip;
# archive_write_set_option my $int = $w->set_option($string1, $string2, $string3);
# archive_write_set_options my $int = $w->set_options($string);
# archive_write_set_passphrase my $int = $w->set_passphrase($string);
# archive_write_set_passphrase_callback my $int = $w->set_passphrase_callback(sub ($w) { ... return $passphrase; });
Set a callback that will be called when a passphrase is required, for example with a .zip file with encrypted entries.
# archive_write_set_skip_file my $int = $w->set_skip_file($sint64_1, $sint64_2);
# archive_write_data my $size_or_code = $w->write_data(\$buffer);
Write the entry content data to the archive. This takes a reference to the buffer. Returns the number of bytes written on success, and a normal status code on error.
# archive_write_header my $int = $w->write_header($e);
# archive_write_zip_set_compression_deflate my $int = $w->zip_set_compression_deflate;
# archive_write_zip_set_compression_store my $int = $w->zip_set_compression_store;
# archive_read_disk_can_descend my $int = $dr->disk_can_descend;
# archive_read_disk_current_filesystem my $int = $dr->disk_current_filesystem;
# archive_read_disk_current_filesystem_is_remote my $int = $dr->disk_current_filesystem_is_remote;
# archive_read_disk_current_filesystem_is_synthetic my $int = $dr->disk_current_filesystem_is_synthetic;
# archive_read_disk_descend my $int = $dr->disk_descend;
# archive_read_disk_gname my $string = $dr->disk_gname($sint64);
# archive_read_disk_open my $int = $dr->disk_open($string);
# archive_read_disk_open_w my $int = $dr->disk_open_w($wstring);
# archive_read_disk_set_atime_restored my $int = $dr->disk_set_atime_restored;
# archive_read_disk_set_behavior my $int1 = $dr->disk_set_behavior($int2);
# archive_read_disk_set_standard_lookup my $int = $dr->disk_set_standard_lookup;
# archive_read_disk_set_symlink_hybrid my $int = $dr->disk_set_symlink_hybrid;
# archive_read_disk_set_symlink_logical my $int = $dr->disk_set_symlink_logical;
# archive_read_disk_set_symlink_physical my $int = $dr->disk_set_symlink_physical;
# archive_read_disk_uname my $string = $dr->disk_uname($sint64);
my $dr = Archive::Libarchive::DiskRead->new;
Create a new disk read object.
# archive_write_disk_gid my $sint64_1 = $dw->disk_gid($string, $sint64_2);
# archive_write_disk_set_options my $int1 = $dw->disk_set_options($int2);
# archive_write_disk_set_skip_file my $int = $dw->disk_set_skip_file($sint64_1, $sint64_2);
# archive_write_disk_set_standard_lookup my $int = $dw->disk_set_standard_lookup;
# archive_write_disk_uid my $sint64_1 = $dw->disk_uid($string, $sint64_2);
# archive_write_disk_new my $dw = Archive::Libarchive::DiskWrite->new;
Create a new disk write object.
# archive_write_data_block my $ssize_t = $dw->write_data_block(\$buffer, $offset);
Write the entry content data to the disk. This is intended to be used with "read_data_block" in Archive::Libarchive::ArchiveRead.
# archive_entry_acl_add_entry my $int1 = $e->acl_add_entry($int2, $int3, $int4, $int5, $string);
# archive_entry_acl_add_entry_w my $int1 = $e->acl_add_entry_w($int2, $int3, $int4, $int5, $wstring);
# archive_entry_acl_clear $e->acl_clear;
# archive_entry_acl_count my $int1 = $e->acl_count($int2);
# archive_entry_acl_from_text (optional) my $int1 = $e->acl_from_text($string, $int2);
# archive_entry_acl_from_text_w (optional) my $int1 = $e->acl_from_text_w($wstring, $int2);
# archive_entry_acl_next my $int1 = $e->acl_next($int2, $int*1, $int*2, $int*3, $int*4, \$string);
# archive_entry_acl_reset my $int1 = $e->acl_reset($int2);
# archive_entry_acl_to_text (optional) my $string = $e->acl_to_text(\$ssize_t, $int);
# archive_entry_acl_to_text_w (optional) my $wstring = $e->acl_to_text_w(\$ssize_t, $int);
# archive_entry_acl_types (optional) my $int = $e->acl_types;
# archive_entry_atime my $time_t = $e->atime;
# archive_entry_atime_is_set my $int = $e->atime_is_set;
# archive_entry_atime_nsec my $long = $e->atime_nsec;
# archive_entry_birthtime my $time_t = $e->birthtime;
# archive_entry_birthtime_is_set my $int = $e->birthtime_is_set;
# archive_entry_birthtime_nsec my $long = $e->birthtime_nsec;
# archive_entry_clear $e->clear;
# archive_entry_clone my $e2 = $e->clone;
Clone the entry instance.
# archive_entry_copy_fflags_text my $string1 = $e->copy_fflags_text($string2);
# archive_entry_copy_fflags_text_w my $wstring1 = $e->copy_fflags_text_w($wstring2);
# archive_entry_copy_gname $e->copy_gname($string);
# archive_entry_copy_gname_w $e->copy_gname_w($wstring);
# archive_entry_copy_hardlink $e->copy_hardlink($string);
# archive_entry_copy_hardlink_w $e->copy_hardlink_w($wstring);
# archive_entry_copy_link $e->copy_link($string);
# archive_entry_copy_link_w $e->copy_link_w($wstring);
# archive_entry_copy_mac_metadata $e->copy_mac_metadata($meta);
Sets the mac metadata to $meta
.
# archive_entry_copy_pathname $e->copy_pathname($string);
# archive_entry_copy_pathname_w $e->copy_pathname_w($wstring);
# archive_entry_copy_sourcepath $e->copy_sourcepath($string);
# archive_entry_copy_sourcepath_w $e->copy_sourcepath_w($wstring);
# archive_entry_copy_stat $e->copy_stat($stat);
Copies the values from a FFI::C::Stat instance.
Not currently implemented on Windows.
# archive_entry_copy_symlink $e->copy_symlink($string);
# archive_entry_copy_symlink_w $e->copy_symlink_w($wstring);
# archive_entry_copy_uname $e->copy_uname($string);
# archive_entry_copy_uname_w $e->copy_uname_w($wstring);
# archive_entry_ctime my $time_t = $e->ctime;
# archive_entry_ctime_is_set my $int = $e->ctime_is_set;
# archive_entry_ctime_nsec my $long = $e->ctime_nsec;
# archive_entry_dev my $dev_t = $e->dev;
# archive_entry_dev_is_set my $int = $e->dev_is_set;
# archive_entry_devmajor my $dev_t = $e->devmajor;
# archive_entry_devminor my $dev_t = $e->devminor;
# archive_entry_digest my $string = $e->digest($type);
This is used to query the raw hex digest for the given entry. The type of digest is provided as an argument. The type may be passed in as either a string or an integer constant. The constant prefix is ARCHIVE_ENTRY_DIGEST_
. So for an MD5 digest you could pass in either 'md5'
or ARCHIVE_ENTRY_DIGEST_MD5
.
# archive_entry_fflags $e->fflags($ulong*1, $ulong*2);
# archive_entry_fflags_text my $string = $e->fflags_text;
# archive_entry_filetype my $code = $e->filetype;
This returns the type of file for the entry. This will be a dualvar where the string is one of mt
, reg
, lnx
, sock
, chr
, blk
, dir
or ifo
, and integer values will match the corresponding AE_IF
prefixed constant. See "CONSTANTS" in Archive::Libarchive::API for the full list.
# archive_entry_filetype_is_set (optional) my $int = $e->filetype_is_set;
# archive_entry_gid my $sint64 = $e->gid;
# archive_entry_gid_is_set (optional) my $int = $e->gid_is_set;
# archive_entry_gname my $string = $e->gname;
# archive_entry_gname_utf8 my $string_utf8 = $e->gname_utf8;
# archive_entry_hardlink my $string = $e->hardlink;
# archive_entry_hardlink_utf8 my $string_utf8 = $e->hardlink_utf8;
# archive_entry_ino my $sint64 = $e->ino;
# archive_entry_ino64 my $sint64 = $e->ino64;
# archive_entry_ino_is_set my $int = $e->ino_is_set;
# archive_entry_is_data_encrypted my $int = $e->is_data_encrypted;
# archive_entry_is_encrypted my $int = $e->is_encrypted;
# archive_entry_is_metadata_encrypted my $int = $e->is_metadata_encrypted;
# archive_entry_mac_metadata my $meta = $e->mac_metadata;
Get the mac metadata from the entry.
# archive_entry_mode my $mode_t = $e->mode;
# archive_entry_mtime my $time_t = $e->mtime;
# archive_entry_mtime_is_set my $int = $e->mtime_is_set;
# archive_entry_mtime_nsec my $long = $e->mtime_nsec;
my $e = Archive::Libarchive::Entry->new;
Create a new Entry object.
# archive_entry_nlink my $uint = $e->nlink;
# archive_entry_pathname my $string = $e->pathname;
# archive_entry_pathname_utf8 my $string_utf8 = $e->pathname_utf8;
# archive_entry_perm my $mode_t = $e->perm;
# archive_entry_perm_is_set (optional) my $int = $e->perm_is_set;
# archive_entry_rdev my $dev_t = $e->rdev;
# archive_entry_rdevmajor my $dev_t = $e->rdevmajor;
# archive_entry_rdevminor my $dev_t = $e->rdevminor;
# archive_entry_set_atime $e->set_atime($time_t, $long);
# archive_entry_set_birthtime $e->set_birthtime($time_t, $long);
# archive_entry_set_ctime $e->set_ctime($time_t, $long);
# archive_entry_set_dev $e->set_dev($dev_t);
# archive_entry_set_devmajor $e->set_devmajor($dev_t);
# archive_entry_set_devminor $e->set_devminor($dev_t);
# archive_entry_set_fflags $e->set_fflags($ulong1, $ulong2);
# archive_entry_set_filetype $e->set_filetype($code);
This sets the type of the file for the entry. This will accept either a string value which is one of mt
, reg
, lnx
, sock
, chr
, blk
, dir
or ifo
, or an integer constant value with the AE_IF
prefix. See "CONSTANTS" in Archive::Libarchive::API for the full list.
# archive_entry_set_gid $e->set_gid($sint64);
# archive_entry_set_gname $e->set_gname($string);
# archive_entry_set_gname_utf8 $e->set_gname_utf8($string);
# archive_entry_set_hardlink $e->set_hardlink($string);
# archive_entry_set_hardlink_utf8 $e->set_hardlink_utf8($string);
# archive_entry_set_ino $e->set_ino($sint64);
# archive_entry_set_ino64 $e->set_ino64($sint64);
# archive_entry_set_is_data_encrypted $e->set_is_data_encrypted($char);
# archive_entry_set_is_metadata_encrypted $e->set_is_metadata_encrypted($char);
# archive_entry_set_link $e->set_link($string);
# archive_entry_set_link_utf8 $e->set_link_utf8($string);
# archive_entry_set_mode $e->set_mode($mode_t);
# archive_entry_set_mtime $e->set_mtime($time_t, $long);
# archive_entry_set_nlink $e->set_nlink($uint);
# archive_entry_set_pathname $e->set_pathname($string);
# archive_entry_set_pathname_utf8 $e->set_pathname_utf8($string);
# archive_entry_set_perm $e->set_perm($mode_t);
# archive_entry_set_rdev $e->set_rdev($dev_t);
# archive_entry_set_rdevmajor $e->set_rdevmajor($dev_t);
# archive_entry_set_rdevminor $e->set_rdevminor($dev_t);
# archive_entry_set_size $e->set_size($sint64);
# archive_entry_set_symlink $e->set_symlink($string);
# archive_entry_set_symlink_type (optional) $e->set_symlink_type($int);
# archive_entry_set_symlink_utf8 $e->set_symlink_utf8($string);
# archive_entry_set_uid $e->set_uid($sint64);
# archive_entry_set_uname $e->set_uname($string);
# archive_entry_set_uname_utf8 $e->set_uname_utf8($string);
# archive_entry_size my $sint64 = $e->size;
# archive_entry_size_is_set my $int = $e->size_is_set;
# archive_entry_sourcepath my $string = $e->sourcepath;
# archive_entry_sourcepath_w my $wstring = $e->sourcepath_w;
# archive_entry_sparse_add_entry $e->sparse_add_entry($sint64_1, $sint64_2);
# archive_entry_sparse_clear $e->sparse_clear;
# archive_entry_sparse_count my $int = $e->sparse_count;
# archive_entry_sparse_next my $int = $e->sparse_next($sint64*1, $sint64*2);
# archive_entry_sparse_reset my $int = $e->sparse_reset;
# archive_entry_stat my $stat = $e->stat;
Returns a FFI::C::Stat instance filled out from the entry metadata.
Not currently implemented on Windows.
# archive_entry_strmode my $string = $e->strmode;
# archive_entry_symlink my $string = $e->symlink;
# archive_entry_symlink_type (optional) my $int = $e->symlink_type;
# archive_entry_symlink_utf8 my $string_utf8 = $e->symlink_utf8;
# archive_entry_uid my $sint64 = $e->uid;
# archive_entry_uid_is_set (optional) my $int = $e->uid_is_set;
# archive_entry_uname my $string = $e->uname;
# archive_entry_uname_utf8 my $string_utf8 = $e->uname_utf8;
# archive_entry_unset_atime $e->unset_atime;
# archive_entry_unset_birthtime $e->unset_birthtime;
# archive_entry_unset_ctime $e->unset_ctime;
# archive_entry_unset_mtime $e->unset_mtime;
# archive_entry_unset_size $e->unset_size;
# archive_entry_update_gname_utf8 my $int = $e->update_gname_utf8($string);
# archive_entry_update_hardlink_utf8 my $int = $e->update_hardlink_utf8($string);
# archive_entry_update_link_utf8 my $int = $e->update_link_utf8($string);
# archive_entry_update_pathname_utf8 my $int = $e->update_pathname_utf8($string);
# archive_entry_update_symlink_utf8 my $int = $e->update_symlink_utf8($string);
# archive_entry_update_uname_utf8 my $int = $e->update_uname_utf8($string);
# archive_entry_xattr_add_entry my $int = $e->xattr_add_entry($name, $value);
Adds an xattr name/value pair.
# archive_entry_xattr_clear $e->xattr_clear;
# archive_entry_xattr_count my $int = $e->xattr_count;
# archive_entry_xattr_next my $int = $e->xattr_next(\$name, $value);
Fetches the next xattr name/value pair.
# archive_entry_xattr_reset my $int = $e->xattr_reset;
my $r = Archive::Libarchive::EntryLinkResolver->new;
Create a new entry link resolver object.
# archive_entry_linkresolver_set_strategy $lr->set_strategy($int);
# archive_match_exclude_entry my $int1 = $m->exclude_entry($int2, $e);
# archive_match_exclude_pattern my $int = $m->exclude_pattern($string);
# archive_match_exclude_pattern_from_file my $int1 = $m->exclude_pattern_from_file($string, $int2);
# archive_match_exclude_pattern_from_file_w my $int1 = $m->exclude_pattern_from_file_w($wstring, $int2);
# archive_match_exclude_pattern_w my $int = $m->exclude_pattern_w($wstring);
# archive_match_excluded my $int = $m->excluded($e);
# archive_match_include_date my $int1 = $m->include_date($int2, $string);
# archive_match_include_date_w my $int1 = $m->include_date_w($int2, $wstring);
# archive_match_include_file_time my $int1 = $m->include_file_time($int2, $string);
# archive_match_include_file_time_w my $int1 = $m->include_file_time_w($int2, $wstring);
# archive_match_include_gid my $int = $m->include_gid($sint64);
# archive_match_include_gname my $int = $m->include_gname($string);
# archive_match_include_gname_w my $int = $m->include_gname_w($wstring);
# archive_match_include_pattern my $int = $m->include_pattern($string);
# archive_match_include_pattern_from_file my $int1 = $m->include_pattern_from_file($string, $int2);
# archive_match_include_pattern_from_file_w my $int1 = $m->include_pattern_from_file_w($wstring, $int2);
# archive_match_include_pattern_w my $int = $m->include_pattern_w($wstring);
# archive_match_include_time my $int1 = $m->include_time($int2, $time_t, $long);
# archive_match_include_uid my $int = $m->include_uid($sint64);
# archive_match_include_uname my $int = $m->include_uname($string);
# archive_match_include_uname_w my $int = $m->include_uname_w($wstring);
my $r = Archive::Libarchive::Match->new;
Create a new archive match object.
# archive_match_owner_excluded my $int = $m->owner_excluded($e);
# archive_match_path_excluded my $int = $m->path_excluded($e);
# archive_match_path_unmatched_inclusions my $int = $m->path_unmatched_inclusions;
# archive_match_path_unmatched_inclusions_next my $int = $m->path_unmatched_inclusions_next(\$string);
# archive_match_set_inclusion_recursion (optional) my $int1 = $m->set_inclusion_recursion($int2);
# archive_match_time_excluded my $int = $m->time_excluded($e);
The status code constants are documented in the main documentation page Archive::Libarchive.
These constants can be imported individually from Archive::Libarchive using the normal Exporter interface, or all of them can be imported with the :const
export tag or along with functions with the :all
tag.
For the rest please consult the libarchive
documentation.
The following methods are not currently implemented. The reason for this is usually for one of 1) the method doesn't make sense in the context of Perl 2) the methods have been renamed, and this is the old name kept for compatibility in libarchive
3) the methods have deprecated and will be removed in a future version of libarchive
4) we haven't gotten around to writing bindings for them.
Provides an interface for listing and retrieving entries from an archive without extracting them to the local filesystem.
Provides an interface for extracting arbitrary archives of any format/filter supported by libarchive
.
Decompresses / unwraps files that have been compressed or wrapped in any of the filter formats supported by libarchive
This is the main top-level module for using libarchive
from Perl. It is the best place to start reading the documentation. It pulls in the other classes and libarchive
constants so that you only need one use
statement to effectively use libarchive
.
The base class of all archive classes. This includes some common error reporting functionality among other things.
This class is used for reading from archives.
This class is for creating new archives.
This class is for reading Archive::Libarchive::Entry objects from disk so that they can be written to Archive::Libarchive::ArchiveWrite objects.
This class is for writing Archive::Libarchive::Entry objects to disk that have been written from Archive::Libarchive::ArchiveRead objects.
This class represents a file in an archive, or on disk.
This class exposes the libarchive
link resolver API.
This class exposes the libarchive
match API.
Build Dist::Zilla based dist tarballs with libarchive instead of the built in Archive::Tar.
If a suitable system libarchive
can't be found, then this Alien will be installed to provide it.
The libarchive
project home page.
The libarchive
project wiki.
Some of the libarchive
man pages are listed here.
Graham Ollis <plicease@cpan.org>
This software is copyright (c) 2021,2022 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.