overload.pl shouldnt update its output unconditionally
[p5sagit/p5-mst-13.2.git] / ext / IO-Compress / lib / IO / Uncompress / Adapter / Bunzip2.pm
CommitLineData
319fab50 1package IO::Uncompress::Adapter::Bunzip2;
2
3use strict;
4use warnings;
5use bytes;
6
80b215cb 7use IO::Compress::Base::Common 2.019 qw(:Status);
319fab50 8
80b215cb 9use Compress::Raw::Bzip2 2.019 ;
319fab50 10
11our ($VERSION, @ISA);
80b215cb 12$VERSION = '2.019';
319fab50 13
14sub mkUncompObject
15{
16 my $small = shift || 0;
17 my $verbosity = shift || 0;
18
ea6efd2c 19 my ($inflate, $status) = new Compress::Raw::Bunzip2(1, 1, $small, $verbosity, 1);
319fab50 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 } ;
29
30}
31
32sub uncompr
33{
34 my $self = shift ;
35 my $from = shift ;
36 my $to = shift ;
37 my $eof = shift ;
38
39 my $inf = $self->{Inf};
40
41 my $status = $inf->bzinflate($from, $to);
42 $self->{ErrorNo} = $status;
43
319fab50 44 if ($status != BZ_OK && $status != BZ_STREAM_END )
45 {
46 $self->{Error} = "Inflation Error: $status";
47 return STATUS_ERROR;
48 }
49
50
51 return STATUS_OK if $status == BZ_OK ;
52 return STATUS_ENDSTREAM if $status == BZ_STREAM_END ;
53 return STATUS_ERROR ;
54}
55
56
319fab50 57sub reset
58{
59 my $self = shift ;
60
61 my ($inf, $status) = new Compress::Raw::Bunzip2();
62 $self->{ErrorNo} = ($status == BZ_OK) ? 0 : $status ;
63
64 if ($status != BZ_OK)
65 {
66 $self->{Error} = "Cannot create Inflate object: $status";
67 return STATUS_ERROR;
68 }
69
70 $self->{Inf} = $inf;
71
72 return STATUS_OK ;
73}
74
319fab50 75sub compressedBytes
76{
77 my $self = shift ;
78 $self->{Inf}->compressedBytes();
79}
80
81sub uncompressedBytes
82{
83 my $self = shift ;
84 $self->{Inf}->uncompressedBytes();
85}
86
87sub crc32
88{
89 my $self = shift ;
90 #$self->{Inf}->crc32();
91}
92
93sub adler32
94{
95 my $self = shift ;
96 #$self->{Inf}->adler32();
97}
98
99sub sync
100{
101 my $self = shift ;
102 #( $self->{Inf}->inflateSync(@_) == BZ_OK)
103 # ? STATUS_OK
104 # : STATUS_ERROR ;
105}
106
107
1081;
109
110__END__
111