File Coverage

blib/lib/IO/Uncompress/Adapter/Bunzip2.pm
Criterion Covered Total %
statement 38 48 79.1
branch 8 12 66.6
condition 6 7 85.7
subroutine 8 13 61.5
pod 0 8 0.0
total 60 88 68.1


line stmt bran cond sub pod time code
1             package IO::Uncompress::Adapter::Bunzip2;
2              
3 87     87   4052 use strict;
  87         211  
  87         3614  
4 87     87   455 use warnings;
  87         175  
  87         7547  
5 87     87   469 use bytes;
  87         220  
  87         713  
6              
7 87     87   3587 use IO::Compress::Base::Common 2.219 qw(:Status);
  87         1947  
  87         15608  
8              
9 87     87   38708 use Compress::Raw::Bzip2 2.218 ;
  87         119110  
  87         67683  
10              
11             our ($VERSION, @ISA);
12             $VERSION = '2.219';
13              
14             sub mkUncompObject
15             {
16 798   100 798 0 2949 my $small = shift || 0;
17 798   50     2544 my $verbosity = shift || 0;
18              
19 798         16523 my ($inflate, $status) = Compress::Raw::Bunzip2->new(1, 1, $small, $verbosity, 1);
20              
21 798 50       3792 return (undef, "Could not create Inflation object: $status", $status)
22             if $status != BZ_OK ;
23              
24 798         9984 return bless {'Inf' => $inflate,
25             'CompSize' => 0,
26             'UnCompSize' => 0,
27             'Error' => '',
28             'ConsumesInput' => 1,
29             } ;
30              
31             }
32              
33             sub uncompr
34             {
35 1105     1105 0 2028 my $self = shift ;
36 1105         5874 my $from = shift ;
37 1105         1802 my $to = shift ;
38 1105         2080 my $eof = shift ;
39              
40 1105         2334 my $inf = $self->{Inf};
41              
42 1105         39509 my $status = $inf->bzinflate($from, $to);
43 1105         3587 $self->{ErrorNo} = $status;
44              
45 1105 100 100     3871 if ($status != BZ_OK && $status != BZ_STREAM_END )
46             {
47 2         27 $self->{Error} = "Inflation Error: $status";
48 2         10 return STATUS_ERROR;
49             }
50              
51              
52 1103 100       12625 return STATUS_OK if $status == BZ_OK ;
53 1101 50       4793 return STATUS_ENDSTREAM if $status == BZ_STREAM_END ;
54 0         0 return STATUS_ERROR ;
55             }
56              
57              
58             sub reset
59             {
60 350     350 0 649 my $self = shift ;
61              
62 350         4288 my ($inf, $status) = Compress::Raw::Bunzip2->new();
63 350 50       1466 $self->{ErrorNo} = ($status == BZ_OK) ? 0 : $status ;
64              
65 350 50       2300 if ($status != BZ_OK)
66             {
67 0         0 $self->{Error} = "Cannot create Inflate object: $status";
68 0         0 return STATUS_ERROR;
69             }
70              
71 350         2729 $self->{Inf} = $inf;
72              
73 350         956 return STATUS_OK ;
74             }
75              
76             sub compressedBytes
77             {
78 0     0 0   my $self = shift ;
79 0           $self->{Inf}->compressedBytes();
80             }
81              
82             sub uncompressedBytes
83             {
84 0     0 0   my $self = shift ;
85 0           $self->{Inf}->uncompressedBytes();
86             }
87              
88             sub crc32
89             {
90 0     0 0   my $self = shift ;
91             #$self->{Inf}->crc32();
92             }
93              
94             sub adler32
95             {
96 0     0 0   my $self = shift ;
97             #$self->{Inf}->adler32();
98             }
99              
100             sub sync
101             {
102 0     0 0   my $self = shift ;
103             #( $self->{Inf}->inflateSync(@_) == BZ_OK)
104             # ? STATUS_OK
105             # : STATUS_ERROR ;
106             }
107              
108              
109             1;
110              
111             __END__