Archive-Libarchive
view release on metacpan or search on metacpan
lib/Archive/Libarchive/Entry.pm view on Meta::CPAN
my $xsub = shift;
my($ptr, $size) = scalar_to_buffer($_[2]);
$xsub->($_[0], $_[1], $ptr, $size);
});
$ffi->attach( xattr_next => ['archive_entry', 'string*', 'opaque*', 'size_t*'] => 'int' => sub {
my($xsub, $self, $ref_name, $ref_value) = @_;
my($ptr, $size);
my $ret = $xsub->($self, $ref_name, \$ptr, \$size);
if(defined $ptr)
{ $$ref_value = buffer_to_scalar($ptr, $size) }
else
{ $$ref_value = undef }
return $ret;
});
if($^O ne 'MSWin32')
{
require FFI::C::Stat;
$ffi->attach( copy_stat => ['archive_entry', 'stat'] );
$ffi->attach( stat => ['archive_entry'] => opaque => sub {
my($xsub, $self) = @_;
my $ptr = $xsub->($self);
defined $ptr ? FFI::C::Stat->clone($ptr) : undef;
});
}
else
{
# https://github.com/uperl/Archive-Libarchive/issues/19
require Carp;
*copy_stat = sub { Carp::croak("Not implemented on this platform") };
*stat = sub { Carp::croak("Not implemented on this platform") };
}
$ffi->attach( clone => ['archive_entry'] => 'archive_entry' );
$ffi->attach( copy_mac_metadata => ['archive_entry', 'opaque', 'size_t'] => sub {
my $xsub = shift;
my $self = shift;
my($ptr, $size) = scalar_to_buffer $_[0];
$xsub->($self, $ptr, $size);
});
$ffi->attach( mac_metadata => ['archive_entry', 'size_t*'] => 'opaque' => sub {
my($xsub, $self) = @_;
my $size;
my $ptr = $xsub->($self, \$size);
defined $ptr ? buffer_to_scalar($ptr, $size) : undef;
});
$ffi->attach( [ free => 'DESTROY' ] => ['archive_entry'] => sub {
my($xsub, $self) = @_;
return if $self->{owner} # owned by another object
|| ${^GLOBAL_PHASE} eq 'DESTRUCT'; # during global shutdown the xsub might go away
$xsub->($self);
});
#$ffi->attach( [ free => 'DESTROY' ] => ['archive_entry'] => 'void' );
$ffi->ignore_not_found(1);
$ffi->attach_cast(_digest_type_to_int => archive_entry_digest_t => 'int' );
my @size = (
undef,
16,
20,
20,
32,
48,
64,
);
$ffi->attach( digest => ['archive_entry', 'archive_entry_digest_t'] => 'opaque' => sub {
my($xsub, $self, $type) = @_;
my $size = $size[_digest_type_to_int($type)];
my $ptr = $xsub->($self, $type);
buffer_to_scalar($ptr, $size);
});
$ffi->ignore_not_found(0);
require Archive::Libarchive::Lib::Entry unless $Archive::Libarchive::no_gen;
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Archive::Libarchive::Entry - Libarchive entry class
=head1 VERSION
version 0.09
=head1 SYNOPSIS
use 5.020;
use Archive::Libarchive;
my $text = "Hello World!\n";
my $e = Archive::Libarchive::Entry->new;
$e->set_pathname("hello.txt");
$e->set_filetype('reg');
$e->set_size(length $text);
$e->set_mtime(time);
$e->set_mode(oct('0644'));
=head1 DESCRIPTION
This class represents an entry, which is file metadata for a file stored in an
archive or on the local file system.
=head1 CONSTRUCTOR
This is a subset of total list of methods available to all archive classes.
For the full list see L<Archive::Libarchive::API/Archive::Libarchive::Entry>.
=head2 new
my $e = Archive::Libarchive::Entry->new;
Create a new Entry object.
=head1 METHODS
This is a subset of total list of methods available to all archive classes.
For the full list see L<Archive::Libarchive::API/Archive::Libarchive::Entry>.
=head2 filetype
# archive_entry_filetype
my $code = $e->filetype;
( run in 1.138 second using v1.01-cache-2.11-cpan-98e64b0badf )