Compress/Adapter/Xz.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
« Compress/Adapter/Lzma.pm ↑ Summary Uncompress/Adapter/UnLzip.pm »
1 package IO::Compress::Adapter::Xz ;
2  
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 15 ▶use IO::Compress::Base::Common 2.217 qw(:Status);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 15 ▶use Compress::Raw::Lzma 2.217 qw(LZMA_OK LZMA_STREAM_END LZMA_PRESET_DEFAULT LZMA_CHECK_CRC32) ;
Subroutine BEGIN: called CC=1 SCAR=2.6
10  
11 our ($VERSION);
12 $VERSION = '2.217';
13  
14 sub mkCompObject
15 {
16 my $Preset = shift ;
17 my $Extreme = shift ;
18 my $Check = shift ;
19  
20 my ($def, $status) = Compress::Raw::Lzma::EasyEncoder->new(AppendOutput => 1,
21 Preset => $Preset,
22 Extreme => $Extreme,
23 Check => $Check);
24  
25 return (undef, "Could not create EasyEncoder object: $status", $status)
26 if $status != LZMA_OK ;
27  
28 return bless {'Def' => $def,
29 'Error' => '',
30 'ErrorNo' => 0,
31 } ;
32 }
33  
34 sub compr
35 {
36 my $self = shift ;
37  
38 my $def = $self->{Def};
39  
40 my $status = $def->code($_[0], $_[1]) ;
41 $self->{ErrorNo} = $status;
42  
43 if ($status != LZMA_OK)
44 {
45 $self->{Error} = "Deflate Error: $status";
46 return STATUS_ERROR;
47 }
48  
49 #${ $_[1] } .= $out if defined $out;
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->flush($_[0]);
61 $self->{ErrorNo} = $status;
62  
63 if ($status != LZMA_STREAM_END)
64 {
65 $self->{Error} = "Deflate Error: $status";
66 return STATUS_ERROR;
67 }
68  
69 #${ $_[0] } .= $out if defined $out ;
70 return STATUS_OK;
71  
72 }
73  
74 sub close
75 {
76 my $self = shift ;
77  
78 my $def = $self->{Def};
79  
80 my $status = $def->flush($_[0]);
81 $self->{ErrorNo} = $status;
82  
83 if ($status != LZMA_STREAM_END)
84 {
85 $self->{Error} = "Deflate Error: $status";
86 return STATUS_ERROR;
87 }
88  
89 #${ $_[0] } .= $out if defined $out ;
90 return STATUS_OK;
91  
92 }
93  
94  
95 sub reset
96 {
97 my $self = shift ;
98  
99 my $outer = $self->{Outer};
100  
101 my ($def, $status) = Compress::Raw::Lzma->lzma_easy_encoder();
102 $self->{ErrorNo} = ($status == LZMA_OK) ? 0 : $status ;
103  
104 if ($status != LZMA_OK)
105 {
106 $self->{Error} = "Cannot create Deflate object: $status";
107 return STATUS_ERROR;
108 }
109  
110 $self->{Def} = $def;
111  
112 return STATUS_OK;
113 }
114  
115 sub compressedBytes
116 {
117 my $self = shift ;
118 $self->{Def}->compressedBytes();
119 }
120  
121 sub uncompressedBytes
122 {
123 my $self = shift ;
124 $self->{Def}->uncompressedBytes();
125 }
126  
127 #sub total_out
128 #{
129 # my $self = shift ;
130 # 0;
131 #}
132 #
133  
134 #sub total_in
135 #{
136 # my $self = shift ;
137 # $self->{Def}->total_in();
138 #}
139 #
140 #sub crc32
141 #{
142 # my $self = shift ;
143 # $self->{Def}->crc32();
144 #}
145 #
146 #sub adler32
147 #{
148 # my $self = shift ;
149 # $self->{Def}->adler32();
150 #}
151  
152  
153 1;
154  
155 __END__
« Compress/Adapter/Lzma.pm ↑ Summary Uncompress/Adapter/UnLzip.pm »