blib/lib/IO/Compress/RawDeflate.pm

filter: Statementstmt 100% 100 / 100 Branchbran 70.0% 14 / 20 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 22 / 22 Podpod 23.0% 3 / 13 totaltotal 88.1% 141 / 160 CC 12 SCAR 13.6
CC
12
Cov
94%
createMerge
10.2
mkComp
2.0
deflateParams
2.0
CRAP 3.9
« blib/lib/IO/Compress/Adapter/Bzip2.pm ↑ Summary blib/lib/IO/Uncompress/Adapter/Inflate.pm »
1 package IO::Compress::RawDeflate ;
2  
3 # create RFC1951
4 #
5 103 ▶use strict ;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 103 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 103 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 103 ▶use IO::Compress::Base 2.225 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 103 ▶use IO::Compress::Base::Common 2.225 qw(:Status :Parse);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 103 ▶use IO::Compress::Adapter::Deflate 2.225 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 103 ▶use Compress::Raw::Zlib 2.225 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 103 require Exporter ;
15  
16 103 our ($VERSION, @ISA, @EXPORT_OK, %DEFLATE_CONSTANTS, %EXPORT_TAGS, $RawDeflateError);
17  
18 103 $VERSION = '2.225';
19 103 $RawDeflateError = '';
20  
21 103 @ISA = qw(IO::Compress::Base Exporter);
22 103 @EXPORT_OK = qw( $RawDeflateError rawdeflate ) ;
23 103 push @EXPORT_OK, @IO::Compress::Adapter::Deflate::EXPORT_OK ;
24  
25 103 %EXPORT_TAGS = %IO::Compress::Adapter::Deflate::DEFLATE_CONSTANTS;
26  
27  
28 {
29 103 my %seen;
30 103 foreach (keys %EXPORT_TAGS )
31 {
32 412 push @{$EXPORT_TAGS{constants}},
33 2472 grep { !$seen{$_}++ }
34 412 @{ $EXPORT_TAGS{$_} }
35 }
36 103 $EXPORT_TAGS{all} = $EXPORT_TAGS{constants} ;
37 }
38  
39  
40 103 %DEFLATE_CONSTANTS = %EXPORT_TAGS;
41  
42 #push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
43  
44 103 Exporter::export_ok_tags('all');
45  
46  
47  
48 sub new
49 170 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
50 170 my $class = shift ;
51  
52 170 my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$RawDeflateError);
53  
54 170 return $obj->_create(undef, @_);
55 }
56  
57 sub rawdeflate
58 152 ▶{
Subroutine rawdeflate: called CC=1 SCAR=0.0
Pod documented
59 152 my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$RawDeflateError);
60 152 return $obj->_def(@_);
61 }
62  
63 sub ckParams
64 646 ▶{
Subroutine ckParams: called CC=1 SCAR=0.0
Pod undocumented
65 646 my $self = shift ;
66 646 my $got = shift;
67  
68 646 return 1 ;
69 }
70  
71 sub mkComp
72 725 ▶{
Subroutine mkComp: called CC=2 SCAR=7.0
Pod undocumented
73 725 my $self = shift ;
74 725 my $got = shift ;
75  
76 725 my ($obj, $errstr, $errno) = IO::Compress::Adapter::Deflate::mkCompObject(
77 $got->getValue('crc32'),
78 $got->getValue('adler32'),
79 $got->getValue('level'),
80 $got->getValue('strategy')
81 );
82  
83 725 ▶ return $self->saveErrorString(undef, $errstr, $errno)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj 0 725 725
84 if ! defined $obj;
85  
86 725 return $obj;
87 }
88  
89  
90 sub mkHeader
91 294 ▶{
Subroutine mkHeader: called CC=1 SCAR=0.0
Pod undocumented
92 294 my $self = shift ;
93 294 return '';
94 }
95  
96 sub mkTrailer
97 314 ▶{
Subroutine mkTrailer: called CC=1 SCAR=0.0
Pod undocumented
98 314 my $self = shift ;
99 314 return '';
100 }
101  
102 sub mkFinalTrailer
103 287 ▶{
Subroutine mkFinalTrailer: called CC=1 SCAR=0.0
Pod undocumented
104 287 return '';
105 }
106  
107  
108 #sub newHeader
109 #{
110 # my $self = shift ;
111 # return '';
112 #}
113  
114 sub getExtraParams
115 321 ▶{
Subroutine getExtraParams: called CC=1 SCAR=0.0
Pod undocumented
116 321 my $self = shift ;
117 321 return getZlibParams();
118 }
119  
120 103 our %PARAMS = (
121 #'method' => [IO::Compress::Base::Common::Parse_unsigned, Z_DEFLATED],
122 'level' => [IO::Compress::Base::Common::Parse_signed, Z_DEFAULT_COMPRESSION],
123 'strategy' => [IO::Compress::Base::Common::Parse_signed, Z_DEFAULT_STRATEGY],
124  
125 'crc32' => [IO::Compress::Base::Common::Parse_boolean, 0],
126 'adler32' => [IO::Compress::Base::Common::Parse_boolean, 0],
127 'merge' => [IO::Compress::Base::Common::Parse_boolean, 0],
128 );
129  
130 sub getZlibParams
131 1180 ▶{
Subroutine getZlibParams: called CC=1 SCAR=0.0
Pod undocumented
132 1180 return %PARAMS;
133 }
134  
135 sub getInverseClass
136 25 ▶{
Subroutine getInverseClass: called CC=1 SCAR=0.0
Pod undocumented
137 103 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
138 25 return ('IO::Uncompress::RawInflate',
139 \$IO::Uncompress::RawInflate::RawInflateError);
140 }
141  
142 sub getFileInfo
143 102 ▶{
Subroutine getFileInfo: called CC=1 SCAR=0.0
Pod undocumented
144 102 my $self = shift ;
145 102 my $params = shift;
146 102 my $file = shift ;
147  
148 }
149  
150 103 ▶use Fcntl qw(SEEK_SET);
Subroutine BEGIN: called CC=1 SCAR=0.0
151  
152 sub createMerge
153 75 ▶{
Subroutine createMerge: called CC=10 SCAR=23.2
Pod undocumented
154 75 my $self = shift ;
155 75 my $outValue = shift ;
156 75 my $outType = shift ;
157  
158 75 my ($invClass, $error_ref) = $self->getInverseClass();
159 75 ▶ eval "require $invClass"
Branch: 1 branch
BranchTrueFalseTotal
eval "require $invClass" or die "aaaahhhh" 75 0 75
160 or die "aaaahhhh" ;
161  
162 75 ▶ my $inf = $invClass->new( $outValue,
Branch: 1 branch
BranchTrueFalseTotal
my $inf = $invClass->new($outValue, "Transparent", 0, "AutoClose", 0, "Scan", 1) or return $self->saveErrorString(undef, "Cannot create InflateScan object: $$error_ref") 61 14 75
163 Transparent => 0,
164 #Strict => 1,
165 AutoClose => 0,
166 Scan => 1)
167 or return $self->saveErrorString(undef, "Cannot create InflateScan object: $$error_ref" ) ;
168  
169 61 my $end_offset = 0;
170 61 ▶ $inf->scan()
Branch: 1 branch
BranchTrueFalseTotal
$inf->scan or return $self->saveErrorString(undef, "Error Scanning: $$error_ref", $inf->errorNo) 60 1 61
171 or return $self->saveErrorString(undef, "Error Scanning: $$error_ref", $inf->errorNo) ;
172 60 ▶ $inf->zap($end_offset)
Branch: 1 branch
BranchTrueFalseTotal
$inf->zap($end_offset) or return $self->saveErrorString(undef, "Error Zapping: $$error_ref", $inf->errorNo) 60 0 60
173 or return $self->saveErrorString(undef, "Error Zapping: $$error_ref", $inf->errorNo) ;
174  
175 60 my $def = *$self->{Compress} = $inf->createDeflate();
176  
177 60 *$self->{Header} = *$inf->{Info}{Header};
178 60 *$self->{UnCompSize} = *$inf->{UnCompSize}->clone();
179 60 *$self->{CompSize} = *$inf->{CompSize}->clone();
180 # TODO -- fix this
181 #*$self->{CompSize} = U64->new(0, *$self->{UnCompSize_32bit});
182  
183  
184 60 ▶ if ( $outType eq 'buffer')
Branch: 2 branches
BranchTrueFalseTotal
if ($outType eq 'buffer') { } 24 36 60
elsif ($outType eq 'handle' or $outType eq 'filename') { } 36 0 36
185 24 { substr( ${ *$self->{Buffer} }, $end_offset) = '' }
186 ▶ elsif ($outType eq 'handle' || $outType eq 'filename') {
Condition66%2/3
$outType eq "handle" or $outType eq "filename"
l!l&&r!l&&!r
12240
MC/DC0%0/2
$outType eq "handle" or $outType eq "filename"
$outType eq "handle" $outType eq "filename"
Truth table66%2/3
A or B
A= $outType eq "handle"B= $outType eq "filename"
ABresult
1X1
011
000
187 36 *$self->{FH} = *$inf->{FH} ;
188 36 delete *$inf->{FH};
189 36 *$self->{FH}->flush() ;
190 36 ▶ *$self->{Handle} = 1 if $outType eq 'handle';
Branch: 1 branch
BranchTrueFalseTotal
if $outType eq "handle" 12 24 36
191  
192 #seek(*$self->{FH}, $end_offset, SEEK_SET)
193 36 ▶ *$self->{FH}->seek($end_offset, SEEK_SET)
Branch: 1 branch
BranchTrueFalseTotal
*$self->{"FH"}->seek($end_offset, 0) or return $self->saveErrorString(undef, $!, $!) 36 0 36
194 or return $self->saveErrorString(undef, $!, $!) ;
195 }
196  
197 60 return $def ;
198 }
199  
200 #### zlib specific methods
201  
202 sub deflateParams
203 3 ▶{
Subroutine deflateParams: called CC=2 SCAR=7.0
Pod documented
204 3 my $self = shift ;
205  
206 3 my $level = shift ;
207 3 my $strategy = shift ;
208  
209 3 my $status = *$self->{Compress}->deflateParams(Level => $level, Strategy => $strategy) ;
210 return $self->saveErrorString(0, *$self->{Compress}{Error}, *$self->{Compress}{ErrorNo})
211 3 ▶ if $status == STATUS_ERROR;
Branch: 1 branch
BranchTrueFalseTotal
if $status == -1 0 3 3
212  
213 3 return 1;
214 }
215  
216  
217  
218  
219 103 1;
220  
221 __END__
« blib/lib/IO/Compress/Adapter/Bzip2.pm ↑ Summary blib/lib/IO/Uncompress/Adapter/Inflate.pm »