Archive-Ar-Libarchive

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  - require Alien::Libarchive 0.20

2.00      2014-06-18 10:14:24 -0400
  - this version serves primarily to bring the API in line with
    Archive::Ar 2.00
  - added methods
    - set_opt
    - get_opt
    - clear
    - get_data
    - chmod
    - chown
    - type
    - rename
    - extract
    - extract_filename
    - error
    - contains_file
  - deprecated methods
    - DEBUG
    - set_output_format_bsd

MANIFEST  view on Meta::CPAN

t/35_list.t
t/40_mode.t
t/45_content.t
t/50_remove.t
t/55_write.t
t/60_extract.t
t/65_gnu.t
t/66_gnu_symtab.t
t/70_bsd.t
t/basic.t
t/chmod.t
t/chown.t
t/clear.t
t/common.t
t/contains_file.t
t/error.t
t/extract_file.t
t/foo.ar
t/write.t
typemap
windows.yml

README  view on Meta::CPAN

    Assign option $name value $value. Supported options include:

    warn

      Warning level. Levels are zero for no warnings, 1 for brief warnings,
      and 2 for warnings with a stack trace. Default is zero.

      Warnings that originate with libarchive itself will not include a
      stacktrace, even with a warn level set to 2.

    chmod

      Change the file permissions of files created when extracting. Default
      is true (non-zero).

      This option is provided only for compatibility with Archive::Ar.
      Libarchive does not provide an equivalent to this option, so setting
      it to false will has no effect.

    same_perms

README  view on Meta::CPAN

    the permissions and modification time stored in the archive, and, if
    possible, the user and group ownership. Returns true on success, undef
    for failure.

 rename

     $ar->rename($filename, $newname);

    Changes the name of a file in the in-memory archive.

 chmod

     $ar->chmod($filename, $mode);

    Change the permission mode of the member to $mode.

 chown

     $ar->chown($filename, $uid, $gid);
     $ar->chown($filename, $uid);

    Change the ownership of the member to user id $udi and (optionally)
    group id $gid. Negative id values are ignored.

lib/Archive/Ar/Libarchive.pm  view on Meta::CPAN

  my($self, $data) = @_;

  open my $fh, '<', \$data;
  binmode $fh;
  my $ret = $self->read($fh);

  $ret;
}


sub chmod
{
  my($self, $filename, $mode) = @_;
  $self->_chmod($filename, $mode + 0 eq $mode ? $mode : oct($mode));
}


sub chown
{
  my($self, $filename, $uid, $gid) = @_;
  $self->_chown($filename, $uid, $gid);
}


lib/Archive/Ar/Libarchive.pm  view on Meta::CPAN

=over 4

=item warn

Warning level.  Levels are zero for no warnings, 1 for brief warnings,
and 2 for warnings with a stack trace.  Default is zero.

Warnings that originate with libarchive itself will not include a
stacktrace, even with a warn level set to 2.

=item chmod

Change the file permissions of files created when extracting.  Default
is true (non-zero).

This option is provided only for compatibility with L<Archive::Ar>.
Libarchive does not provide an equivalent to this option, so setting
it to false will has no effect.

=item same_perms

lib/Archive/Ar/Libarchive.pm  view on Meta::CPAN

the permissions and modification time stored in the archive, and, if
possible, the user and group ownership.  Returns true on success,
C<undef> for failure.

=head2 rename

 $ar->rename($filename, $newname);

Changes the name of a file in the in-memory archive.

=head2 chmod

 $ar->chmod($filename, $mode);

Change the permission mode of the member to C<$mode>.

=head2 chown

 $ar->chown($filename, $uid, $gid);
 $ar->chown($filename, $uid);

Change the ownership of the member to user id C<$udi> and (optionally)
group id C<$gid>.  Negative id values are ignored.

lib/Archive/Ar/Libarchive.xs  view on Meta::CPAN

        ar->error = ar->longmess = SvREFCNT_inc(newSVpv(message,0));            \
      }

struct ar_entry;

struct ar {
  struct ar_entry *first;
  SV *callback;

  unsigned int opt_warn       : 2;
  unsigned int opt_chmod      : 1;
  unsigned int opt_same_perms : 1;
  unsigned int opt_chown      : 1;
  unsigned int opt_type       : 2;

