"Fossies" - the Fresh Open Source Software Archive

Member "IO-Compress-2.093/lib/IO/Compress/Adapter/Bzip2.pm" (7 Dec 2019, 2596 Bytes) of package /linux/privat/IO-Compress-2.093.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Bzip2.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.092_vs_2.093.

    1 package IO::Compress::Adapter::Bzip2 ;
    2 
    3 use strict;
    4 use warnings;
    5 use bytes;
    6 
    7 use IO::Compress::Base::Common  2.093 qw(:Status);
    8 
    9 use Compress::Raw::Bzip2  2.093 ;
   10 
   11 our ($VERSION);
   12 $VERSION = '2.093';
   13 
   14 sub mkCompObject
   15 {
   16     my $BlockSize100K = shift ;
   17     my $WorkFactor = shift ;
   18     my $Verbosity  = shift ;
   19 
   20     $BlockSize100K = 1 if ! defined $BlockSize100K ;
   21     $WorkFactor    = 0 if ! defined $WorkFactor ;
   22     $Verbosity     = 0 if ! defined $Verbosity ;
   23 
   24     my ($def, $status) = new Compress::Raw::Bzip2(1, $BlockSize100K,
   25                                                  $WorkFactor, $Verbosity);
   26 
   27     return (undef, "Could not create Deflate object: $status", $status)
   28         if $status != BZ_OK ;
   29 
   30     return bless {'Def'        => $def,
   31                   'Error'      => '',
   32                   'ErrorNo'    => 0,
   33                  }  ;     
   34 }
   35 
   36 sub compr
   37 {
   38     my $self = shift ;
   39 
   40     my $def   = $self->{Def};
   41 
   42     my $status = $def->bzdeflate($_[0], $_[1]) ;
   43     $self->{ErrorNo} = $status;
   44 
   45     if ($status != BZ_RUN_OK)
   46     {
   47         $self->{Error} = "Deflate Error: $status"; 
   48         return STATUS_ERROR;
   49     }
   50 
   51     return STATUS_OK;    
   52 }
   53 
   54 sub flush
   55 {
   56     my $self = shift ;
   57 
   58     my $def   = $self->{Def};
   59 
   60     my $status = $def->bzflush($_[0]);
   61     $self->{ErrorNo} = $status;
   62 
   63     if ($status != BZ_RUN_OK)
   64     {
   65         $self->{Error} = "Deflate Error: $status"; 
   66         return STATUS_ERROR;
   67     }
   68 
   69     return STATUS_OK;    
   70     
   71 }
   72 
   73 sub close
   74 {
   75     my $self = shift ;
   76 
   77     my $def   = $self->{Def};
   78 
   79     my $status = $def->bzclose($_[0]);
   80     $self->{ErrorNo} = $status;
   81 
   82     if ($status != BZ_STREAM_END)
   83     {
   84         $self->{Error} = "Deflate Error: $status"; 
   85         return STATUS_ERROR;
   86     }
   87 
   88     return STATUS_OK;    
   89     
   90 }
   91 
   92 
   93 sub reset
   94 {
   95     my $self = shift ;
   96 
   97     my $outer = $self->{Outer};
   98 
   99     my ($def, $status) = new Compress::Raw::Bzip2();
  100     $self->{ErrorNo} = ($status == BZ_OK) ? 0 : $status ;
  101 
  102     if ($status != BZ_OK)
  103     {
  104         $self->{Error} = "Cannot create Deflate object: $status"; 
  105         return STATUS_ERROR;
  106     }
  107 
  108     $self->{Def} = $def;
  109 
  110     return STATUS_OK;    
  111 }
  112 
  113 sub compressedBytes
  114 {
  115     my $self = shift ;
  116     $self->{Def}->compressedBytes();
  117 }
  118 
  119 sub uncompressedBytes
  120 {
  121     my $self = shift ;
  122     $self->{Def}->uncompressedBytes();
  123 }
  124 
  125 #sub total_out
  126 #{
  127 #    my $self = shift ;
  128 #    0;
  129 #}
  130 #
  131 
  132 #sub total_in
  133 #{
  134 #    my $self = shift ;
  135 #    $self->{Def}->total_in();
  136 #}
  137 #
  138 #sub crc32
  139 #{
  140 #    my $self = shift ;
  141 #    $self->{Def}->crc32();
  142 #}
  143 #
  144 #sub adler32
  145 #{
  146 #    my $self = shift ;
  147 #    $self->{Def}->adler32();
  148 #}
  149 
  150 
  151 1;
  152 
  153 __END__
  154