package IO::Uncompress::AnyUncompress ;
use strict;
use warnings;
use bytes;
use IO::Compress::Base::Common 2.015 qw(createSelfTiedObject);
use IO::Uncompress::Base 2.015 ;
require Exporter ;
our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyUncompressError);
$VERSION = '2.015';
$AnyUncompressError = '';
@ISA = qw( Exporter IO::Uncompress::Base );
@EXPORT_OK = qw( $AnyUncompressError anyuncompress ) ;
%EXPORT_TAGS = %IO::Uncompress::Base::DEFLATE_CONSTANTS ;
push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
Exporter::export_ok_tags('all');
# TODO - allow the user to pick a set of the three formats to allow
# or just assume want to auto-detect any of the three formats.
BEGIN
{
eval ' use IO::Uncompress::Adapter::Inflate 2.015 ;';
eval ' use IO::Uncompress::Adapter::Bunzip2 2.015 ;';
eval ' use IO::Uncompress::Adapter::LZO 2.015 ;';
eval ' use IO::Uncompress::Adapter::Lzf 2.015 ;';
eval ' use IO::Uncompress::Bunzip2 2.015 ;';
eval ' use IO::Uncompress::UnLzop 2.015 ;';
eval ' use IO::Uncompress::Gunzip 2.015 ;';
eval ' use IO::Uncompress::Inflate 2.015 ;';
eval ' use IO::Uncompress::RawInflate 2.015 ;';
eval ' use IO::Uncompress::Unzip 2.015 ;';
eval ' use IO::Uncompress::UnLzf 2.015 ;';
}
sub new
{
my $class = shift ;
my $obj = createSelfTiedObject($class, \$AnyUncompressError);
$obj->_create(undef, 0, @_);
}
sub anyuncompress
{
my $obj = createSelfTiedObject(undef, \$AnyUncompressError);
return $obj->_inf(@_) ;
}
sub getExtraParams
{
use IO::Compress::Base::Common 2.015 qw(:Parse);
return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ;
}
sub ckParams
{
my $self = shift ;
my $got = shift ;
# any always needs both crc32 and adler32
$got->value('CRC32' => 1);
$got->value('ADLER32' => 1);
return 1;
}
sub mkUncomp
{
my $self = shift ;
my $got = shift ;
my $magic ;
# try zlib first
if (defined $IO::Uncompress::RawInflate::VERSION )
{
my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Inflate::mkUncompObject();
return $self->saveErrorString(undef, $errstr, $errno)
if ! defined $obj;
*$self->{Uncomp} = $obj;
my @possible = qw( Inflate Gunzip Unzip );
unshift @possible, 'RawInflate'
if $got->value('RawInflate');
$magic = $self->ckMagic( @possible );
if ($magic) {
*$self->{Info} = $self->readHeader($magic)
or return undef ;
=1= |