[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 package IO::Uncompress::Adapter::Inflate; 2 3 use strict; 4 use warnings; 5 use bytes; 6 7 use IO::Compress::Base::Common 2.008 qw(:Status); 8 use Compress::Raw::Zlib 2.008 qw(Z_OK Z_DATA_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); 9 10 our ($VERSION); 11 $VERSION = '2.008'; 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; 158 159 160 __END__ 161
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |