line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Compress::RawDeflate ; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# create RFC1951 |
4
|
|
|
|
|
|
|
# |
5
|
66
|
|
|
66
|
|
38531
|
use strict ; |
|
66
|
|
|
|
|
181
|
|
|
66
|
|
|
|
|
1735
|
|
6
|
66
|
|
|
66
|
|
301
|
use warnings; |
|
66
|
|
|
|
|
140
|
|
|
66
|
|
|
|
|
1303
|
|
7
|
66
|
|
|
66
|
|
6362
|
use bytes; |
|
66
|
|
|
|
|
237
|
|
|
66
|
|
|
|
|
305
|
|
8
|
|
|
|
|
|
|
|
9
|
66
|
|
|
66
|
|
30127
|
use IO::Compress::Base 2.204 ; |
|
66
|
|
|
|
|
1892
|
|
|
66
|
|
|
|
|
3648
|
|
10
|
66
|
|
|
66
|
|
426
|
use IO::Compress::Base::Common 2.204 qw(:Status :Parse); |
|
66
|
|
|
|
|
787
|
|
|
66
|
|
|
|
|
9578
|
|
11
|
66
|
|
|
66
|
|
27377
|
use IO::Compress::Adapter::Deflate 2.204 ; |
|
66
|
|
|
|
|
1941
|
|
|
66
|
|
|
|
|
11096
|
|
12
|
66
|
|
|
66
|
|
453
|
use Compress::Raw::Zlib 2.204 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); |
|
66
|
|
|
|
|
787
|
|
|
66
|
|
|
|
|
36421
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require Exporter ; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our ($VERSION, @ISA, @EXPORT_OK, %DEFLATE_CONSTANTS, %EXPORT_TAGS, $RawDeflateError); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$VERSION = '2.204'; |
19
|
|
|
|
|
|
|
$RawDeflateError = ''; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
@ISA = qw(IO::Compress::Base Exporter); |
22
|
|
|
|
|
|
|
@EXPORT_OK = qw( $RawDeflateError rawdeflate ) ; |
23
|
|
|
|
|
|
|
push @EXPORT_OK, @IO::Compress::Adapter::Deflate::EXPORT_OK ; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
%EXPORT_TAGS = %IO::Compress::Adapter::Deflate::DEFLATE_CONSTANTS; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
my %seen; |
30
|
|
|
|
|
|
|
foreach (keys %EXPORT_TAGS ) |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
push @{$EXPORT_TAGS{constants}}, |
33
|
|
|
|
|
|
|
grep { !$seen{$_}++ } |
34
|
|
|
|
|
|
|
@{ $EXPORT_TAGS{$_} } |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
$EXPORT_TAGS{all} = $EXPORT_TAGS{constants} ; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
%DEFLATE_CONSTANTS = %EXPORT_TAGS; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Exporter::export_ok_tags('all'); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new |
49
|
|
|
|
|
|
|
{ |
50
|
168
|
|
|
168
|
1
|
152514
|
my $class = shift ; |
51
|
|
|
|
|
|
|
|
52
|
168
|
|
|
|
|
614
|
my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$RawDeflateError); |
53
|
|
|
|
|
|
|
|
54
|
168
|
|
|
|
|
655
|
return $obj->_create(undef, @_); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub rawdeflate |
58
|
|
|
|
|
|
|
{ |
59
|
152
|
|
|
152
|
1
|
174527
|
my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$RawDeflateError); |
60
|
152
|
|
|
|
|
484
|
return $obj->_def(@_); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub ckParams |
64
|
|
|
|
|
|
|
{ |
65
|
642
|
|
|
642
|
0
|
995
|
my $self = shift ; |
66
|
642
|
|
|
|
|
890
|
my $got = shift; |
67
|
|
|
|
|
|
|
|
68
|
642
|
|
|
|
|
1548
|
return 1 ; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub mkComp |
72
|
|
|
|
|
|
|
{ |
73
|
714
|
|
|
714
|
0
|
1102
|
my $self = shift ; |
74
|
714
|
|
|
|
|
1050
|
my $got = shift ; |
75
|
|
|
|
|
|
|
|
76
|
714
|
|
|
|
|
1580
|
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
|
714
|
50
|
|
|
|
2000
|
return $self->saveErrorString(undef, $errstr, $errno) |
84
|
|
|
|
|
|
|
if ! defined $obj; |
85
|
|
|
|
|
|
|
|
86
|
714
|
|
|
|
|
4545
|
return $obj; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub mkHeader |
91
|
|
|
|
|
|
|
{ |
92
|
294
|
|
|
294
|
0
|
517
|
my $self = shift ; |
93
|
294
|
|
|
|
|
762
|
return ''; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub mkTrailer |
97
|
|
|
|
|
|
|
{ |
98
|
314
|
|
|
314
|
0
|
495
|
my $self = shift ; |
99
|
314
|
|
|
|
|
660
|
return ''; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub mkFinalTrailer |
103
|
|
|
|
|
|
|
{ |
104
|
287
|
|
|
287
|
0
|
671
|
return ''; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#sub newHeader |
109
|
|
|
|
|
|
|
#{ |
110
|
|
|
|
|
|
|
# my $self = shift ; |
111
|
|
|
|
|
|
|
# return ''; |
112
|
|
|
|
|
|
|
#} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub getExtraParams |
115
|
|
|
|
|
|
|
{ |
116
|
319
|
|
|
319
|
0
|
483
|
my $self = shift ; |
117
|
319
|
|
|
|
|
614
|
return getZlibParams(); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
{ |
132
|
1135
|
|
|
1135
|
0
|
12659
|
return %PARAMS; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub getInverseClass |
136
|
|
|
|
|
|
|
{ |
137
|
66
|
|
|
66
|
|
464
|
no warnings 'once'; |
|
66
|
|
|
|
|
162
|
|
|
66
|
|
|
|
|
6028
|
|
138
|
23
|
|
|
23
|
0
|
56
|
return ('IO::Uncompress::RawInflate', |
139
|
|
|
|
|
|
|
\$IO::Uncompress::RawInflate::RawInflateError); |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub getFileInfo |
143
|
|
|
|
|
|
|
{ |
144
|
102
|
|
|
102
|
0
|
190
|
my $self = shift ; |
145
|
102
|
|
|
|
|
127
|
my $params = shift; |
146
|
102
|
|
|
|
|
194
|
my $file = shift ; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
66
|
|
|
66
|
|
445
|
use Fcntl qw(SEEK_SET); |
|
66
|
|
|
|
|
133
|
|
|
66
|
|
|
|
|
28283
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub createMerge |
153
|
|
|
|
|
|
|
{ |
154
|
69
|
|
|
69
|
0
|
111
|
my $self = shift ; |
155
|
69
|
|
|
|
|
92
|
my $outValue = shift ; |
156
|
69
|
|
|
|
|
89
|
my $outType = shift ; |
157
|
|
|
|
|
|
|
|
158
|
69
|
|
|
|
|
159
|
my ($invClass, $error_ref) = $self->getInverseClass(); |
159
|
69
|
50
|
|
|
|
3604
|
eval "require $invClass" |
160
|
|
|
|
|
|
|
or die "aaaahhhh" ; |
161
|
|
|
|
|
|
|
|
162
|
69
|
100
|
|
|
|
355
|
my $inf = $invClass->new( $outValue, |
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
|
60
|
|
|
|
|
93
|
my $end_offset = 0; |
170
|
60
|
50
|
|
|
|
158
|
$inf->scan() |
171
|
|
|
|
|
|
|
or return $self->saveErrorString(undef, "Error Scanning: $$error_ref", $inf->errorNo) ; |
172
|
60
|
50
|
|
|
|
157
|
$inf->zap($end_offset) |
173
|
|
|
|
|
|
|
or return $self->saveErrorString(undef, "Error Zapping: $$error_ref", $inf->errorNo) ; |
174
|
|
|
|
|
|
|
|
175
|
60
|
|
|
|
|
154
|
my $def = *$self->{Compress} = $inf->createDeflate(); |
176
|
|
|
|
|
|
|
|
177
|
60
|
|
|
|
|
158
|
*$self->{Header} = *$inf->{Info}{Header}; |
178
|
60
|
|
|
|
|
204
|
*$self->{UnCompSize} = *$inf->{UnCompSize}->clone(); |
179
|
60
|
|
|
|
|
130
|
*$self->{CompSize} = *$inf->{CompSize}->clone(); |
180
|
|
|
|
|
|
|
# TODO -- fix this |
181
|
|
|
|
|
|
|
#*$self->{CompSize} = U64->new(0, *$self->{UnCompSize_32bit}); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
60
|
100
|
66
|
|
|
232
|
if ( $outType eq 'buffer') |
|
|
50
|
|
|
|
|
|
185
|
24
|
|
|
|
|
39
|
{ substr( ${ *$self->{Buffer} }, $end_offset) = '' } |
|
24
|
|
|
|
|
66
|
|
186
|
|
|
|
|
|
|
elsif ($outType eq 'handle' || $outType eq 'filename') { |
187
|
36
|
|
|
|
|
75
|
*$self->{FH} = *$inf->{FH} ; |
188
|
36
|
|
|
|
|
90
|
delete *$inf->{FH}; |
189
|
36
|
|
|
|
|
144
|
*$self->{FH}->flush() ; |
190
|
36
|
100
|
|
|
|
90
|
*$self->{Handle} = 1 if $outType eq 'handle'; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
#seek(*$self->{FH}, $end_offset, SEEK_SET) |
193
|
36
|
50
|
|
|
|
112
|
*$self->{FH}->seek($end_offset, SEEK_SET) |
194
|
|
|
|
|
|
|
or return $self->saveErrorString(undef, $!, $!) ; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
60
|
|
|
|
|
703
|
return $def ; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#### zlib specific methods |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub deflateParams |
203
|
|
|
|
|
|
|
{ |
204
|
3
|
|
|
3
|
1
|
30
|
my $self = shift ; |
205
|
|
|
|
|
|
|
|
206
|
3
|
|
|
|
|
6
|
my $level = shift ; |
207
|
3
|
|
|
|
|
5
|
my $strategy = shift ; |
208
|
|
|
|
|
|
|
|
209
|
3
|
|
|
|
|
15
|
my $status = *$self->{Compress}->deflateParams(Level => $level, Strategy => $strategy) ; |
210
|
|
|
|
|
|
|
return $self->saveErrorString(0, *$self->{Compress}{Error}, *$self->{Compress}{ErrorNo}) |
211
|
3
|
50
|
|
|
|
9
|
if $status == STATUS_ERROR; |
212
|
|
|
|
|
|
|
|
213
|
3
|
|
|
|
|
12
|
return 1; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
1; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
__END__ |