| 1 | package IO::Uncompress::Adapter::UnLzma; | ||
| 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.225 qw(:Status); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 0 | ▶ | use Compress::Raw::Lzma 2.225 ; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 10 | |||
| 11 | our ($VERSION, @ISA); | ||
| 12 | $VERSION = '2.225'; | ||
| 13 | |||
| 14 | #@ISA = qw( Compress::Raw::UnLzma ); | ||
| 15 | |||
| 16 | |||
| 17 | sub mkUncompObject | ||
| 18 | { | ||
| 19 | #my $CompressedLength = shift; | ||
| 20 | #my $UncompressedLength = shift; | ||
| 21 | #my $small = shift || 0; | ||
| 22 | #my $verbosity = shift || 0; | ||
| 23 | |||
| 24 | my ($inflate, $status) = Compress::Raw::Lzma::AloneDecoder->new(AppendOutput => 1, | ||
| 25 | ConsumeInput => 1, | ||
| 26 | LimitOutput => 1); | ||
| 27 | |||
| 28 | return (undef, "Could not create AloneDecoder object: $status", $status) | ||
| 29 | if $status != LZMA_OK ; | ||
| 30 | |||
| 31 | return bless {'Inf' => $inflate, | ||
| 32 | 'CompSize' => 0, | ||
| 33 | 'UnCompSize' => 0, | ||
| 34 | 'Error' => '', | ||
| 35 | 'ConsumesInput' => 1, | ||
| 36 | #'CompressedLen' => $CompressedLength || 0, | ||
| 37 | #'UncompressedLen' => $UncompressedLength || 0, | ||
| 38 | } ; | ||
| 39 | |||
| 40 | } | ||
| 41 | |||
| 42 | sub mkUncompZipObject | ||
| 43 | { | ||
| 44 | my $properties = shift ; | ||
| 45 | #my $CompressedLength = shift; | ||
| 46 | #my $UncompressedLength = shift; | ||
| 47 | #my $small = shift || 0; | ||
| 48 | #my $verbosity = shift || 0; | ||
| 49 | |||
| 50 | my ($inflate, $status) = Compress::Raw::Lzma::RawDecoder->new(AppendOutput => 1, | ||
| 51 | Properties => $properties, | ||
| 52 | ConsumeInput => 1, | ||
| 53 | LimitOutput => 1); | ||
| 54 | |||
| 55 | return (undef, "Could not create RawDecoder object: $status", $status) | ||
| 56 | if $status != LZMA_OK ; | ||
| 57 | |||
| 58 | return bless {'Inf' => $inflate, | ||
| 59 | 'CompSize' => 0, | ||
| 60 | 'UnCompSize' => 0, | ||
| 61 | 'Error' => '', | ||
| 62 | 'ConsumesInput' => 1, | ||
| 63 | 'ResetData' => $properties, | ||
| 64 | #'CompressedLen' => $CompressedLength || 0, | ||
| 65 | #'UncompressedLen' => $UncompressedLength || 0, | ||
| 66 | } ; | ||
| 67 | |||
| 68 | } | ||
| 69 | |||
| 70 | sub uncompr | ||
| 71 | { | ||
| 72 | my $self = shift ; | ||
| 73 | my $from = shift ; | ||
| 74 | my $to = shift ; | ||
| 75 | my $eof = shift ; | ||
| 76 | |||
| 77 | my $inf = $self->{Inf}; | ||
| 78 | my $status = $inf->code($from, $to); | ||
| 79 | $self->{ErrorNo} = $status; | ||
| 80 | |||
| 81 | if ($status != LZMA_OK && $status != LZMA_STREAM_END ) | ||
| 82 | { | ||
| 83 | $self->{Error} = "Uncompression Error: $status"; | ||
| 84 | return STATUS_ERROR; | ||
| 85 | } | ||
| 86 | |||
| 87 | return STATUS_ENDSTREAM if $status == LZMA_STREAM_END || | ||
| 88 | ($eof && length $$from == 0); | ||
| 89 | |||
| 90 | return STATUS_OK if $status == LZMA_OK ; | ||
| 91 | return STATUS_ERROR ; | ||
| 92 | } | ||
| 93 | |||
| 94 | |||
| 95 | sub reset | ||
| 96 | { | ||
| 97 | my $self = shift ; | ||
| 98 | |||
| 99 | my ($inf, $status) = Compress::Raw::Lzma::RawDecoder->new(AppendOutput => 1, | ||
| 100 | Properties => $self->{'ResetData'}, | ||
| 101 | ConsumeInput => 1, | ||
| 102 | LimitOutput => 1); | ||
| 103 | $self->{ErrorNo} = ($status == LZMA_OK) ? 0 : $status ; | ||
| 104 | |||
| 105 | if ($status != LZMA_OK) | ||
| 106 | { | ||
| 107 | $self->{Error} = "Cannot create UnLzma object: $status"; | ||
| 108 | return STATUS_ERROR; | ||
| 109 | } | ||
| 110 | |||
| 111 | $self->{Inf} = $inf; | ||
| 112 | |||
| 113 | return STATUS_OK ; | ||
| 114 | } | ||
| 115 | |||
| 116 | #sub count | ||
| 117 | #{ | ||
| 118 | # my $self = shift ; | ||
| 119 | # $self->{Inf}->inflateCount(); | ||
| 120 | #} | ||
| 121 | |||
| 122 | sub compressedBytes | ||
| 123 | { | ||
| 124 | my $self = shift ; | ||
| 125 | $self->{Inf}->compressedBytes(); | ||
| 126 | } | ||
| 127 | |||
| 128 | sub uncompressedBytes | ||
| 129 | { | ||
| 130 | my $self = shift ; | ||
| 131 | $self->{Inf}->uncompressedBytes(); | ||
| 132 | } | ||
| 133 | |||
| 134 | sub crc32 | ||
| 135 | { | ||
| 136 | my $self = shift ; | ||
| 137 | #$self->{Inf}->crc32(); | ||
| 138 | } | ||
| 139 | |||
| 140 | sub adler32 | ||
| 141 | { | ||
| 142 | my $self = shift ; | ||
| 143 | #$self->{Inf}->adler32(); | ||
| 144 | } | ||
| 145 | |||
| 146 | sub sync | ||
| 147 | { | ||
| 148 | my $self = shift ; | ||
| 149 | #( $self->{Inf}->inflateSync(@_) == LZMA_OK) | ||
| 150 | # ? STATUS_OK | ||
| 151 | # : STATUS_ERROR ; | ||
| 152 | } | ||
| 153 | |||
| 154 | |||
| 155 | 1; | ||
| 156 | |||
| 157 | __END__ | ||