Uncompress/Adapter/UnXz.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Uncompress/Adapter/UnLzma.pm ↑ Summary Compress/Lzip.pm »
1 package IO::Uncompress::Adapter::UnXz;
2  
3 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 14 ▶use IO::Compress::Base::Common 2.224 qw(:Status);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 14 ▶use Compress::Raw::Lzma 2.224 ;
Subroutine BEGIN: called CC=1 SCAR=2.6
10  
11 our ($VERSION, @ISA);
12 $VERSION = '2.224';
13  
14 #@ISA = qw( Compress::Raw::UnLzma );
15  
16  
17 sub mkUncompObject
18 {
19 my $memlimit = shift || 128 * 1024 * 1024;
20 my $flags = shift || 0;
21  
22 my ($inflate, $status) =
23 Compress::Raw::Lzma::StreamDecoder->new(AppendOutput => 1,
24 ConsumeInput => 1,
25 LimitOutput => 1,
26 MemLimit => $memlimit,
27 Flags => $flags,
28 );
29  
30 return (undef, "Could not create StreamDecoder object: $status", $status)
31 if $status != LZMA_OK ;
32  
33 return bless {'Inf' => $inflate,
34 'CompSize' => 0,
35 'UnCompSize' => 0,
36 'Error' => '',
37 'ConsumesInput' => 1,
38 } ;
39  
40 }
41  
42 sub uncompr
43 {
44 my $self = shift ;
45 my $from = shift ;
46 my $to = shift ;
47 my $eof = shift ;
48  
49 my $inf = $self->{Inf};
50  
51 my $status = $inf->code($from, $to);
52 $self->{ErrorNo} = $status;
53  
54 if ($status != LZMA_OK && $status != LZMA_STREAM_END )
55 {
56 $self->{Error} = "Uncompression Error: $status";
57 return STATUS_ERROR;
58 }
59  
60  
61 return STATUS_OK if $status == LZMA_OK ;
62 return STATUS_ENDSTREAM if $status == LZMA_STREAM_END ;
63 return STATUS_ERROR ;
64 }
65  
66  
67 sub reset
68 {
69 my $self = shift ;
70  
71 my ($inf, $status) =
72 Compress::Raw::Lzma::StreamDecoder->new(AppendOutput => 1,
73 ConsumeInput => 1,
74 LimitOutput => 1);
75 $self->{ErrorNo} = ($status == LZMA_OK) ? 0 : $status ;
76  
77 if ($status != LZMA_OK)
78 {
79 $self->{Error} = "Cannot create UnXz object: $status";
80 return STATUS_ERROR;
81 }
82  
83 $self->{Inf} = $inf;
84  
85 return STATUS_OK ;
86 }
87  
88 #sub count
89 #{
90 # my $self = shift ;
91 # $self->{Inf}->inflateCount();
92 #}
93  
94 sub compressedBytes
95 {
96 my $self = shift ;
97 $self->{Inf}->compressedBytes();
98 }
99  
100 sub uncompressedBytes
101 {
102 my $self = shift ;
103 $self->{Inf}->uncompressedBytes();
104 }
105  
106 sub crc32
107 {
108 my $self = shift ;
109 #$self->{Inf}->crc32();
110 }
111  
112 sub adler32
113 {
114 my $self = shift ;
115 #$self->{Inf}->adler32();
116 }
117  
118 sub sync
119 {
120 my $self = shift ;
121 #( $self->{Inf}->inflateSync(@_) == LZMA_OK)
122 # ? STATUS_OK
123 # : STATUS_ERROR ;
124 }
125  
126  
127 1;
128  
129 __END__
« Uncompress/Adapter/UnLzma.pm ↑ Summary Compress/Lzip.pm »