File Coverage

blib/lib/packdrake.pm
Criterion Covered Total %
statement 23 40 57.5
branch 4 12 33.3
condition n/a
subroutine 6 9 66.6
pod 1 6 16.6
total 34 67 50.7


line stmt bran cond sub pod time code
1             ##- Nanar
2             ##-
3             ##- This program is free software; you can redistribute it and/or modify
4             ##- it under the terms of the GNU General Public License as published by
5             ##- the Free Software Foundation; either version 2, or (at your option)
6             ##- any later version.
7             ##-
8             ##- This program is distributed in the hope that it will be useful,
9             ##- but WITHOUT ANY WARRANTY; without even the implied warranty of
10             ##- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11             ##- GNU General Public License for more details.
12             ##-
13             ##- You should have received a copy of the GNU General Public License
14             ##- along with this program; if not, write to the Free Software
15             ##- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16              
17             ##- $Id: packdrake.pm 12160 2005-11-15 12:42:54Z rgarciasuarez $
18              
19             package packdrake;
20              
21 1     1   587 use strict;
  1         2  
  1         22  
22 1     1   4 use warnings;
  1         2  
  1         21  
23 1     1   445 use MDV::Packdrakeng;
  1         10736  
  1         458  
24             our @ISA = qw(MDV::Packdrakeng);
25             our $VERSION = $MDV::Packdrakeng::VERSION;
26              
27             sub new {
28 1     1 1 9070 my ($class, $file, %options) = @_;
29             my $pack = MDV::Packdrakeng->open(
30             %options,
31             archive => $file
32 1 50       37 ) or do { print STDERR "Can't open $file: $!\n"; return undef };
  0         0  
  0         0  
33             #- rebless
34 1         488 bless($pack, $class);
35             }
36              
37             sub extract_archive {
38 1     1 0 14 my ($pack, $dir, @files) = @_;
39 1 50       14 @files or return;
40 1         27 $pack->extract($dir, @files);
41             }
42              
43             sub extract_all_archive {
44 0     0 0 0 my ($pack, $dir) = @_;
45 0         0 my ($d, $f, $l) = $pack->getcontent();
46 0         0 $pack->extract($dir, @$d, @$f, @$l);
47             }
48              
49             sub list_archive {
50 0     0 0 0 foreach my $archive (@_) {
51 0 0       0 my $pack = MDV::Packdrakeng->open(archive => $archive) or do {
52 0         0 print STDERR "Can't open $archive: $!\n";
53 0         0 next;
54             };
55 0         0 $pack->list();
56             }
57             }
58              
59             sub build_archive {
60 1     1 0 856 my ($listh, $dir, $archive, $size, $compress, $uncompress) = @_;
61 1         6 my ($comp_level) = $compress =~ m/ -(\d)(?:\s|$)/;
62 1         6 $compress =~ s/ -\d(\s|$)/$1/;
63 1 50       6 my $pack = MDV::Packdrakeng->new(
64             archive => $archive,
65             compress => $compress,
66             uncompress => $uncompress,
67             block_size => $size,
68             comp_level => $comp_level,
69             ) or return;
70 1         53001 while (my $line = <$listh>) {
71 3         806 chomp($line);
72 3 50       12 $pack->add($dir, $line) or return;
73             }
74 1         57 1;
75             }
76              
77             sub cat_archive {
78 0     0 0   foreach my $archive (@_) {
79 0 0         my $pack = MDV::Packdrakeng->open(archive => $archive) or do {
80 0           print STDERR "Can't open $archive: $!\n";
81 0           next;
82             };
83 0           (undef, my $files, undef) = $pack->getcontent();
84 0           foreach (@$files) {
85 0           $pack->extract_virtual(\*STDOUT, $_);
86             }
87             }
88             }
89              
90             1;
91              
92             __END__