1 package IO::Uncompress::Adapter::Identity;
7 use IO::Compress::Base::Common 2.057 qw(:Status);
8 use IO::Compress::Zip::Constants ;
14 use Compress::Raw::Zlib 2.057 ();
18 my $streaming = shift;
21 my $crc32 = 1; #shift ;
24 bless { 'CompSize' => new U64 , # 0,
26 'wantCRC32' => $crc32,
27 'CRC32' => Compress::Raw::Zlib::crc32(''),
28 'wantADLER32'=> $adler32,
29 'ADLER32' => Compress::Raw::Zlib::adler32(''),
31 'Streaming' => $streaming,
33 'DataHdrSize' => $zip64 ? 24 : 16,
46 my $len = length $$in;
49 if (defined $$in && $len) {
51 if ($self->{Streaming}) {
53 if (length $self->{Pending}) {
54 $$in = $self->{Pending} . $$in ;
56 $self->{Pending} = '';
59 my $ind = index($$in, "\x50\x4b\x07\x08");
63 if ($len >= 3 && substr($$in, -3) eq "\x50\x4b\x07") {
66 elsif ($len >= 2 && substr($$in, -2) eq "\x50\x4b") {
69 elsif ($len >= 1 && substr($$in, -1) eq "\x50") {
75 $remainder = substr($$in, $ind) ;
76 substr($$in, $ind) = '' ;
80 if (length $remainder && length $remainder < $self->{DataHdrSize}) {
81 $self->{Pending} = $remainder ;
84 elsif (length $remainder >= $self->{DataHdrSize}) {
85 my $crc = unpack "V", substr($remainder, 4);
86 if ($crc == Compress::Raw::Zlib::crc32($$in, $self->{CRC32})) {
90 $l1 = U64::newUnpack_V64(substr($remainder, 8));
91 $l2 = U64::newUnpack_V64(substr($remainder, 16));
94 $l1 = U64::newUnpack_V32(substr($remainder, 8));
95 $l2 = U64::newUnpack_V32(substr($remainder, 12));
98 my $newLen = $self->{CompSize}->clone();
99 $newLen->add(length $$in);
100 if ($l1->equal($l2) && $l1->equal($newLen) ) {
104 $$in .= substr($remainder, 0, 4) ;
105 $remainder = substr($remainder, 4);
106 #$self->{Pending} = substr($remainder, 4);
112 $$in .= substr($remainder, 0, 4) ;
113 $remainder = substr($remainder, 4);
114 #$self->{Pending} = substr($remainder, 4);
121 $self->{CompSize}->add(length $$in) ;
123 $self->{CRC32} = Compress::Raw::Zlib::crc32($$in, $self->{CRC32})
124 if $self->{wantCRC32};
126 $self->{ADLER32} = Compress::Zlib::adler32($$in, $self->{ADLER32})
127 if $self->{wantADLER32};
134 return STATUS_ENDSTREAM if $eof;
142 $self->{CompSize} = 0;
143 $self->{UnCompSize} = 0;
144 $self->{CRC32} = Compress::Raw::Zlib::crc32('');
145 $self->{ADLER32} = Compress::Raw::Zlib::adler32('');
153 # return $self->{UnCompSize} ;
159 return $self->{CompSize} ;
162 sub uncompressedBytes
165 return $self->{CompSize} ;
176 return $self->{CRC32};
182 return $self->{ADLER32};