1package IO::Uncompress::Adapter::Bunzip2; 2 3use strict; 4use warnings; 5use bytes; 6 7use IO::Compress::Base::Common 2.212 qw(:Status); 8 9use Compress::Raw::Bzip2 2.212 ; 10 11our ($VERSION, @ISA); 12$VERSION = '2.212'; 13 14sub mkUncompObject 15{ 16 my $small = shift || 0; 17 my $verbosity = shift || 0; 18 19 my ($inflate, $status) = Compress::Raw::Bunzip2->new(1, 1, $small, $verbosity, 1); 20 21 return (undef, "Could not create Inflation object: $status", $status) 22 if $status != BZ_OK ; 23 24 return bless {'Inf' => $inflate, 25 'CompSize' => 0, 26 'UnCompSize' => 0, 27 'Error' => '', 28 'ConsumesInput' => 1, 29 } ; 30 31} 32 33sub uncompr 34{ 35 my $self = shift ; 36 my $from = shift ; 37 my $to = shift ; 38 my $eof = shift ; 39 40 my $inf = $self->{Inf}; 41 42 my $status = $inf->bzinflate($from, $to); 43 $self->{ErrorNo} = $status; 44 45 if ($status != BZ_OK && $status != BZ_STREAM_END ) 46 { 47 $self->{Error} = "Inflation Error: $status"; 48 return STATUS_ERROR; 49 } 50 51 52 return STATUS_OK if $status == BZ_OK ; 53 return STATUS_ENDSTREAM if $status == BZ_STREAM_END ; 54 return STATUS_ERROR ; 55} 56 57 58sub reset 59{ 60 my $self = shift ; 61 62 my ($inf, $status) = Compress::Raw::Bunzip2->new(); 63 $self->{ErrorNo} = ($status == BZ_OK) ? 0 : $status ; 64 65 if ($status != BZ_OK) 66 { 67 $self->{Error} = "Cannot create Inflate object: $status"; 68 return STATUS_ERROR; 69 } 70 71 $self->{Inf} = $inf; 72 73 return STATUS_OK ; 74} 75 76sub compressedBytes 77{ 78 my $self = shift ; 79 $self->{Inf}->compressedBytes(); 80} 81 82sub uncompressedBytes 83{ 84 my $self = shift ; 85 $self->{Inf}->uncompressedBytes(); 86} 87 88sub crc32 89{ 90 my $self = shift ; 91 #$self->{Inf}->crc32(); 92} 93 94sub adler32 95{ 96 my $self = shift ; 97 #$self->{Inf}->adler32(); 98} 99 100sub sync 101{ 102 my $self = shift ; 103 #( $self->{Inf}->inflateSync(@_) == BZ_OK) 104 # ? STATUS_OK 105 # : STATUS_ERROR ; 106} 107 108 1091; 110 111__END__ 112