line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Uncompress::Untar; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.006; |
4
|
1
|
|
|
1
|
|
68303
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
490
|
use IO::File; |
|
1
|
|
|
|
|
8508
|
|
|
1
|
|
|
|
|
107
|
|
7
|
1
|
|
|
1
|
|
547
|
use Archive::Tar::Stream; |
|
1
|
|
|
|
|
17174
|
|
|
1
|
|
|
|
|
44
|
|
8
|
1
|
|
|
1
|
|
591
|
use IO::Uncompress::AnyUncompress qw(anyuncompress $AnyUncompressError) ; |
|
1
|
|
|
|
|
70286
|
|
|
1
|
|
|
|
|
1181
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
13
|
|
|
|
|
|
|
our($VERSION)='1.02'; |
14
|
|
|
|
|
|
|
our($UntarError) = ''; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( $UntarError ) ] ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @EXPORT = qw( ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
25
|
0
|
|
|
|
|
|
my $this={}; |
26
|
0
|
|
|
|
|
|
$this->{handle}=shift; |
27
|
0
|
0
|
|
|
|
|
if(!defined $this->{handle}){warn "undef handle"; return undef;} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
$this->{z} = new IO::Uncompress::AnyUncompress $this->{handle} or return undef; |
29
|
0
|
0
|
|
|
|
|
$this->{ts} = Archive::Tar::Stream->new(infh => $this->{z}) or return undef; |
30
|
0
|
|
|
|
|
|
$this->{ts}->SafeCopy(0); |
31
|
0
|
|
|
|
|
|
$this->{opt}=shift; |
32
|
0
|
|
|
|
|
|
$this->{raw}=''; |
33
|
0
|
|
|
|
|
|
$this->{header}={}; |
34
|
0
|
|
|
|
|
|
$this->{loc}=0; |
35
|
0
|
|
|
|
|
|
$this->{i}=0; |
36
|
0
|
|
|
|
|
|
$this->{readoffset}=0; |
37
|
0
|
|
|
|
|
|
bless $this,$class; |
38
|
0
|
|
|
|
|
|
return $this; |
39
|
|
|
|
|
|
|
} # new |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub nextStream { |
43
|
0
|
|
|
0
|
1
|
|
my $this = shift ; |
44
|
0
|
|
|
|
|
|
$this->{readoffset}=0; |
45
|
0
|
0
|
|
|
|
|
if(!$this->{loc}) { |
46
|
0
|
|
|
|
|
|
$this->{header}=$this->{ts}->ReadHeader(); |
47
|
0
|
|
|
|
|
|
$this->{loc}+=512; |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
0
|
|
|
|
while(($this->{header}->{size} > $this->{i} )&&(defined $this->{raw})) { |
50
|
0
|
|
|
|
|
|
my $blks=int(($this->{header}->{size}-$this->{i}-1)/512)+1; |
51
|
0
|
0
|
|
|
|
|
$blks=1602 if($blks>1602); |
52
|
0
|
|
|
|
|
|
$this->{raw} = $this->{ts}->ReadBlocks($blks); |
53
|
0
|
|
|
|
|
|
$this->{i}+=$blks*512; |
54
|
0
|
|
|
|
|
|
$this->{loc}+=$blks*512; |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
$this->{header}=$this->{ts}->ReadHeader(); |
57
|
0
|
|
|
|
|
|
$this->{loc}+=512; $this->{i}=0; |
|
0
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
0
|
|
|
|
return 0 if(!((defined $this->{raw})&&(ref $this->{header}))); |
61
|
0
|
|
|
|
|
|
return 1; |
62
|
|
|
|
|
|
|
} # nextStream |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub getHeaderInfo { |
66
|
0
|
|
|
0
|
1
|
|
my $this = shift ; |
67
|
0
|
0
|
|
|
|
|
$this->nextStream() unless($this->{loc}); |
68
|
0
|
0
|
|
|
|
|
return undef if(!ref $this->{header}); |
69
|
0
|
|
|
|
|
|
$this->{header}->{UncompressedLength}=$this->{header}->{size}; |
70
|
0
|
|
|
|
|
|
$this->{header}->{Name}=$this->{header}->{name}; |
71
|
0
|
|
|
|
|
|
$this->{header}->{Time}=$this->{header}->{mtime}; |
72
|
0
|
|
|
|
|
|
return $this->{header}; |
73
|
|
|
|
|
|
|
} # getHeaderInfo |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub read { |
77
|
0
|
|
|
0
|
1
|
|
my $this = shift; |
78
|
0
|
|
0
|
|
|
|
my $bytes = $_[1] || 512*1600; |
79
|
0
|
|
|
|
|
|
++$this->{rec}; # debugging - block accidental recursion |
80
|
|
|
|
|
|
|
#warn "$this $bytes r=" . $this->{rec}; |
81
|
0
|
|
|
|
|
|
my $offset = $_[2]; |
82
|
0
|
0
|
|
|
|
|
die "non zero offset not implimented" if($offset); |
83
|
0
|
|
|
|
|
|
my $maxleft=$this->{header}->{size}-$this->{i}; |
84
|
0
|
0
|
|
|
|
|
$bytes=$maxleft if($bytes>$maxleft); |
85
|
0
|
0
|
0
|
|
|
|
if((!defined $this->{raw})||($bytes>length($this->{raw}))) { |
86
|
0
|
|
|
|
|
|
my $blks=int(($bytes-length( $this->{raw} )-1 )/512)+1; |
87
|
0
|
0
|
|
|
|
|
$this->{raw}.=$this->{ts}->ReadBlocks($blks) if($this->{rec}<2); |
88
|
0
|
0
|
|
|
|
|
warn "Blocked recursion $this->{rec}" if($this->{rec}>1); |
89
|
0
|
|
|
|
|
|
$this->{i}+=$blks*512; $this->{loc}+=$blks*512; |
|
0
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
0
|
|
|
|
|
|
--$this->{rec}; |
92
|
0
|
|
|
|
|
|
$_[0]=substr($this->{raw},$this->{readoffset},$bytes); |
93
|
0
|
|
|
|
|
|
$this->{raw}=substr($this->{raw},$bytes); |
94
|
|
|
|
|
|
|
#$this->{readoffset}+=$bytes; |
95
|
|
|
|
|
|
|
#warn "$this got=" . length($_[0]); |
96
|
0
|
|
|
|
|
|
return length($_[0]); |
97
|
|
|
|
|
|
|
} # read |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub close { |
100
|
0
|
|
|
0
|
0
|
|
my $this = shift; |
101
|
|
|
|
|
|
|
# $this->{ts}->close(); |
102
|
0
|
|
|
|
|
|
$this->{z}->close(); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |