1 package IO::Uncompress::AnyUncompress ;
6 use Compress::Zlib::Common qw(createSelfTiedObject);
8 #use IO::Uncompress::Base ;
9 use IO::Uncompress::Gunzip ;
10 use IO::Uncompress::Inflate ;
11 use IO::Uncompress::RawInflate ;
12 use IO::Uncompress::Unzip ;
16 eval { require UncompressPlugin::Bunzip2; import UncompressPlugin::Bunzip2 };
17 eval { require UncompressPlugin::LZO; import UncompressPlugin::LZO };
18 eval { require IO::Uncompress::Bunzip2; import IO::Uncompress::Bunzip2 };
19 eval { require IO::Uncompress::UnLzop; import IO::Uncompress::UnLzop };
24 our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyUncompressError);
26 $VERSION = '2.000_05';
27 $AnyUncompressError = '';
29 @ISA = qw( Exporter IO::Uncompress::Base );
30 @EXPORT_OK = qw( $AnyUncompressError anyuncompress ) ;
31 %EXPORT_TAGS = %IO::Uncompress::Base::DEFLATE_CONSTANTS ;
32 push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
33 Exporter::export_ok_tags('all');
35 # TODO - allow the user to pick a set of the three formats to allow
36 # or just assume want to auto-detect any of the three formats.
41 my $obj = createSelfTiedObject($class, \$AnyUncompressError);
42 $obj->_create(undef, 0, @_);
47 my $obj = createSelfTiedObject(undef, \$AnyUncompressError);
48 return $obj->_inf(@_) ;
61 # any always needs both crc32 and adler32
62 $got->value('CRC32' => 1);
63 $got->value('ADLER32' => 1);
75 my ($obj, $errstr, $errno) = UncompressPlugin::Inflate::mkUncompObject();
77 return $self->saveErrorString(undef, $errstr, $errno)
80 *$self->{Uncomp} = $obj;
82 my $magic = $self->ckMagic( qw( RawInflate Inflate Gunzip Unzip ) );
85 *$self->{Info} = $self->readHeader($magic)
91 #foreach my $type ( qw( Bunzip2 UnLzop ) ) {
92 if (defined $IO::Uncompress::Bunzip2::VERSION and
93 $magic = $self->ckMagic('Bunzip2')) {
94 *$self->{Info} = $self->readHeader($magic)
97 my ($obj, $errstr, $errno) = UncompressPlugin::Bunzip2::mkUncompObject();
99 return $self->saveErrorString(undef, $errstr, $errno)
102 *$self->{Uncomp} = $obj;
106 elsif (defined $IO::Uncompress::UnLzop::VERSION and
107 $magic = $self->ckMagic('UnLzop')) {
109 *$self->{Info} = $self->readHeader($magic)
112 my ($obj, $errstr, $errno) = UncompressPlugin::LZO::mkUncompObject();
114 return $self->saveErrorString(undef, $errstr, $errno)
117 *$self->{Uncomp} = $obj;
132 my $keep = ref $self ;
133 for my $class ( map { "IO::Uncompress::$_" } @names)
135 bless $self => $class;
136 my $magic = $self->ckMagic();
140 #bless $self => $class;
144 $self->pushBack(*$self->{HeaderPending}) ;
145 *$self->{HeaderPending} = '' ;
148 bless $self => $keep;