view release on metacpan or search on metacpan
- for libarchive 2.x, use our own Perl implementation of archive_read_open_memory
as interfacing with the C version is causing SIGSEGV.
0.0704 2014-03-27 10:41:31 -0400
- Take advantage of FFI::Raw 0.29's ability to return strings from callbacks
- And therefore remove dependency on Module::Build::FFI
0.0703 2014-03-24 17:17:33 -0400
- fixed some type declarations which were causing failures on 32bit Linux
(possibly others)
specifically: use int64_t instead of gid_t/uid_t for UID/GID types
use size_t instead of int64_t for buffer sizes
0.0702 2014-02-22 10:30:50 -0500
- require FFI::Raw 0.28 and FFI::Util 0.06 for recent bugfixes
0.07 2014-02-10 18:54:14 -0500
- fix MSWin32 build failure
- support for libarchive 2.5.x
- Update tests to be in sync with Archive::Libarchive::XS 0.07
t/common_list_contents_of_archive.t
t/common_match2.t
t/common_match_owner.t
t/common_memory_write.t
t/common_read_data_into_fh.t
t/common_read_disk.t
t/common_read_open_error.t
t/common_signature.t
t/common_sparse.t
t/common_stat.t
t/common_uid_gid_lookup.t
t/common_unicode.t
t/common_universal_decompressor.t
t/common_user_group_lookup.t
t/foo.tar
t/foo.tar.Z
t/foo.tar.bz2
t/foo.tar.gz
t/foo.txt.Z.uu
t/foo.txt.gz.uu
t/foo.xar
inc/functions.txt view on Meta::CPAN
archive_entry_ctime_is_set
archive_entry_ctime_nsec
archive_entry_dev
archive_entry_dev_is_set
archive_entry_devmajor
archive_entry_devminor
archive_entry_fflags
archive_entry_fflags_text
archive_entry_filetype
archive_entry_free
archive_entry_gid
archive_entry_gname
archive_entry_hardlink
archive_entry_ino
archive_entry_ino_is_set
archive_entry_linkify
archive_entry_linkresolver_free
archive_entry_linkresolver_new
archive_entry_linkresolver_set_strategy
archive_entry_mac_metadata
archive_entry_mode
inc/functions.txt view on Meta::CPAN
archive_entry_rdevminor
archive_entry_set_atime
archive_entry_set_birthtime
archive_entry_set_ctime
archive_entry_set_dev
archive_entry_set_devmajor
archive_entry_set_devminor
archive_entry_set_fflags
archive_entry_set_fflags_text
archive_entry_set_filetype
archive_entry_set_gid
archive_entry_set_gname
archive_entry_set_hardlink
archive_entry_set_ino
archive_entry_set_link
archive_entry_set_mac_metadata
archive_entry_set_mode
archive_entry_set_mtime
archive_entry_set_nlink
archive_entry_set_pathname
archive_entry_set_perm
inc/functions.txt view on Meta::CPAN
archive_filter_name
archive_format
archive_format_name
archive_match_exclude_entry
archive_match_exclude_pattern
archive_match_exclude_pattern_from_file
archive_match_excluded
archive_match_free
archive_match_include_date
archive_match_include_file_time
archive_match_include_gid
archive_match_include_gname
archive_match_include_pattern
archive_match_include_pattern_from_file
archive_match_include_time
archive_match_include_uid
archive_match_include_uname
archive_match_new
archive_match_owner_excluded
archive_match_path_excluded
archive_match_path_unmatched_inclusions
inc/functions.txt view on Meta::CPAN
archive_write_add_filter_lzip
archive_write_add_filter_lzma
archive_write_add_filter_lzop
archive_write_add_filter_none
archive_write_add_filter_program
archive_write_add_filter_uuencode
archive_write_add_filter_xz
archive_write_close
archive_write_data
archive_write_data_block
archive_write_disk_gid
archive_write_disk_new
archive_write_disk_set_group_lookup
archive_write_disk_set_options
archive_write_disk_set_skip_file
archive_write_disk_set_standard_lookup
archive_write_disk_set_user_lookup
archive_write_disk_uid
archive_write_fail
archive_write_finish_entry
archive_write_free
lib/Archive/Libarchive/FFI.pm view on Meta::CPAN
_attach 'archive_write_disk_set_options', [ _ptr, _int ], _int;
_attach 'archive_write_finish_entry', [ _ptr ], _int;
_attach 'archive_write_disk_set_standard_lookup', [ _ptr ], _int;
_attach 'archive_write_zip_set_compression_deflate', [ _ptr ], _int;
_attach 'archive_write_zip_set_compression_store', [ _ptr ], _int;
_attach 'archive_write_set_filter_option', [ _ptr, _str, _str, _str ], _int;
_attach 'archive_write_set_format_option', [ _ptr, _str, _str, _str ], _int;
_attach 'archive_write_set_option', [ _ptr, _str, _str, _str ], _int;
_attach 'archive_write_set_options', [ _ptr, _str ], _int;
_attach 'archive_write_set_skip_file', [ _ptr, _int64, _int64 ], _int;
_attach 'archive_write_disk_gid', [ _ptr, _str, _int64 ], _int64;
_attach 'archive_write_disk_set_skip_file', [ _ptr, _int64, _int64 ], _int;
_attach 'archive_write_disk_uid', [ _ptr, _str, _int64 ], _int64;
_attach 'archive_write_fail', [ _ptr ], _int;
_attach 'archive_write_get_bytes_in_last_block', [ _ptr ], _int;
_attach 'archive_write_get_bytes_per_block', [ _ptr ], _int;
_attach 'archive_write_set_bytes_in_last_block', [ _ptr, _int ], _int;
_attach 'archive_write_set_bytes_per_block', [ _ptr, _int ], _int;
if(archive_version_number() >= 3000000)
{
lib/Archive/Libarchive/FFI.pm view on Meta::CPAN
_attach 'archive_entry_ctime', [ _ptr ], _time_t;
_attach 'archive_entry_ctime_nsec', [ _ptr ], _long;
_attach 'archive_entry_mtime_is_set', [ _ptr ], _int;
_attach 'archive_entry_mtime', [ _ptr ], _time_t;
_attach 'archive_entry_mtime_nsec', [ _ptr ], _long;
_attach 'archive_entry_dev_is_set', [ _ptr ], _int;
_attach 'archive_entry_dev', [ _ptr ], _dev_t;
_attach 'archive_entry_devmajor', [ _ptr ], _dev_t;
_attach 'archive_entry_devminor', [ _ptr ], _dev_t;
_attach 'archive_entry_fflags_text', [ _ptr ], _str;
_attach 'archive_entry_gid', [ _ptr ], _int64;
_attach 'archive_entry_rdev', [ _ptr ], _int64;
_attach 'archive_entry_rdevmajor', [ _ptr ], _int64;
_attach 'archive_entry_rdevminor', [ _ptr ], _int64;
_attach 'archive_entry_set_rdev', [ _ptr, _int64 ], _void;
_attach 'archive_entry_set_rdevmajor', [ _ptr, _int64 ], _void;
_attach 'archive_entry_set_rdevminor', [ _ptr, _int64 ], _void;
_attach 'archive_entry_filetype', [ _ptr ], _int;
_attach 'archive_entry_ino', [ _ptr ], _int64;
_attach 'archive_entry_ino_is_set', [ _ptr ], _int;
_attach 'archive_entry_mode', [ _ptr ], _int;
_attach 'archive_entry_nlink', [ _ptr ], _uint;
_attach 'archive_entry_perm', [ _ptr ], _int;
_attach 'archive_entry_set_dev', [ _ptr, _dev_t ], _void;
_attach 'archive_entry_set_devmajor', [ _ptr, _dev_t ], _void;
_attach 'archive_entry_set_devminor', [ _ptr, _dev_t ], _void;
_attach 'archive_entry_set_fflags', [ _ptr, _ulong, _ulong ], _void;
_attach 'archive_entry_set_gid', [ _ptr, _int64 ], _void;
_attach 'archive_entry_set_ino', [ _ptr, _int64 ], _void;
_attach 'archive_entry_set_link', [ _ptr, _str ], _void;
_attach 'archive_entry_set_mode', [ _ptr, _int ], _void;
_attach 'archive_entry_set_nlink', [ _ptr, _int ], _void;
_attach 'archive_entry_set_uid', [ _ptr, _int64 ], _void;
_attach 'archive_entry_size_is_set', [ _ptr ], _int;
_attach 'archive_entry_unset_atime', [ _ptr ], _void;
_attach 'archive_entry_unset_birthtime', [ _ptr ], _void;
_attach 'archive_entry_unset_ctime', [ _ptr ], _void;
_attach 'archive_entry_unset_mtime', [ _ptr ], _void;
lib/Archive/Libarchive/FFI.pm view on Meta::CPAN
_attach 'archive_read_disk_set_symlink_hybrid', [ _ptr ], _int;
_attach 'archive_read_disk_set_symlink_logical', [ _ptr ], _int;
_attach 'archive_read_disk_set_symlink_physical', [ _ptr ], _int;
_attach 'archive_match_new', undef, _ptr;
_attach 'archive_match_free', [ _ptr ], _int;
_attach 'archive_match_excluded', [ _ptr, _ptr ], _int;
_attach 'archive_match_path_excluded', [ _ptr, _ptr ], _int;
_attach 'archive_match_time_excluded', [ _ptr, _ptr ], _int;
_attach 'archive_match_owner_excluded', [ _ptr, _ptr ], _int;
_attach 'archive_match_include_gid', [ _ptr, _int64 ], _int;
_attach 'archive_match_include_uid', [ _ptr, _int64 ], _int;
_attach 'archive_match_include_gname', [ _ptr, _str ], _int;
_attach 'archive_match_include_uname', [ _ptr, _str ], _int;
_attach 'archive_match_exclude_entry', [ _ptr, _int, _ptr ], _int;
_attach 'archive_match_exclude_pattern', [ _ptr, _str ], _int;
_attach 'archive_match_exclude_pattern_from_file', [ _ptr, _str, _int ], _int;
_attach 'archive_match_include_pattern', [ _ptr, _str ], _int;
_attach 'archive_match_include_pattern_from_file', [ _ptr, _str, _int ], _int;
_attach 'archive_match_include_file_time', [ _ptr, _int, _str ], _int;
_attach 'archive_match_include_time', [ _ptr, _int, _time_t, _long ], _int;
lib/Archive/Libarchive/FFI/Callback.pm view on Meta::CPAN
my $status = archive_write_disk_set_user_lookup($archive, $data, sub {
my($data, $name, $uid) = @_;
... # should return the UID for $name or $uid if it can't be found
}, undef);
Called by archive_write_disk_uid to determine appropriate UID.
=head2 group id lookup
my $status = archive_write_disk_set_group_lookup($archive, $data, sub {
my($data, $name, $gid) = @_;
... # should return the GID for $name or $gid if it can't be found
}, undef);
Called by archive_write_disk_gid to determine appropriate GID.
=head2 user name lookup
my $status = archive_read_disk_set_uname_lookup($archive, $data, sub
my($data, $uid) = @_;
... # should return the name for $uid, or undef
}, undef);
Called by archive_read_disk_uname to determine appropriate user name.
=head2 group name lookup
my $status = archive_read_disk_set_gname_lookup($archive, $data, sub
my($data, $gid) = @_;
... # should return the name for $gid, or undef
}, undef);
Called by archive_read_disk_gname to determine appropriate group name.
=head2 lookup cleanup
sub mycleanup
{
my($data) = @_;
... # any cleanup necessary
lib/Archive/Libarchive/FFI/Common.pm view on Meta::CPAN
warn 'write error';
return ARCHIVE_FATAL();
}
}
# TODO: for XS version, implement this in XS
sub archive_entry_stat ($)
{
my($entry) = @_;
no strict 'refs';
map { &{"archive_entry_$_"}($entry) } qw ( dev ino mode nlink uid gid rdev atime mtime ctime );
}
# TODO: for XS version, implement this in XS
sub archive_entry_set_stat
{
my $entry = shift;
my $status = ARCHIVE_OK();
no strict 'refs';
foreach my $prop (qw( dev ino mode nlink uid gid rdev ))
{
my $status2 = &{"archive_entry_set_$prop"}($entry, shift);
$status = $status2 if $status2 < $status;
}
foreach my $prop (qw( atime mtime ctime ))
{
my $value = shift;
my $status2 = &{"archive_entry_set_$prop"}($entry, $value, $value);
$status = $status2 if $status2 < $status;
}
lib/Archive/Libarchive/FFI/Common.pm view on Meta::CPAN
});
_sub_if_can( archive_write_set_format_option => sub {
_archive_write_set_format_option($_[0], _encode($_[1]), _encode($_[2]), _encode($_[3]));
});
_sub_if_can( archive_write_set_option => sub {
_archive_write_set_option($_[0], _encode($_[1]), _encode($_[2]), _encode($_[3]));
});
_sub_if_can( archive_write_set_options => sub {
_archive_write_set_options($_[0], _encode($_[1]));
});
_sub_if_can( archive_write_disk_gid => sub {
_archive_write_disk_gid($_[0], _encode($_[1]), $_[2]);
});
_sub_if_can( archive_write_disk_uid => sub {
_archive_write_disk_uid($_[0], _encode($_[1]), $_[2]);
});
_sub_if_can( archive_entry_fflags_text => sub {
_decode(_archive_entry_fflags_text($_[0]));
});
_sub_if_can( archive_read_disk_open => sub {
_archive_read_disk_open($_[0], _encode($_[1]));
});
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
=head2 archive_entry_copy_sourcepath
my $status = archive_entry_set_sourcepath($entry, $sourcepath);
Sets the sourcepath property for the archive entry object.
This is an alias for archive_entry_set_sourcepath.
=head2 archive_entry_copy_stat
my $status = archive_entry_stat($entry, $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $atime, $mtime, $ctime);
Converts the various fields in the format used by L<stat|perlfunc#stat> to the fields store in the archive entry.
The fields C<$blksize>, C<$blocks> supported by L<stat|perlfunc#stat>, are not supported by this function.
This is an alias for L<archive_entry_set_stat|Archive::Libarchive::FFI::Function#archive_entry_set_stat>.
=head2 archive_entry_ctime
my $ctime = archive_entry_ctime($entry);
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
=item AE_IFIFO
=back
=head2 archive_entry_free
my $status = archive_entry_free($entry);
Releases the struct archive_entry object.
=head2 archive_entry_gid
my $gid = archive_entry_gid($entry);
Returns the group id property for the archive entry.
=head2 archive_entry_gname
my $string = archive_entry_gname($entry);
Retrieve the gname for the archive entry object.
=head2 archive_entry_hardlink
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
=item AE_IFCHR
=item AE_IFBLK
=item AE_IFDIR
=item AE_IFIFO
=back
=head2 archive_entry_set_gid
my $status = archive_entry_set_gid($gid).
Sets the group id property for the archive entry.
=head2 archive_entry_set_gname
my $status = archive_entry_set_gname($entry, $string)
Sets the gname for the archive entry object.
=head2 archive_entry_set_hardlink
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
Sets the size property for the archive entry.
=head2 archive_entry_set_sourcepath
my $status = archive_entry_set_sourcepath($entry, $sourcepath);
Sets the sourcepath property for the archive entry object.
=head2 archive_entry_set_stat
my $status = archive_entry_stat($entry, $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $atime, $mtime, $ctime);
Converts the various fields in the format used by L<stat|perlfunc#stat> to the fields store in the archive entry.
The fields C<$blksize>, C<$blocks> supported by L<stat|perlfunc#stat>, are not supported by this function.
=head2 archive_entry_set_symlink
my $status = archive_entry_set_symlink($entry, $string)
Sets the symlink for the archive entry object.
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
}
=head2 archive_entry_sparse_reset
my $count = archive_entry_sparse_reset($entry);
Reset the internal sparse region iterator for the entry (see L<archive_entry_sparse_next|Archive::Libarchive::FFI::Function#archive_entry_sparse_next> for an example).
=head2 archive_entry_stat
my($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $atime, $mtime, $ctime) = archive_entry_stat($entry);
Converts the various fields stored in the archive entry to the format used by L<stat|perlfunc#stat>.
The fields C<$blksize>, C<$blocks> supported by L<stat|perlfunc#stat>, are not supported by this function.
=head2 archive_entry_strmode
my $strmode = archive_entry_strmode($entry);
Returns a string representation of the archive entry's permission mode,
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
my $status = archive_match_include_date($archive, $flag, $date_string);
Set inclusion time by a date string
=head2 archive_match_include_file_time
my $status = archive_match_include_file_time($archive, $flag, $pathname);
Set inclusion time by a particular file
=head2 archive_match_include_gid
my $status = archive_match_include_gid($archive, $gid);
The match object $archive should match entries with the given $gid
=head2 archive_match_include_gname
my $status = archive_match_include_gname($archive, $gname);
The match object $archive should match entries with the given group name
=head2 archive_match_include_pattern
my $status = archive_match_include_pattern_from_file($archive, $pattern);
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
=head2 archive_match_new
my $archive = archive_match_new();
Allocates and initializes a archive object suitable for reading and matching with an archive.
=head2 archive_match_owner_excluded
my $bool = archive_match_owner_excluded($archive, $entry);
Test if a file is excluded by its uid, gid, user name or group name.
=head2 archive_match_path_excluded
my $bool = archive_match_path_excluded($archive, $entry);
Test if pathname is excluded.
=head2 archive_match_path_unmatched_inclusions
my $count = archive_match_path_unmatched_inclusions($archive);
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
platforms that support the appropriate system calls.
Note: The C API supports passing in a stat structure for some performance benefits. Currently this is unsupported in the Perl version, and you must pass undef in as the forth argument,
for possible future compatibility.
Where necessary, user and group ids are converted to user and group names using the currently registered lookup functions above. This affects the file ownership fields and ACL values in the
struct archive_entry object.
=head2 archive_read_disk_gname
my $string = archive_read_disk_gname($archive, $gid);
Returns a group name given a gid value. By default always
returns C<undef>.
=head2 archive_read_disk_new
my $archive = archive_read_disk_new();
Allocates and initializes an archive object suitable for reading object information
from disk.
=head2 archive_read_disk_open
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
Register a callback for the lookup of GID from group names. In order to deregister call
C<archive_read_disk_set_gname_lookup> with both callback functions set to C<undef>.
See L<Archive::Libarchive::FFI::Callback> for calling conventions for the lookup and cleanup callbacks.
=head2 archive_read_disk_set_standard_lookup
my $status = archive_read_disk_set_standard_lookup($archive);
This convenience function installs a standard set of user and group name lookup functions.
These functions use C<getpwuid> and C<getgrgid> to convert ids to names, defaulting to C<undef>.
if the names cannot be looked up. These functions also implement a simple memory cache to
reduce the number of calls to C<getpwuid> and C<getgrgid>.
=head2 archive_read_disk_set_symlink_hybrid
my $status = archive_read_disk_set_symlink_hybrid($archive);
This sets the mode used for handling symbolic links. The "hybrid" mode currently
behaves identically to the "logical" mode.
=head2 archive_read_disk_set_symlink_logical
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
my $status = archive_read_disk_set_uname_lookup($archive, $data, $lookup_callback, $cleanup_callback);
Register a callback for the lookup of UID from user names. In order to deregister call
C<archive_read_disk_setugname_lookup> with both callback functions set to C<undef>.
See L<Archive::Libarchive::FFI::Callback> for calling conventions for the lookup and cleanup callbacks.
=head2 archive_read_disk_uname
my $string = archive_read_disk_uname($archive, $gid);
Returns a user name given a uid value. By default always
returns C<undef>.
=head2 archive_read_extract
my $status = archive_read_extract($archive, $entry, $flags);
A convenience function that wraps the corresponding archive_write_disk interfaces. The first call to L<archive_read_extract|Archive::Libarchive::FFI::Function#archive_read_extract> creates a restore object using L<archive_write_disk_new|Archive::Lib...
L<archive_write_disk_set_standard_lookup|Archive::Libarchive::FFI::Function#archive_write_disk_set_standard_lookup>, then transparently invokes L<archive_write_disk_set_options|Archive::Libarchive::FFI::Function#archive_write_disk_set_options>, L<arc...
lib/Archive/Libarchive/FFI/Function.pod view on Meta::CPAN
This function returns the number of bytes actually written, or -1 on error.
=head2 archive_write_data_block
my $count_or_status = archive_write_data_block($archive, $buffer, $offset);
Writes the buffer to the current entry in the given archive
starting at the given offset.
=head2 archive_write_disk_gid
my $int64 = archive_write_disk_gid($archive, $string, $int64);
Undocumented libarchive function.
=head2 archive_write_disk_new
my $archive = archive_write_disk_new();
Allocates and initializes a struct archive object suitable for
writing objects to disk.
t/common_entry.t view on Meta::CPAN
diag $@ if $@;
is eval { archive_entry_strmode($e) }, '-rw-r--r-- ', 'archive_entry_strmode';
diag $@ if $@;
is archive_entry_uid($e), 0, 'archive_entry_uid = 0';
$r = archive_entry_set_uid($e, 101);
is $r, ARCHIVE_OK, 'archive_entry_set_uid';
is archive_entry_uid($e), 101, 'archive_entry_uid = 101';
is eval { archive_entry_gid($e) }, 0, 'archive_entry_gid = 0';
diag $@ if $@;
$r = eval { archive_entry_set_gid($e, 201) };
diag $@ if $@;
is $r, ARCHIVE_OK, 'archive_entry_set_gid';
is eval { archive_entry_gid($e) }, 201, 'archive_entry_gid = 201';
diag $@ if $@;
$r = archive_entry_set_nlink($e, 5);
is $r, ARCHIVE_OK, 'archive_entry_set_nlink';
is eval { archive_entry_nlink($e) }, 5, 'archive_entry_nlink';
diag $@ if $@;
SKIP: {
skip 'requires archive_entry_dev_is_set', 1 unless Archive::Libarchive::FFI->can('archive_entry_dev_is_set');
t/common_match_owner.t view on Meta::CPAN
ok archive_match_owner_excluded($m, $e), 'archive_match_owner_excluded (1003)';
ok archive_match_excluded($m,$e), 'archive_match_excluded (1003)';
$r = archive_match_free($m);
is $r, ARCHIVE_OK, 'archive_match_free';
$r = archive_entry_free($e);
is $r, ARCHIVE_OK, 'archive_entry_free';
};
subtest gid => sub {
plan tests => 21;
my $m = archive_match_new();
ok $m, 'archive_match_new';
my $e = archive_entry_new();
ok $e, 'archive_entry_new';
$r = archive_match_include_gid($m, 1000);
is $r, ARCHIVE_OK, 'archive_match_include_gid 1000';
$r = archive_match_include_gid($m, 1002);
is $r, ARCHIVE_OK, 'archive_match_include_gid 1002';
$r = archive_entry_set_gid($e, 0);
is $r, ARCHIVE_OK, 'archive_entry_set_gid 0';
ok archive_match_owner_excluded($m, $e), 'archive_match_owner_excluded (0)';
ok archive_match_excluded($m,$e), 'archive_match_excluded (0)';
$r = archive_entry_set_gid($e, 1000);
is $r, ARCHIVE_OK, 'archive_entry_set_gid 1000';
ok !archive_match_owner_excluded($m, $e), 'archive_match_owner_excluded (1000)';
ok !archive_match_excluded($m,$e), 'archive_match_excluded (1000)';
$r = archive_entry_set_gid($e, 1001);
is $r, ARCHIVE_OK, 'archive_entry_set_gid 1001';
ok archive_match_owner_excluded($m, $e), 'archive_match_owner_excluded (1001)';
ok archive_match_excluded($m,$e), 'archive_match_excluded (1001)';
$r = archive_entry_set_gid($e, 1002);
is $r, ARCHIVE_OK, 'archive_entry_set_gid 1002';
ok !archive_match_owner_excluded($m, $e), 'archive_match_owner_excluded (1002)';
ok !archive_match_excluded($m,$e), 'archive_match_excluded (1002)';
$r = archive_entry_set_gid($e, 1003);
is $r, ARCHIVE_OK, 'archive_entry_set_gid 1002';
ok archive_match_owner_excluded($m, $e), 'archive_match_owner_excluded (1003)';
ok archive_match_excluded($m,$e), 'archive_match_excluded (1003)';
$r = archive_match_free($m);
is $r, ARCHIVE_OK, 'archive_match_free';
$r = archive_entry_free($e);
is $r, ARCHIVE_OK, 'archive_entry_free';
};
t/common_stat.t view on Meta::CPAN
subtest 'archive_entry_stat' => sub {
plan tests => 10;
my $entry = archive_entry_new();
archive_entry_set_dev($entry, 0x1234);
archive_entry_set_ino($entry, 0x5678);
archive_entry_set_mode($entry, 0400);
archive_entry_set_nlink($entry, 1);
archive_entry_set_uid($entry, 500);
archive_entry_set_gid($entry, 501);
archive_entry_set_rdev($entry, 0x1357);
archive_entry_set_atime($entry, 123456789, 123456789);
archive_entry_set_mtime($entry, 123456779, 123456779);
archive_entry_set_ctime($entry, 123456769, 123456769);
my($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $atime, $mtime, $ctime) = eval { archive_entry_stat($entry) };
diag $@ if $@;
is $dev, 0x1234, 'dev';
is $ino, 0x5678, 'ino';
is $mode, 0400, 'mode';
is $nlink, 1, 'nlink';
is $uid, 500, 'uid';
is $gid, 501, 'gid';
is $rdev, 0x1357, 'rdev';
is $atime, 123456789, 'atime';
is $mtime, 123456779, 'mtime';
is $ctime, 123456769, 'ctime';
archive_entry_free($entry);
};
subtest 'archive_entry_set_stat' => sub {
t/common_stat.t view on Meta::CPAN
my $entry = archive_entry_new();
eval { archive_entry_set_stat($entry,0x1234,0x5678,0400,1,500,501,0x1357,123456789,123456779,123456769) };
diag $@ if $@;
my $dev = archive_entry_dev($entry);
my $ino = archive_entry_ino($entry);
my $mode = archive_entry_mode($entry);
my $nlink = archive_entry_nlink($entry);
my $uid = archive_entry_uid($entry);
my $gid = archive_entry_gid($entry);
my $rdev = archive_entry_rdev($entry);
my $atime = archive_entry_atime($entry);
my $mtime = archive_entry_mtime($entry);
my $ctime = archive_entry_ctime($entry);
is $dev, 0x1234, 'dev';
is $ino, 0x5678, 'ino';
is $mode, 0400, 'mode';
is $nlink, 1, 'nlink';
is $uid, 500, 'uid';
is $gid, 501, 'gid';
is $rdev, 0x1357, 'rdev';
is $atime, 123456789, 'atime';
is $mtime, 123456779, 'mtime';
is $ctime, 123456769, 'ctime';
archive_entry_free($entry);
};
t/common_uid_gid_lookup.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use Archive::Libarchive::FFI qw( :all );
plan skip_all => 'requires archive_write_disk_gid' unless Archive::Libarchive::FFI->can('archive_write_disk_gid');
plan tests => 7;
# based on test_write_disk_lookup.c
my $gmagic = 0x13579;
my $umagic = 0x1234;
my $a = archive_write_disk_new();
ok $a, 'archive_write_disk_new';
subtest 'Default uname/gname lookup always return ID.' => sub {
plan tests => 5;
is archive_write_disk_gid($a, '', 0), 0, 'gid "",0 = 0';
is archive_write_disk_gid($a, 'root', 12), 12, 'gid root,12 = 12';
is archive_write_disk_gid($a, 'wheel', 12), 12, 'gid wheel,12 = 12';
is archive_write_disk_uid($a, '', 0), 0, 'uid "",0 = 0';
is archive_write_disk_uid($a, 'root', 18), 18, 'uid root,18 = 18';
};
subtest 'Register some weird lookup functions' => sub {
plan tests => 1;
my $r = eval { archive_write_disk_set_group_lookup($a, \$gmagic, \&group_lookup, \&group_cleanup) };
diag $@ if $@;
is $r, ARCHIVE_OK, 'archive_write_disk_set_group_lookup';
};
subtest 'Verify that our new function got called.' => sub {
plan tests => 2;
is archive_write_disk_gid($a, "FOOGROUP", 8), 73, 'gid FOOGROUP 8 = 73';
is archive_write_disk_gid($a, "NOTFOOGROUP", 8), 1, 'gid NOTFOOGROUP 8 = 1';
};
subtest 'De-register.' => sub {
plan tests => 2;
my $r = eval { archive_write_disk_set_group_lookup($a, undef, undef, undef) };
diag $@ if $@;
is $r, ARCHIVE_OK, 'archive_write_disk_set_group_lookup';
is $gmagic, 0x2468, 'Ensure our cleanup function got called.';
};
t/common_uid_gid_lookup.t view on Meta::CPAN
sub group_cleanup
{
my($data) = @_;
die unless $$data == 0x13579;
$$data = 0x2468;
}
sub group_lookup
{
my($data, $name, $gid) = @_;
die unless $$data == 0x13579;
return 1 if $name ne 'FOOGROUP';
return 73;
}
sub user_cleanup
{
my($data) = @_;
die unless $$data == 0x1234;
$$data = 0x2345;
t/common_user_group_lookup.t view on Meta::CPAN
sub gname_cleanup
{
my($data) = @_;
die unless $$data == 0x13579;
$$data = 0x2468;
}
sub gname_lookup
{
my($data, $gid) = @_;
return "FOOGROUP" if $gid == 1;
return "NOTFOOGROUP";
}
sub uname_cleanup
{
my($data) = @_;
die unless $$data == 0x1234;
$$data = 0x2345;
}