1 package IO::Uncompress::AnyUncompress ;
7 use IO::Compress::Base::Common 2.100 ();
9 use IO::Uncompress::Base 2.100 ;
14 our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyUncompressError);
17 $AnyUncompressError = '';
19 @ISA = qw(IO::Uncompress::Base Exporter);
20 @EXPORT_OK = qw( $AnyUncompressError anyuncompress ) ;
21 %EXPORT_TAGS = %IO::Uncompress::Base::DEFLATE_CONSTANTS if keys %IO::Uncompress::Base::DEFLATE_CONSTANTS;
22 push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
23 Exporter::export_ok_tags('all');
25 # TODO - allow the user to pick a set of the three formats to allow
26 # or just assume want to auto-detect any of the three formats.
31 pop @INC if $INC[-1] eq '.';
33 # Don't trigger any __DIE__ Hooks.
36 eval ' use IO::Uncompress::Adapter::Inflate 2.100 ;';
37 eval ' use IO::Uncompress::Adapter::Bunzip2 2.100 ;';
38 eval ' use IO::Uncompress::Adapter::LZO 2.100 ;';
39 eval ' use IO::Uncompress::Adapter::Lzf 2.100 ;';
40 eval ' use IO::Uncompress::Adapter::UnLzma 2.100 ;';
41 eval ' use IO::Uncompress::Adapter::UnXz 2.100 ;';
42 eval ' use IO::Uncompress::Adapter::UnZstd 2.100 ;';
43 eval ' use IO::Uncompress::Adapter::UnLzip 2.100 ;';
45 eval ' use IO::Uncompress::Bunzip2 2.100 ;';
46 eval ' use IO::Uncompress::UnLzop 2.100 ;';
47 eval ' use IO::Uncompress::Gunzip 2.100 ;';
48 eval ' use IO::Uncompress::Inflate 2.100 ;';
49 eval ' use IO::Uncompress::RawInflate 2.100 ;';
50 eval ' use IO::Uncompress::Unzip 2.100 ;';
51 eval ' use IO::Uncompress::UnLzf 2.100 ;';
52 eval ' use IO::Uncompress::UnLzma 2.100 ;';
53 eval ' use IO::Uncompress::UnXz 2.100 ;';
54 eval ' use IO::Uncompress::UnZstd 2.100 ;';
55 eval ' use IO::Uncompress::UnLzip 2.100 ;';
62 my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$AnyUncompressError);
63 $obj->_create(undef, 0, @_);
68 my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$AnyUncompressError);
69 return $obj->_inf(@_) ;
74 return ( 'rawinflate' => [IO::Compress::Base::Common::Parse_boolean, 0] ,
75 'unlzma' => [IO::Compress::Base::Common::Parse_boolean, 0] ) ;
83 # any always needs both crc32 and adler32
84 $got->setValue('crc32' => 1);
85 $got->setValue('adler32' => 1);
98 if (defined $IO::Uncompress::RawInflate::VERSION )
100 my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Inflate::mkUncompObject();
102 return $self->saveErrorString(undef, $errstr, $errno)
105 *$self->{Uncomp} = $obj;
107 my @possible = qw( Inflate Gunzip Unzip );
108 unshift @possible, 'RawInflate'
109 if $got->getValue('rawinflate');
111 $magic = $self->ckMagic( @possible );
114 *$self->{Info} = $self->readHeader($magic)
121 if (defined $IO::Uncompress::UnLzma::VERSION && $got->getValue('unlzma'))
123 my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::UnLzma::mkUncompObject();
125 return $self->saveErrorString(undef, $errstr, $errno)
128 *$self->{Uncomp} = $obj;
130 my @possible = qw( UnLzma );
131 #unshift @possible, 'RawInflate'
132 # if $got->getValue('rawinflate');
134 if ( *$self->{Info} = $self->ckMagic( @possible ))
140 if (defined $IO::Uncompress::UnXz::VERSION and
141 $magic = $self->ckMagic('UnXz')) {
142 *$self->{Info} = $self->readHeader($magic)
145 my ($obj, $errstr, $errno) =
146 IO::Uncompress::Adapter::UnXz::mkUncompObject();
148 return $self->saveErrorString(undef, $errstr, $errno)
151 *$self->{Uncomp} = $obj;
156 if (defined $IO::Uncompress::Bunzip2::VERSION and
157 $magic = $self->ckMagic('Bunzip2')) {
158 *$self->{Info} = $self->readHeader($magic)
161 my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Bunzip2::mkUncompObject();
163 return $self->saveErrorString(undef, $errstr, $errno)
166 *$self->{Uncomp} = $obj;
171 if (defined $IO::Uncompress::UnLzop::VERSION and
172 $magic = $self->ckMagic('UnLzop')) {
174 *$self->{Info} = $self->readHeader($magic)
177 my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::LZO::mkUncompObject();
179 return $self->saveErrorString(undef, $errstr, $errno)
182 *$self->{Uncomp} = $obj;
187 if (defined $IO::Uncompress::UnLzf::VERSION and
188 $magic = $self->ckMagic('UnLzf')) {
190 *$self->{Info} = $self->readHeader($magic)
193 my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Lzf::mkUncompObject();
195 return $self->saveErrorString(undef, $errstr, $errno)
198 *$self->{Uncomp} = $obj;
203 if (defined $IO::Uncompress::UnZstd::VERSION and
204 $magic = $self->ckMagic('UnZstd')) {
206 *$self->{Info} = $self->readHeader($magic)
209 my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::UnZstd::mkUncompObject();
211 return $self->saveErrorString(undef, $errstr, $errno)
214 *$self->{Uncomp} = $obj;
220 if (defined $IO::Uncompress::UnLzip::VERSION and
221 $magic = $self->ckMagic('UnLzip')) {
223 *$self->{Info} = $self->readHeader($magic)
226 my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::UnLzip::mkUncompObject(*$self->{Info}{DictSize});
228 return $self->saveErrorString(undef, $errstr, $errno)
231 *$self->{Uncomp} = $obj;
246 my $keep = ref $self ;
247 for my $class ( map { "IO::Uncompress::$_" } @names)
249 bless $self => $class;
250 my $magic = $self->ckMagic();
254 #bless $self => $class;
258 $self->pushBack(*$self->{HeaderPending}) ;
259 *$self->{HeaderPending} = '' ;
262 bless $self => $keep;
273 IO::Uncompress::AnyUncompress - Uncompress gzip, zip, bzip2, zstd, xz, lzma, lzip, lzf or lzop file/buffer
277 use IO::Uncompress::AnyUncompress qw(anyuncompress $AnyUncompressError) ;
279 my $status = anyuncompress $input => $output [,OPTS]
280 or die "anyuncompress failed: $AnyUncompressError\n";
282 my $z = IO::Uncompress::AnyUncompress->new( $input [OPTS] )
283 or die "anyuncompress failed: $AnyUncompressError\n";
285 $status = $z->read($buffer)
286 $status = $z->read($buffer, $length)
287 $status = $z->read($buffer, $length, $offset)
288 $line = $z->getline()
293 $data = $z->trailingData()
294 $status = $z->nextStream()
295 $data = $z->getHeaderInfo()
297 $z->seek($position, $whence)
303 $AnyUncompressError ;
309 read($z, $buffer, $length);
310 read($z, $buffer, $length, $offset);
312 seek($z, $position, $whence)
320 This module provides a Perl interface that allows the reading of
321 files/buffers that have been compressed with a variety of compression
324 The formats supported are:
330 =item RFC 1951 (optionally)
332 =item gzip (RFC 1952)
336 =item zstd (Zstandard)
352 The module will auto-detect which, if any, of the supported
353 compression formats is being used.
355 =head1 Functional Interface
357 A top-level function, C<anyuncompress>, is provided to carry out
358 "one-shot" uncompression between buffers and/or files. For finer
359 control over the uncompression process, see the L</"OO Interface">
362 use IO::Uncompress::AnyUncompress qw(anyuncompress $AnyUncompressError) ;
364 anyuncompress $input_filename_or_reference => $output_filename_or_reference [,OPTS]
365 or die "anyuncompress failed: $AnyUncompressError\n";
367 The functional interface needs Perl5.005 or better.
369 =head2 anyuncompress $input_filename_or_reference => $output_filename_or_reference [, OPTS]
371 C<anyuncompress> expects at least two parameters,
372 C<$input_filename_or_reference> and C<$output_filename_or_reference>
373 and zero or more optional parameters (see L</Optional Parameters>)
375 =head3 The C<$input_filename_or_reference> parameter
377 The parameter, C<$input_filename_or_reference>, is used to define the
378 source of the compressed data.
380 It can take one of the following forms:
386 If the C<$input_filename_or_reference> parameter is a simple scalar, it is
387 assumed to be a filename. This file will be opened for reading and the
388 input data will be read from it.
392 If the C<$input_filename_or_reference> parameter is a filehandle, the input
393 data will be read from it. The string '-' can be used as an alias for
396 =item A scalar reference
398 If C<$input_filename_or_reference> is a scalar reference, the input data
399 will be read from C<$$input_filename_or_reference>.
401 =item An array reference
403 If C<$input_filename_or_reference> is an array reference, each element in
404 the array must be a filename.
406 The input data will be read from each file in turn.
408 The complete array will be walked to ensure that it only
409 contains valid filenames before any data is uncompressed.
411 =item An Input FileGlob string
413 If C<$input_filename_or_reference> is a string that is delimited by the
414 characters "<" and ">" C<anyuncompress> will assume that it is an
415 I<input fileglob string>. The input is the list of files that match the
418 See L<File::GlobMapper|File::GlobMapper> for more details.
422 If the C<$input_filename_or_reference> parameter is any other type,
423 C<undef> will be returned.
425 =head3 The C<$output_filename_or_reference> parameter
427 The parameter C<$output_filename_or_reference> is used to control the
428 destination of the uncompressed data. This parameter can take one of
435 If the C<$output_filename_or_reference> parameter is a simple scalar, it is
436 assumed to be a filename. This file will be opened for writing and the
437 uncompressed data will be written to it.
441 If the C<$output_filename_or_reference> parameter is a filehandle, the
442 uncompressed data will be written to it. The string '-' can be used as
443 an alias for standard output.
445 =item A scalar reference
447 If C<$output_filename_or_reference> is a scalar reference, the
448 uncompressed data will be stored in C<$$output_filename_or_reference>.
450 =item An Array Reference
452 If C<$output_filename_or_reference> is an array reference,
453 the uncompressed data will be pushed onto the array.
455 =item An Output FileGlob
457 If C<$output_filename_or_reference> is a string that is delimited by the
458 characters "<" and ">" C<anyuncompress> will assume that it is an
459 I<output fileglob string>. The output is the list of files that match the
462 When C<$output_filename_or_reference> is an fileglob string,
463 C<$input_filename_or_reference> must also be a fileglob string. Anything
466 See L<File::GlobMapper|File::GlobMapper> for more details.
470 If the C<$output_filename_or_reference> parameter is any other type,
471 C<undef> will be returned.
475 When C<$input_filename_or_reference> maps to multiple compressed
476 files/buffers and C<$output_filename_or_reference> is
477 a single file/buffer, after uncompression C<$output_filename_or_reference> will contain a
478 concatenation of all the uncompressed data from each of the input
481 =head2 Optional Parameters
483 The optional parameters for the one-shot function C<anyuncompress>
484 are (for the most part) identical to those used with the OO interface defined in the
485 L</"Constructor Options"> section. The exceptions are listed below
489 =item C<< AutoClose => 0|1 >>
491 This option applies to any input or output data streams to
492 C<anyuncompress> that are filehandles.
494 If C<AutoClose> is specified, and the value is true, it will result in all
495 input and/or output filehandles being closed once C<anyuncompress> has
498 This parameter defaults to 0.
500 =item C<< BinModeOut => 0|1 >>
502 This option is now a no-op. All files will be written in binmode.
504 =item C<< Append => 0|1 >>
506 The behaviour of this option is dependent on the type of output data
513 If C<Append> is enabled, all uncompressed data will be append to the end of
514 the output buffer. Otherwise the output buffer will be cleared before any
515 uncompressed data is written to it.
519 If C<Append> is enabled, the file will be opened in append mode. Otherwise
520 the contents of the file, if any, will be truncated before any uncompressed
521 data is written to it.
525 If C<Append> is enabled, the filehandle will be positioned to the end of
526 the file via a call to C<seek> before any uncompressed data is
527 written to it. Otherwise the file pointer will not be moved.
531 When C<Append> is specified, and set to true, it will I<append> all uncompressed
532 data to the output data stream.
534 So when the output is a filehandle it will carry out a seek to the eof
535 before writing any uncompressed data. If the output is a filename, it will be opened for
536 appending. If the output is a buffer, all uncompressed data will be
537 appended to the existing buffer.
539 Conversely when C<Append> is not specified, or it is present and is set to
540 false, it will operate as follows.
542 When the output is a filename, it will truncate the contents of the file
543 before writing any uncompressed data. If the output is a filehandle
544 its position will not be changed. If the output is a buffer, it will be
545 wiped before any uncompressed data is output.
549 =item C<< MultiStream => 0|1 >>
551 If the input file/buffer contains multiple compressed data streams, this
552 option will uncompress the whole lot as a single data stream.
556 =item C<< TrailingData => $scalar >>
558 Returns the data, if any, that is present immediately after the compressed
559 data stream once uncompression is complete.
561 This option can be used when there is useful information immediately
562 following the compressed data stream, and you don't know the length of the
563 compressed data stream.
565 If the input is a buffer, C<trailingData> will return everything from the
566 end of the compressed data stream to the end of the buffer.
568 If the input is a filehandle, C<trailingData> will return the data that is
569 left in the filehandle input buffer once the end of the compressed data
570 stream has been reached. You can then use the filehandle to read the rest
573 Don't bother using C<trailingData> if the input is a filename.
575 If you know the length of the compressed data stream before you start
576 uncompressing, you can avoid having to use C<trailingData> by setting the
577 C<InputLength> option.
583 To read the contents of the file C<file1.txt.Compressed> and write the
584 uncompressed data to the file C<file1.txt>.
588 use IO::Uncompress::AnyUncompress qw(anyuncompress $AnyUncompressError) ;
590 my $input = "file1.txt.Compressed";
591 my $output = "file1.txt";
592 anyuncompress $input => $output
593 or die "anyuncompress failed: $AnyUncompressError\n";
595 To read from an existing Perl filehandle, C<$input>, and write the
596 uncompressed data to a buffer, C<$buffer>.
600 use IO::Uncompress::AnyUncompress qw(anyuncompress $AnyUncompressError) ;
603 my $input = IO::File->new( "<file1.txt.Compressed" )
604 or die "Cannot open 'file1.txt.Compressed': $!\n" ;
606 anyuncompress $input => \$buffer
607 or die "anyuncompress failed: $AnyUncompressError\n";
609 To uncompress all files in the directory "/my/home" that match "*.txt.Compressed" and store the compressed data in the same directory
613 use IO::Uncompress::AnyUncompress qw(anyuncompress $AnyUncompressError) ;
615 anyuncompress '</my/home/*.txt.Compressed>' => '</my/home/#1.txt>'
616 or die "anyuncompress failed: $AnyUncompressError\n";
618 and if you want to compress each file one at a time, this will do the trick
622 use IO::Uncompress::AnyUncompress qw(anyuncompress $AnyUncompressError) ;
624 for my $input ( glob "/my/home/*.txt.Compressed" )
627 $output =~ s/.Compressed// ;
628 anyuncompress $input => $output
629 or die "Error compressing '$input': $AnyUncompressError\n";
636 The format of the constructor for IO::Uncompress::AnyUncompress is shown below
638 my $z = IO::Uncompress::AnyUncompress->new( $input [OPTS] )
639 or die "IO::Uncompress::AnyUncompress failed: $AnyUncompressError\n";
641 Returns an C<IO::Uncompress::AnyUncompress> object on success and undef on failure.
642 The variable C<$AnyUncompressError> will contain an error message on failure.
644 If you are running Perl 5.005 or better the object, C<$z>, returned from
645 IO::Uncompress::AnyUncompress can be used exactly like an L<IO::File|IO::File> filehandle.
646 This means that all normal input file operations can be carried out with
647 C<$z>. For example, to read a line from a compressed file/buffer you can
648 use either of these forms
650 $line = $z->getline();
653 The mandatory parameter C<$input> is used to determine the source of the
654 compressed data. This parameter can take one of three forms.
660 If the C<$input> parameter is a scalar, it is assumed to be a filename. This
661 file will be opened for reading and the compressed data will be read from it.
665 If the C<$input> parameter is a filehandle, the compressed data will be
667 The string '-' can be used as an alias for standard input.
669 =item A scalar reference
671 If C<$input> is a scalar reference, the compressed data will be read from
676 =head2 Constructor Options
678 The option names defined below are case insensitive and can be optionally
679 prefixed by a '-'. So all of the following are valid
686 OPTS is a combination of the following options:
690 =item C<< AutoClose => 0|1 >>
692 This option is only valid when the C<$input> parameter is a filehandle. If
693 specified, and the value is true, it will result in the file being closed once
694 either the C<close> method is called or the IO::Uncompress::AnyUncompress object is
697 This parameter defaults to 0.
699 =item C<< MultiStream => 0|1 >>
701 Allows multiple concatenated compressed streams to be treated as a single
702 compressed stream. Decompression will stop once either the end of the
703 file/buffer is reached, an error is encountered (premature eof, corrupt
704 compressed data) or the end of a stream is not immediately followed by the
705 start of another stream.
707 This parameter defaults to 0.
709 =item C<< Prime => $string >>
711 This option will uncompress the contents of C<$string> before processing the
714 This option can be useful when the compressed data is embedded in another
715 file/data structure and it is not possible to work out where the compressed
716 data begins without having to read the first few bytes. If this is the
717 case, the uncompression can be I<primed> with these bytes using this
720 =item C<< Transparent => 0|1 >>
722 If this option is set and the input file/buffer is not compressed data,
723 the module will allow reading of it anyway.
725 In addition, if the input file/buffer does contain compressed data and
726 there is non-compressed data immediately following it, setting this option
727 will make this module treat the whole file/buffer as a single data stream.
729 This option defaults to 1.
731 =item C<< BlockSize => $num >>
733 When reading the compressed input data, IO::Uncompress::AnyUncompress will read it in
734 blocks of C<$num> bytes.
736 This option defaults to 4096.
738 =item C<< InputLength => $size >>
740 When present this option will limit the number of compressed bytes read
741 from the input file/buffer to C<$size>. This option can be used in the
742 situation where there is useful data directly after the compressed data
743 stream and you know beforehand the exact length of the compressed data
746 This option is mostly used when reading from a filehandle, in which case
747 the file pointer will be left pointing to the first byte directly after the
748 compressed data stream.
750 This option defaults to off.
752 =item C<< Append => 0|1 >>
754 This option controls what the C<read> method does with uncompressed data.
756 If set to 1, all uncompressed data will be appended to the output parameter
757 of the C<read> method.
759 If set to 0, the contents of the output parameter of the C<read> method
760 will be overwritten by the uncompressed data.
764 =item C<< Strict => 0|1 >>
766 This option controls whether the extra checks defined below are used when
767 carrying out the decompression. When Strict is on, the extra tests are
768 carried out, when Strict is off they are not.
770 The default for this option is off.
772 =item C<< RawInflate => 0|1 >>
774 When auto-detecting the compressed format, try to test for raw-deflate (RFC
775 1951) content using the C<IO::Uncompress::RawInflate> module.
777 The reason this is not default behaviour is because RFC 1951 content can
778 only be detected by attempting to uncompress it. This process is error
779 prone and can result is false positives.
783 =item C<< UnLzma => 0|1 >>
785 When auto-detecting the compressed format, try to test for lzma_alone
786 content using the C<IO::Uncompress::UnLzma> module.
788 The reason this is not default behaviour is because lzma_alone content can
789 only be detected by attempting to uncompress it. This process is error
790 prone and can result is false positives.
806 $status = $z->read($buffer)
808 Reads a block of compressed data (the size of the compressed block is
809 determined by the C<Buffer> option in the constructor), uncompresses it and
810 writes any uncompressed data into C<$buffer>. If the C<Append> parameter is
811 set in the constructor, the uncompressed data will be appended to the
812 C<$buffer> parameter. Otherwise C<$buffer> will be overwritten.
814 Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
815 or a negative number on error.
821 $status = $z->read($buffer, $length)
822 $status = $z->read($buffer, $length, $offset)
824 $status = read($z, $buffer, $length)
825 $status = read($z, $buffer, $length, $offset)
827 Attempt to read C<$length> bytes of uncompressed data into C<$buffer>.
829 The main difference between this form of the C<read> method and the
830 previous one, is that this one will attempt to return I<exactly> C<$length>
831 bytes. The only circumstances that this function will not is if end-of-file
832 or an IO error is encountered.
834 Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
835 or a negative number on error.
841 $line = $z->getline()
846 This method fully supports the use of the variable C<$/> (or
847 C<$INPUT_RECORD_SEPARATOR> or C<$RS> when C<English> is in use) to
848 determine what constitutes an end of line. Paragraph mode, record mode and
849 file slurp mode are all supported.
857 Read a single character.
863 $char = $z->ungetc($string)
869 $hdr = $z->getHeaderInfo();
870 @hdrs = $z->getHeaderInfo();
872 This method returns either a hash reference (in scalar context) or a list
873 or hash references (in array context) that contains information about each
874 of the header fields in the compressed data stream(s).
883 Returns the uncompressed file offset.
892 Returns true if the end of the compressed input stream has been reached.
896 $z->seek($position, $whence);
897 seek($z, $position, $whence);
899 Provides a sub-set of the C<seek> functionality, with the restriction
900 that it is only legal to seek forward in the input file/buffer.
901 It is a fatal error to attempt to seek backward.
903 Note that the implementation of C<seek> in this module does not provide
904 true random access to a compressed file/buffer. It works by uncompressing
905 data from the current offset in the file/buffer until it reaches the
906 uncompressed offset specified in the parameters to C<seek>. For very small
907 files this may be acceptable behaviour. For large files it may cause an
910 The C<$whence> parameter takes one the usual values, namely SEEK_SET,
911 SEEK_CUR or SEEK_END.
913 Returns 1 on success, 0 on failure.
922 This is a noop provided for completeness.
928 Returns true if the object currently refers to a opened file/buffer.
932 my $prev = $z->autoflush()
933 my $prev = $z->autoflush(EXPR)
935 If the C<$z> object is associated with a file or a filehandle, this method
936 returns the current autoflush setting for the underlying filehandle. If
937 C<EXPR> is present, and is non-zero, it will enable flushing after every
938 write/print operation.
940 If C<$z> is associated with a buffer, this method has no effect and always
943 B<Note> that the special variable C<$|> B<cannot> be used to set or
944 retrieve the autoflush setting.
946 =head2 input_line_number
948 $z->input_line_number()
949 $z->input_line_number(EXPR)
951 Returns the current uncompressed line number. If C<EXPR> is present it has
952 the effect of setting the line number. Note that setting the line number
953 does not change the current position within the file/buffer being read.
955 The contents of C<$/> are used to determine what constitutes a line
963 If the C<$z> object is associated with a file or a filehandle, C<fileno>
964 will return the underlying file descriptor. Once the C<close> method is
965 called C<fileno> will return C<undef>.
967 If the C<$z> object is associated with a buffer, this method will return
975 Closes the output file/buffer.
977 For most versions of Perl this method will be automatically invoked if
978 the IO::Uncompress::AnyUncompress object is destroyed (either explicitly or by the
979 variable with the reference to the object going out of scope). The
980 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
981 these cases, the C<close> method will be called automatically, but
982 not until global destruction of all live objects when the program is
985 Therefore, if you want your scripts to be able to run on all versions
986 of Perl, you should call C<close> explicitly and not rely on automatic
989 Returns true on success, otherwise 0.
991 If the C<AutoClose> option has been enabled when the IO::Uncompress::AnyUncompress
992 object was created, and the object is associated with a file, the
993 underlying file will also be closed.
999 my $status = $z->nextStream();
1001 Skips to the next compressed data stream in the input file/buffer. If a new
1002 compressed data stream is found, the eof marker will be cleared and C<$.>
1005 Returns 1 if a new stream was found, 0 if none was found, and -1 if an
1006 error was encountered.
1012 my $data = $z->trailingData();
1014 Returns the data, if any, that is present immediately after the compressed
1015 data stream once uncompression is complete. It only makes sense to call
1016 this method once the end of the compressed data stream has been
1019 This option can be used when there is useful information immediately
1020 following the compressed data stream, and you don't know the length of the
1021 compressed data stream.
1023 If the input is a buffer, C<trailingData> will return everything from the
1024 end of the compressed data stream to the end of the buffer.
1026 If the input is a filehandle, C<trailingData> will return the data that is
1027 left in the filehandle input buffer once the end of the compressed data
1028 stream has been reached. You can then use the filehandle to read the rest
1031 Don't bother using C<trailingData> if the input is a filename.
1033 If you know the length of the compressed data stream before you start
1034 uncompressing, you can avoid having to use C<trailingData> by setting the
1035 C<InputLength> option in the constructor.
1039 No symbolic constants are required by IO::Uncompress::AnyUncompress at present.
1045 Imports C<anyuncompress> and C<$AnyUncompressError>.
1048 use IO::Uncompress::AnyUncompress qw(anyuncompress $AnyUncompressError) ;
1056 General feedback/questions/bug reports should be sent to
1057 L<https://github.com/pmqs/IO-Compress/issues> (preferred) or
1058 L<https://rt.cpan.org/Public/Dist/Display.html?Name=IO-Compress>.
1062 L<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzma>, L<IO::Uncompress::UnLzma>, L<IO::Compress::Xz>, L<IO::Uncompress::UnXz>, L<IO::Compress::Lzip>, L<IO::Uncompress::UnLzip>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Compress::Zstd>, L<IO::Uncompress::UnZstd>, L<IO::Uncompress::AnyInflate>
1064 L<IO::Compress::FAQ|IO::Compress::FAQ>
1066 L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
1067 L<Archive::Tar|Archive::Tar>,
1068 L<IO::Zlib|IO::Zlib>
1072 This module was written by Paul Marquess, C<pmqs@cpan.org>.
1074 =head1 MODIFICATION HISTORY
1076 See the Changes file.
1078 =head1 COPYRIGHT AND LICENSE
1080 Copyright (c) 2005-2021 Paul Marquess. All rights reserved.
1082 This program is free software; you can redistribute it and/or
1083 modify it under the same terms as Perl itself.