| 1 | ##- Nanar <nanardon@mandrake.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | #- This package provides functions to use Compress::Zlib instead of gzip. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | package MDV::Packdrakeng::zlib; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use Compress::Zlib; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use base qw(MDV::Packdrakeng); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | (our $VERSION) = q($Id: zlib.pm 225628 2007-08-09 11:00:15Z nanardon $) =~ /(\d+)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my $gzip_header = pack("C" . 10, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 31, 139, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 8, 0,0,0,0,0,0, 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # true if wrapper writes directly in archive and not into temp file | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 38 | ▶ | sub direct_write { 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
direct_write: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 10 | ▶ | sub method_info { "internal zlib $VERSION" } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
method_info: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 32 | ▶ | sub compress_handle { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compress_handle: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 32 | my ($pack, $sourcefh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 32 | my ($insize, $outsize) = (0, 0); # aka uncompressed / compressed data length | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # If $sourcefh is not set, this means we want a flush(), for end_block() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # EOF, flush compress stream, adding crc | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 32 | ▶ | if (!defined($sourcefh)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 15 | return(undef, $pack->compress_data()); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 17 | binmode $sourcefh; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 17 | ▶ | while (my $lenght = sysread($sourcefh, my $buf, $pack->{bufsize})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 154 | my $wres = $pack->compress_data($buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 154 | $outsize += $wres; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 154 | $insize += $lenght; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 17 | ($insize, $outsize) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 171 | ▶ | sub compress_data { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compress_data: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 171 | my ($pack, $data) = ($_[0], \$_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 171 | my $outsize = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 171 | ▶ | if (! defined($$data)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 15 | ▶ | if (defined($pack->{cstream_data}{object})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 13 | my ($cbuf, $status) = $pack->{cstream_data}{object}->flush(); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 13 | $outsize += syswrite($pack->{handle}, $cbuf); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 13 | $outsize += syswrite($pack->{handle}, pack("V V", $pack->{cstream_data}{crc}, $pack->{cstream_data}{object}->total_in())); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 15 | $pack->{cstream_data} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 15 | return($outsize); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 156 | ▶ | if (!defined $pack->{cstream_data}{object}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # Writing gzip header file | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 13 | $outsize += syswrite($pack->{handle}, $gzip_header); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $pack->{cstream_data}{object} = deflateInit( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | -Level => $pack->{level}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # Zlib does not create a gzip header, except with this flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 13 | -WindowBits => - MAX_WBITS(), | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 156 | $pack->{cstream_data}{crc} = crc32($$data, $pack->{cstream_data}{crc}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 156 | my ($cbuf, $status) = $pack->{cstream_data}{object}->deflate($$data); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 156 | ▶ | my $wres = syswrite($pack->{handle}, $cbuf) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
syswrite($pack->{'handle'}, $cbuf) || 0
MC/DC100%1/1
syswrite($pack->{'handle'}, $cbuf) || 0
syswrite($pack->{'handle'}, $cbuf)
Truth table100%2/2
A
A= syswrite($pack->{'handle'}, $cbuf)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 156 | ▶ | $wres == length($cbuf) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $pack->{destroyed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | die "Can't push all data to compressor\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 156 | $outsize += $wres; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 156 | return($outsize); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 27 | ▶ | sub uncompress_handle { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uncompress_handle: called CC=27 SCAR=41.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 27 | my ($pack, $destfh, $fileinfo) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 27 | ▶ | if (!defined $fileinfo) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 8 | $pack->{ustream_data} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 8 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 19 | ▶ | if (defined($pack->{ustream_data}) && ($fileinfo->{coff} != $pack->{ustream_data}{coff} || $fileinfo->{off} < ($pack->{ustream_data}{off} || 0))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition75%6/8
defined $pack->{"ustream_data"} and $fileinfo->{"coff"} != $pack->{"ustream_data"}{"coff"} || $fileinfo->{"off"} < ($pack->{"ustream_data"}{"off"} || 0)
$fileinfo->{"coff"} != $pack->{"ustream_data"}{"coff"} or $fileinfo->{"off"} < ($pack->{"ustream_data"}{"off"} || 0)
$pack->{'ustream_data'}{'off'} || 0
MC/DC66%2/3
defined $pack->{"ustream_data"} and $fileinfo->{"coff"} != $pack->{"ustream_data"}{"coff"} || $fileinfo->{"off"} < ($pack->{"ustream_data"}{"off"} || 0)
defined $pack->{"ustream_data"}
$fileinfo->{"coff"} != $pack->{"ustream_data"}{"coff"}
$fileinfo->{"off"} < ($pack->{"ustream_data"}{"off"} || 0)
MC/DC0%0/1
$pack->{'ustream_data'}{'off'} || 0
$pack->{'ustream_data'}{'off'}
Truth table75%3/4
A and B or C
A= defined $pack->{"ustream_data"}B= $fileinfo->{"coff"} != $pack->{"ustream_data"}{"coff"}C= $fileinfo->{"off"} < ($pack->{"ustream_data"}{"off"} || 0)
Truth table50%1/2
A
A= $pack->{'ustream_data'}{'off'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 10 | $pack->{ustream_data} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 19 | ▶ | if (!defined($pack->{ustream_data})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 13 | $pack->{ustream_data}{coff} = $fileinfo->{coff}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 13 | $pack->{ustream_data}{read} = 0; # uncompressed data read | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 13 | $pack->{ustream_data}{x} = inflateInit( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | -WindowBits => - MAX_WBITS(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 13 | $pack->{ustream_data}{cread} = 0; # Compressed data read | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 13 | my $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # get magic | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 13 | ▶ | if (sysread($pack->{handle}, $buf, 2) == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 13 | my @magic = unpack("C*", $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 13 | ▶ | $magic[0] == 31 && $magic[1] == 139 or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$magic[0] == 31 and $magic[1] == 139
MC/DC0%0/2
$magic[0] == 31 and $magic[1] == 139
$magic[0] == 31
$magic[1] == 139
Truth table33%1/3
A and B
A= $magic[0] == 31B= $magic[1] == 139
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | warn("Wrong magic header found\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | warn("Unexpected end of file while reading magic\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 13 | my ($method, $flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 13 | ▶ | if (sysread($pack->{handle}, $buf, 2) == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 13 | ($method, $flags) = unpack("C2", $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | warn("Unexpected end of file while reading flags\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 13 | ▶ | if (sysread($pack->{handle}, $buf, 6) != 6) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | warn("Unexpected end of file while reading gzip header\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 13 | $pack->{ustream_data}{cread} += 12; #Gzip header fixed size is already read | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 13 | ▶ | if ($flags & 0x04) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (sysread($pack->{handle}, $buf, 2) == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $len = unpack("I", $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $pack->{ustream_data}{cread} += $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if (sysread($pack->{handle}, $buf, $len) != $len) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | warn("Unexpected end of file while reading gzip header\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | warn("Unexpected end of file while reading gzip header\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 6 | sysseek($pack->{handle}, $pack->{ustream_data}{cread} - 2, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 19 | $pack->{ustream_data}{off} = $fileinfo->{off}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 19 | my $byteswritten = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 19 | ▶ | while ($byteswritten < $fileinfo->{size}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 157 | my ($l, $out, $status) = (0, $pack->{ustream_data}{buf}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 157 | $pack->{ustream_data}{buf} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 157 | ▶ | if (!defined($out)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | my $cl=sysread($pack->{handle}, my $buf, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | $pack->{ustream_data}{cread} + $pack->{bufsize} > $fileinfo->{csize} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | $fileinfo->{csize} - $pack->{ustream_data}{cread} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 151 | ▶ | $pack->{bufsize}) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | warn("Unexpected end of file\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 151 | $pack->{ustream_data}{cread} += $cl; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 151 | ($out, $status) = $pack->{ustream_data}{x}->inflate(\$buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 151 | ▶ | $status == Z_OK || $status == Z_STREAM_END or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$status == Z_OK() or $status == Z_STREAM_END()
MC/DC0%0/2
$status == Z_OK() or $status == Z_STREAM_END()
$status == Z_OK()
$status == Z_STREAM_END()
Truth table66%2/3
A or B
A= $status == Z_OK()B= $status == Z_STREAM_END()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | warn("Unable to uncompress data\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 157 | ▶ | $l = length($out) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 157 | ▶ | if ($pack->{ustream_data}{read} < $fileinfo->{off} && $pack->{ustream_data}{read} + $l > $fileinfo->{off}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pack->{"ustream_data"}{"read"} < $fileinfo->{"off"} and $pack->{"ustream_data"}{"read"} + $l > $fileinfo->{"off"}
MC/DC0%0/2
$pack->{"ustream_data"}{"read"} < $fileinfo->{"off"} and $pack->{"ustream_data"}{"read"} + $l > $fileinfo->{"off"}
$pack->{"ustream_data"}{"read"} < $fileinfo->{"off"}
$pack->{"ustream_data"}{"read"} + $l > $fileinfo->{"off"}
Truth table33%1/3
A and B
A= $pack->{"ustream_data"}{"read"} < $fileinfo->{"off"}B= $pack->{"ustream_data"}{"read"} + $l > $fileinfo->{"off"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $out = substr($out, $fileinfo->{off} - $pack->{ustream_data}{read}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 157 | $pack->{ustream_data}{read} += $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ($pack->{ustream_data}{read} <= $fileinfo->{off}) { next } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 157 | my $bw; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 157 | ▶ | if ($byteswritten + length($out) > $fileinfo->{size}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 6 | $bw = $fileinfo->{size} - $byteswritten; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 6 | $pack->{ustream_data}{buf} = substr($out, $bw); # keeping track of unwritten uncompressed data | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 6 | $pack->{ustream_data}{read} -= length($pack->{ustream_data}{buf}); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 151 | $bw = length($out); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 157 | ▶ | syswrite($destfh, $out, $bw) == $bw or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | warn "Can't write data into dest\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 157 | $byteswritten += $bw; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | $byteswritten | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 19 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||