Archive-Ar-Ng

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    use Archive::Ar::Ng;

    my $ar = Archive::Ar::Ng->new;

    $ar->read('./foo.ar');
    $ar->extract;

    $ar->add_files('./bar.tar.gz', 'bat.pl')
    $ar->add_data('newfile.txt','Some contents');

    $ar->chmod('file1', 0644);
    $ar->chown('file1', $uid, $gid);

    $ar->remove('file1', 'file2');

    my $filehash = $ar->get_content('bar.tar.gz');
    my $data = $ar->get_data('bar.tar.gz');
    my $handle = $ar->get_handle('bar.tar.gz');

    my @files = $ar->list_files();

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

use constant COMMON => 1;
use constant BSD    => 2;
use constant GNU    => 3;

sub new {
  my $class = shift;
  my $file  = shift;
  my $opts  = shift || 0;
  my $self  = bless {}, $class;
  my $defopts = {
                 chmod      => 1,
                 chown      => 1,
                 same_perms => ( $> == 0 ) ? 1 : 0,
                 symbols    => undef,
                };
  $opts = {warn => $opts} unless ref $opts;
  $self->clear();
  $self->{opts} = {( %$defopts, %{$opts} )};

  if ( $file ) {
    return unless $self->read( $file );

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

    }
    $rpos += sysread( $self->{fh}, $rbuf, $blk_size ) or return $self->_error( "$filename: $!" );
    syswrite( $fh, $rbuf, $blk_size ) or return $self->_error( "$filename: $!" );
  }
  undef $rbuf;
##--
  close $fh or return $self->_error( "$filename: $!" );
  if ( CAN_CHOWN && $self->{opts}->{chown} ) {
    chown $meta->{fuid}, $meta->{fgid}, $filename or return $self->_error( "$filename: $!" );
  }
  if ( $self->{opts}->{chmod} ) {
    my $mode = $meta->{mode};
    unless ( $self->{opts}->{same_perms} ) {
      $mode &= ~( oct( 7000 ) | ( umask | 0 ) );
    }
    chmod $mode, $filename or return $self->_error( "$filename: $!" );
  }
  utime $meta->{date}, $meta->{date}, $filename or return $self->_error( "$filename: $!" );
  return 1;
}

sub list_files {
  my $self = shift;
  return wantarray ? @{$self->{names}} : $self->{names};
}

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';



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