  SV *error;
  SV *longmess;
  SV *opt_symbols;
};

struct ar_entry {

lib/Archive/Ar/Libarchive.xs  view on Meta::CPAN

_new()
  CODE:
    struct ar *self;
    Newx(self, 1, struct ar);
    self->first          = NULL;
    self->callback       = NULL;
    self->error          = NULL;
    self->longmess       = NULL;
    self->opt_symbols    = NULL;
    self->opt_warn       = 0;
    self->opt_chmod      = 1;  /* ignored */
    self->opt_same_perms = 1;  /* different: pp version this is true for root only */
    self->opt_chown      = 1;
    ar_reset(self);
    RETVAL = self;
  OUTPUT:
    RETVAL

int
set_opt(self, name, value)
    struct ar *self
    const char *name
    SV *value
  CODE:
    if(!strcmp(name, "warn"))
      RETVAL = self->opt_warn = SvIV(value);
    else if(!strcmp(name, "chmod"))
      RETVAL = self->opt_chmod = SvIV(value);
    else if(!strcmp(name, "same_perms"))
      RETVAL = self->opt_same_perms = SvIV(value);
    else if(!strcmp(name, "chown"))
      RETVAL = self->opt_chown = SvIV(value);
    else if(!strcmp(name, "type"))
      RETVAL = self->opt_type = SvIV(value);
    else if(!strcmp(name, "symbols"))
      self->opt_symbols = SvREFCNT_inc(value);  /*  TODO: make set_opt return void; maybe */
    else
      warn("unknown or unsupported option %s", name);
  OUTPUT:
    RETVAL

int
get_opt(self, name)
    struct ar *self
    const char *name
  CODE:
    if(!strcmp(name, "warn"))
      RETVAL = self->opt_warn;
    else if(!strcmp(name, "chmod"))
      RETVAL = self->opt_chmod;
    else if(!strcmp(name, "same_perms"))
      RETVAL = self->opt_same_perms;
    else if(!strcmp(name, "chown"))
      RETVAL = self->opt_chown;
    else if(!strcmp(name, "type"))
    {
      if(self->opt_type == ARCHIVE_AR_UNDEF)
        XSRETURN_EMPTY;
      else
        RETVAL = self->opt_type;

lib/Archive/Ar/Libarchive.xs  view on Meta::CPAN



void
clear(self)
    struct ar *self
  CODE:
    ar_reset(self);


int
_chmod(self, filename, mode)
    struct ar *self
    const char *filename
    int mode
  CODE:
    struct ar_entry *entry;
    entry = ar_find_by_name(self, filename);
    if(entry != NULL)
    {
      archive_entry_set_mode(entry->entry, mode);
      RETVAL = 1;

t/05_class.t  view on Meta::CPAN

can_ok $mod, 'set_opt';
can_ok $mod, 'get_opt';
can_ok $mod, 'type';
can_ok $mod, 'clear';
can_ok $mod, 'read';
can_ok $mod, 'read_memory';
can_ok $mod, 'contains_file';
can_ok $mod, 'extract';
can_ok $mod, 'extract_file';
can_ok $mod, 'rename';
can_ok $mod, 'chmod';
can_ok $mod, 'chown';
can_ok $mod, 'remove';
can_ok $mod, 'list_files';
can_ok $mod, 'add_files';
can_ok $mod, 'add_data';
can_ok $mod, 'write';
can_ok $mod, 'get_content';
can_ok $mod, 'get_data';
can_ok $mod, 'get_handle';
can_ok $mod, 'error';

t/chmod.t  view on Meta::CPAN

END { chdir $wd; }

use Archive::Ar::Libarchive;

my $dir = tempdir(CLEANUP => 1);
my $content = do {local $/ = undef; <DATA>};

umask 0;
my $ar  = Archive::Ar::Libarchive->new();
$ar->read_memory($content) or diag $ar->error;
ok $ar->chmod('foo.txt', 0100750), 'chmod';

is $ar->get_content('foo.txt')->{mode}, 0100750, 'mode is set';

__DATA__
!<arch>
foo.txt         1384344423  1000  1000  100644  9         `
hi there

bar.txt         1384344423  1000  1000  100750  31        `
this is the content of bar.txt

xs/ppport.h  view on Meta::CPAN

CHECK_MALLOC_TAINT|5.008001||Viu
CHECK_MALLOC_TOO_LATE_FOR|5.008001||Viu
check_offset_max|5.005000||Viu
check_offset_min|5.005000||Viu
check_substr|5.005000||Viu
check_type_and_open|5.009003||Viu
check_uni|5.003007||Viu
check_utf8|5.008000||Viu
check_utf8_print|5.013009||Viu
child_offset_bits|5.009003||Viu
chmod|5.005000||Viu
chsize|5.005000||Viu
ckDEAD|5.006000||Viu
ck_entersub_args_core|||iu
ck_entersub_args_list|5.013006|5.013006|
ck_entersub_args_proto|5.013006|5.013006|
ck_entersub_args_proto_or_list|5.013006|5.013006|
ckWARN2|5.006000|5.003007|p
ckWARN2_d|5.006000|5.003007|p
ckWARN3|5.007003|5.003007|p
ckWARN3_d|5.007003|5.003007|p

xs/ppport.h  view on Meta::CPAN

KEY_AUTOLOAD|5.003007||Viu
KEY_BEGIN|5.003007||Viu
KEY_bind|5.003007||Viu
KEY_binmode|5.003007||Viu
KEY_bless|5.003007||Viu
KEY_break|5.027008||Viu
KEY_caller|5.003007||Viu
KEY_catch|5.033007||Viu
KEY_chdir|5.003007||Viu
KEY_CHECK|5.006000||Viu
KEY_chmod|5.003007||Viu
KEY_chomp|5.003007||Viu
KEY_chop|5.003007||Viu
KEY_chown|5.003007||Viu
KEY_chr|5.003007||Viu
KEY_chroot|5.003007||Viu
KEY_close|5.003007||Viu
KEY_closedir|5.003007||Viu
KEY_cmp|5.003007||Viu
KEY_connect|5.003007||Viu
KEY_continue|5.003007||Viu

xs/ppport.h  view on Meta::CPAN

PERL_IS_GCC|5.032001||Viu
Perl_isinf|5.007003|5.007003|n
Perl_isnan|5.006001|5.006001|n
PERL_IS_SUBWORD_ADDR|5.027007||Viu
PERL_JNP_TO_DECIMAL|5.033001||Viu
Perl_langinfo|5.027004|5.027004|n
PERL_LANGINFO_H|5.027004||Viu
PERL_LAST_5_18_0_INTERP_MEMBER|5.017009||Viu
Perl_ldexp|5.021003|5.021003|n
PerlLIO_access|5.005000||Viu
PerlLIO_chmod|5.005000||Viu
PerlLIO_chown|5.005000||Viu
PerlLIO_chsize|5.005000||Viu
PerlLIO_close|5.005000||Viu
PerlLIO_dup2|5.005000||Viu
PerlLIO_dup2_cloexec|5.027008||Viu
PerlLIO_dup|5.005000||Viu
PerlLIO_dup_cloexec|5.027008||Viu
PerlLIO_flock|5.005000||Viu
PerlLIO_fstat|5.005000||Viu
PerlLIO_ioctl|5.005000||Viu

xs/ppport.h  view on Meta::CPAN

PERL_PATCHLEVEL_H_IMPLICIT|5.006000||Viu
PERL_PATCHNUM|5.010001||Viu
PERL_POISON_EXPR|5.019006||Viu
Perl_pow|5.006000|5.006000|n
Perl_pp_accept|5.013009||Viu
Perl_pp_aelemfast_lex|5.015000||Viu
Perl_pp_andassign|5.013009||Viu
Perl_pp_avalues|5.013009||Viu
Perl_pp_bind|5.013009||Viu
Perl_pp_bit_xor|5.013009||Viu
Perl_pp_chmod|5.013009||Viu
Perl_pp_chomp|5.013009||Viu
Perl_pp_connect|5.013009||Viu
Perl_pp_cos|5.013009||Viu
Perl_pp_custom|5.013009||Viu
Perl_pp_dbmclose|5.013009||Viu
PERL_PPDEF|5.006000||Viu
Perl_pp_dofile|5.013009||Viu
Perl_pp_dor|5.013009||Viu
Perl_pp_dorassign|5.013009||Viu
Perl_pp_dump|5.013009||Viu



( run in 0.266 second using v1.01-cache-2.11-cpan-496ff517765 )