File | /project/perl/lib/IO/Uncompress/Adapter/Inflate.pm |
Statements Executed | 18 |
Statement Execution Time | 2.26ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
0 | 0 | 0 | 0s | 0s | BEGIN | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | adler32 | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | compressedBytes | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | crc32 | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | createDeflateStream | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | getEndOffset | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | getLastBlockOffset | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | mkUncompObject | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | reset | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | resetLastBlockByte | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | sync | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | uncompr | IO::Uncompress::Adapter::Inflate::
0 | 0 | 0 | 0s | 0s | uncompressedBytes | IO::Uncompress::Adapter::Inflate::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package IO::Uncompress::Adapter::Inflate; | ||||
2 | |||||
3 | 3 | 94µs | 1 | 25µs | use strict; # spent 25µs making 1 call to strict::import |
4 | 3 | 83µs | 1 | 112µs | use warnings; # spent 112µs making 1 call to warnings::import |
5 | 3 | 118µs | 1 | 15µs | use bytes; # spent 15µs making 1 call to bytes::import |
6 | |||||
7 | 3 | 391µs | 2 | 978µs | use IO::Compress::Base::Common 2.005 qw(:Status); # spent 760µs making 1 call to Exporter::import
# spent 218µs making 1 call to UNIVERSAL::VERSION |
8 | 3 | 1.55ms | 2 | 538µs | use Compress::Raw::Zlib 2.005 qw(Z_OK Z_DATA_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); # spent 320µs making 1 call to Exporter::import
# spent 218µs making 1 call to UNIVERSAL::VERSION |
9 | |||||
10 | 1 | 5µs | our ($VERSION); | ||
11 | 1 | 6µs | $VERSION = '2.005'; | ||
12 | |||||
13 | |||||
14 | |||||
15 | sub mkUncompObject | ||||
16 | { | ||||
17 | my $crc32 = shift || 1; | ||||
18 | my $adler32 = shift || 1; | ||||
19 | my $scan = shift || 0; | ||||
20 | |||||
21 | my $inflate ; | ||||
22 | my $status ; | ||||
23 | |||||
24 | if ($scan) | ||||
25 | { | ||||
26 | ($inflate, $status) = new Compress::Raw::Zlib::InflateScan | ||||
27 | CRC32 => $crc32, | ||||
28 | ADLER32 => $adler32, | ||||
29 | WindowBits => - MAX_WBITS ; | ||||
30 | } | ||||
31 | else | ||||
32 | { | ||||
33 | ($inflate, $status) = new Compress::Raw::Zlib::Inflate | ||||
34 | AppendOutput => 1, | ||||
35 | CRC32 => $crc32, | ||||
36 | ADLER32 => $adler32, | ||||
37 | WindowBits => - MAX_WBITS ; | ||||
38 | } | ||||
39 | |||||
40 | return (undef, "Could not create Inflation object: $status", $status) | ||||
41 | if $status != Z_OK ; | ||||
42 | |||||
43 | return bless {'Inf' => $inflate, | ||||
44 | 'CompSize' => 0, | ||||
45 | 'UnCompSize' => 0, | ||||
46 | 'Error' => '', | ||||
47 | } ; | ||||
48 | |||||
49 | } | ||||
50 | |||||
51 | sub uncompr | ||||
52 | { | ||||
53 | my $self = shift ; | ||||
54 | my $from = shift ; | ||||
55 | my $to = shift ; | ||||
56 | my $eof = shift ; | ||||
57 | |||||
58 | my $inf = $self->{Inf}; | ||||
59 | |||||
60 | my $status = $inf->inflate($from, $to, $eof); | ||||
61 | $self->{ErrorNo} = $status; | ||||
62 | |||||
63 | if ($status != Z_STREAM_END && $eof) | ||||
64 | { | ||||
65 | $self->{Error} = "unexpected end of file"; | ||||
66 | return STATUS_ERROR; | ||||
67 | } | ||||
68 | |||||
69 | if ($status != Z_OK && $status != Z_STREAM_END ) | ||||
70 | { | ||||
71 | $self->{Error} = "Inflation Error: $status"; | ||||
72 | return STATUS_ERROR; | ||||
73 | } | ||||
74 | |||||
75 | |||||
76 | return STATUS_OK if $status == Z_OK ; | ||||
77 | return STATUS_ENDSTREAM if $status == Z_STREAM_END ; | ||||
78 | return STATUS_ERROR ; | ||||
79 | } | ||||
80 | |||||
81 | sub reset | ||||
82 | { | ||||
83 | my $self = shift ; | ||||
84 | $self->{Inf}->inflateReset(); | ||||
85 | |||||
86 | return STATUS_OK ; | ||||
87 | } | ||||
88 | |||||
89 | #sub count | ||||
90 | #{ | ||||
91 | # my $self = shift ; | ||||
92 | # $self->{Inf}->inflateCount(); | ||||
93 | #} | ||||
94 | |||||
95 | sub crc32 | ||||
96 | { | ||||
97 | my $self = shift ; | ||||
98 | $self->{Inf}->crc32(); | ||||
99 | } | ||||
100 | |||||
101 | sub compressedBytes | ||||
102 | { | ||||
103 | my $self = shift ; | ||||
104 | $self->{Inf}->compressedBytes(); | ||||
105 | } | ||||
106 | |||||
107 | sub uncompressedBytes | ||||
108 | { | ||||
109 | my $self = shift ; | ||||
110 | $self->{Inf}->uncompressedBytes(); | ||||
111 | } | ||||
112 | |||||
113 | sub adler32 | ||||
114 | { | ||||
115 | my $self = shift ; | ||||
116 | $self->{Inf}->adler32(); | ||||
117 | } | ||||
118 | |||||
119 | sub sync | ||||
120 | { | ||||
121 | my $self = shift ; | ||||
122 | ( $self->{Inf}->inflateSync(@_) == Z_OK) | ||||
123 | ? STATUS_OK | ||||
124 | : STATUS_ERROR ; | ||||
125 | } | ||||
126 | |||||
127 | |||||
128 | sub getLastBlockOffset | ||||
129 | { | ||||
130 | my $self = shift ; | ||||
131 | $self->{Inf}->getLastBlockOffset(); | ||||
132 | } | ||||
133 | |||||
134 | sub getEndOffset | ||||
135 | { | ||||
136 | my $self = shift ; | ||||
137 | $self->{Inf}->getEndOffset(); | ||||
138 | } | ||||
139 | |||||
140 | sub resetLastBlockByte | ||||
141 | { | ||||
142 | my $self = shift ; | ||||
143 | $self->{Inf}->resetLastBlockByte(@_); | ||||
144 | } | ||||
145 | |||||
146 | sub createDeflateStream | ||||
147 | { | ||||
148 | my $self = shift ; | ||||
149 | my $deflate = $self->{Inf}->createDeflateStream(@_); | ||||
150 | return bless {'Def' => $deflate, | ||||
151 | 'CompSize' => 0, | ||||
152 | 'UnCompSize' => 0, | ||||
153 | 'Error' => '', | ||||
154 | }, 'IO::Compress::Adapter::Deflate'; | ||||
155 | } | ||||
156 | |||||
157 | 1 | 13µs | 1; | ||
158 | |||||
159 | |||||
160 | __END__ | ||||
161 |