1package IO::Uncompress::UnLzma ;
2
3use strict ;
4use warnings;
5use bytes;
6
7use IO::Compress::Base::Common 2.101 qw(:Status createSelfTiedObject);
8
9use IO::Uncompress::Base 2.101 ;
10use IO::Uncompress::Adapter::UnLzma 2.101 ;
11
12require Exporter ;
13our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $UnLzmaError);
14
15$VERSION = '2.101';
16$UnLzmaError = '';
17
18@ISA    = qw( IO::Uncompress::Base Exporter );
19@EXPORT_OK = qw( $UnLzmaError unlzma ) ;
20#%EXPORT_TAGS = %IO::Uncompress::Base::EXPORT_TAGS ;
21push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
22#Exporter::export_ok_tags('all');
23
24
25sub new
26{
27    my $class = shift ;
28    my $obj = createSelfTiedObject($class, \$UnLzmaError);
29
30    $obj->_create(undef, 0, @_);
31}
32
33sub unlzma
34{
35    my $obj = createSelfTiedObject(undef, \$UnLzmaError);
36    return $obj->_inf(@_);
37}
38
39#our %PARAMS = (
40        #'verbosity' => [IO::Compress::Base::Common::Parse_boolean,   0],
41        #'small'     => [IO::Compress::Base::Common::Parse_boolean,   0],
42#    );
43
44sub getExtraParams
45{
46    return ();
47}
48
49
50sub ckParams
51{
52    my $self = shift ;
53    my $got = shift ;
54
55    return 1;
56}
57
58sub mkUncomp
59{
60    my $self = shift ;
61    my $got = shift ;
62
63    #my $Small     = $got->getValue('small');
64    #my $Verbosity = $got->getValue('verbosity');
65
66    my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::UnLzma::mkUncompObject(
67                                                    );
68
69    return $self->saveErrorString(undef, $errstr, $errno)
70        if ! defined $obj;
71
72    *$self->{Uncomp} = $obj;
73
74    *$self->{Info} = $self->ckMagic()
75        or return 0 ;
76
77    return 1;
78}
79
80
81sub ckMagic
82{
83    my $self = shift;
84
85    my $got = $self->isLzma(@_);
86
87    if ($got) {
88        *$self->{Pending} = *$self->{HeaderPending} ;
89    }
90    else {
91        $self->pushBack(*$self->{HeaderPending});
92        *$self->{Uncomp}->reset();
93    }
94    *$self->{HeaderPending} = '';
95
96    return $got ;
97}
98
99
100sub isLzma
101{
102    my $self = shift ;
103    my $magic = shift;
104
105    $magic = '' unless defined $magic ;
106
107    my $buffer = '';
108
109    $self->smartRead(\$buffer, *$self->{BlockSize}) >= 0
110        or return $self->saveErrorString(undef, "No data to read");
111
112    my $temp_buf = $magic . $buffer ;
113    *$self->{HeaderPending} = $temp_buf ;
114    $buffer = '';
115    my $status = *$self->{Uncomp}->uncompr(\$temp_buf, \$buffer, $self->smartEof()) ;
116
117    return $self->saveErrorString(undef, *$self->{Uncomp}{Error}, STATUS_ERROR)
118        if $status == STATUS_ERROR;
119
120    $self->pushBack($temp_buf)  ;
121
122    return $self->saveErrorString(undef, "unexpected end of file", STATUS_ERROR)
123        if $self->smartEof() && $status != STATUS_ENDSTREAM;
124
125    #my $buf_len = *$self->{Uncomp}->uncompressedBytes();
126    my $buf_len = length $buffer;
127
128    if ($status == STATUS_ENDSTREAM) {
129        if (*$self->{MultiStream}
130                    && (length $temp_buf || ! $self->smartEof())){
131            *$self->{NewStream} = 1 ;
132            *$self->{EndStream} = 0 ;
133        }
134        else {
135            *$self->{EndStream} = 1 ;
136        }
137    }
138    *$self->{HeaderPending} = $buffer ;
139    *$self->{InflatedBytesRead} = $buf_len ;
140    *$self->{TotalInflatedBytesRead} += $buf_len ;
141    *$self->{Type} = 'lzma';
142
143    $self->saveStatus(STATUS_OK);
144
145    return {
146        'Type'          => 'lzma',
147        'HeaderLength'  => 0,
148        'TrailerLength' => 0,
149        'Header'        => ''
150        };
151
152
153    return '';
154}
155
156
157sub readHeader
158{
159    my $self = shift;
160    my $magic = shift ;
161
162    $self->pushBack($magic);
163    *$self->{HeaderPending} = '';
164
165
166    return {
167        'Type'              => 'lzma',
168        'FingerprintLength' => 0,
169        'HeaderLength'      => 0,
170        'TrailerLength'     => 0,
171        'Header'            => ''
172        };
173
174}
175
176sub chkTrailer
177{
178    return STATUS_OK;
179}
180
181
1821 ;
183
184__END__
185
186
187=head1 NAME
188
189IO::Uncompress::UnLzma - Read lzma files/buffers
190
191=head1 SYNOPSIS
192
193    use IO::Uncompress::UnLzma qw(unlzma $UnLzmaError) ;
194
195    my $status = unlzma $input => $output [,OPTS]
196        or die "unlzma failed: $UnLzmaError\n";
197
198    my $z = IO::Uncompress::UnLzma->new( $input [OPTS] )
199        or die "unlzma failed: $UnLzmaError\n";
200
201    $status = $z->read($buffer)
202    $status = $z->read($buffer, $length)
203    $status = $z->read($buffer, $length, $offset)
204    $line = $z->getline()
205    $char = $z->getc()
206    $char = $z->ungetc()
207    $char = $z->opened()
208
209    $data = $z->trailingData()
210    $status = $z->nextStream()
211    $data = $z->getHeaderInfo()
212    $z->tell()
213    $z->seek($position, $whence)
214    $z->binmode()
215    $z->fileno()
216    $z->eof()
217    $z->close()
218
219    $UnLzmaError ;
220
221    # IO::File mode
222
223    <$z>
224    read($z, $buffer);
225    read($z, $buffer, $length);
226    read($z, $buffer, $length, $offset);
227    tell($z)
228    seek($z, $position, $whence)
229    binmode($z)
230    fileno($z)
231    eof($z)
232    close($z)
233
234=head1 DESCRIPTION
235
236This module provides a Perl interface that allows the reading of
237lzma files/buffers.
238
239For writing lzma files/buffers, see the companion module IO::Compress::Lzma.
240
241=head1 Functional Interface
242
243A top-level function, C<unlzma>, is provided to carry out
244"one-shot" uncompression between buffers and/or files. For finer
245control over the uncompression process, see the L</"OO Interface">
246section.
247
248    use IO::Uncompress::UnLzma qw(unlzma $UnLzmaError) ;
249
250    unlzma $input_filename_or_reference => $output_filename_or_reference [,OPTS]
251        or die "unlzma failed: $UnLzmaError\n";
252
253The functional interface needs Perl5.005 or better.
254
255=head2 unlzma $input_filename_or_reference => $output_filename_or_reference [, OPTS]
256
257C<unlzma> expects at least two parameters,
258C<$input_filename_or_reference> and C<$output_filename_or_reference>
259and zero or more optional parameters (see L</Optional Parameters>)
260
261=head3 The C<$input_filename_or_reference> parameter
262
263The parameter, C<$input_filename_or_reference>, is used to define the
264source of the compressed data.
265
266It can take one of the following forms:
267
268=over 5
269
270=item A filename
271
272If the C<$input_filename_or_reference> parameter is a simple scalar, it is
273assumed to be a filename. This file will be opened for reading and the
274input data will be read from it.
275
276=item A filehandle
277
278If the C<$input_filename_or_reference> parameter is a filehandle, the input
279data will be read from it.  The string '-' can be used as an alias for
280standard input.
281
282=item A scalar reference
283
284If C<$input_filename_or_reference> is a scalar reference, the input data
285will be read from C<$$input_filename_or_reference>.
286
287=item An array reference
288
289If C<$input_filename_or_reference> is an array reference, each element in
290the array must be a filename.
291
292The input data will be read from each file in turn.
293
294The complete array will be walked to ensure that it only
295contains valid filenames before any data is uncompressed.
296
297=item An Input FileGlob string
298
299If C<$input_filename_or_reference> is a string that is delimited by the
300characters "<" and ">" C<unlzma> will assume that it is an
301I<input fileglob string>. The input is the list of files that match the
302fileglob.
303
304See L<File::GlobMapper|File::GlobMapper> for more details.
305
306=back
307
308If the C<$input_filename_or_reference> parameter is any other type,
309C<undef> will be returned.
310
311=head3 The C<$output_filename_or_reference> parameter
312
313The parameter C<$output_filename_or_reference> is used to control the
314destination of the uncompressed data. This parameter can take one of
315these forms.
316
317=over 5
318
319=item A filename
320
321If the C<$output_filename_or_reference> parameter is a simple scalar, it is
322assumed to be a filename.  This file will be opened for writing and the
323uncompressed data will be written to it.
324
325=item A filehandle
326
327If the C<$output_filename_or_reference> parameter is a filehandle, the
328uncompressed data will be written to it.  The string '-' can be used as
329an alias for standard output.
330
331=item A scalar reference
332
333If C<$output_filename_or_reference> is a scalar reference, the
334uncompressed data will be stored in C<$$output_filename_or_reference>.
335
336=item An Array Reference
337
338If C<$output_filename_or_reference> is an array reference,
339the uncompressed data will be pushed onto the array.
340
341=item An Output FileGlob
342
343If C<$output_filename_or_reference> is a string that is delimited by the
344characters "<" and ">" C<unlzma> will assume that it is an
345I<output fileglob string>. The output is the list of files that match the
346fileglob.
347
348When C<$output_filename_or_reference> is an fileglob string,
349C<$input_filename_or_reference> must also be a fileglob string. Anything
350else is an error.
351
352See L<File::GlobMapper|File::GlobMapper> for more details.
353
354=back
355
356If the C<$output_filename_or_reference> parameter is any other type,
357C<undef> will be returned.
358
359=head2 Notes
360
361When C<$input_filename_or_reference> maps to multiple compressed
362files/buffers and C<$output_filename_or_reference> is
363a single file/buffer, after uncompression C<$output_filename_or_reference> will contain a
364concatenation of all the uncompressed data from each of the input
365files/buffers.
366
367=head2 Optional Parameters
368
369The optional parameters for the one-shot function C<unlzma>
370are (for the most part) identical to those used with the OO interface defined in the
371L</"Constructor Options"> section. The exceptions are listed below
372
373=over 5
374
375=item C<< AutoClose => 0|1 >>
376
377This option applies to any input or output data streams to
378C<unlzma> that are filehandles.
379
380If C<AutoClose> is specified, and the value is true, it will result in all
381input and/or output filehandles being closed once C<unlzma> has
382completed.
383
384This parameter defaults to 0.
385
386=item C<< BinModeOut => 0|1 >>
387
388This option is now a no-op. All files will be written  in binmode.
389
390=item C<< Append => 0|1 >>
391
392The behaviour of this option is dependent on the type of output data
393stream.
394
395=over 5
396
397=item * A Buffer
398
399If C<Append> is enabled, all uncompressed data will be append to the end of
400the output buffer. Otherwise the output buffer will be cleared before any
401uncompressed data is written to it.
402
403=item * A Filename
404
405If C<Append> is enabled, the file will be opened in append mode. Otherwise
406the contents of the file, if any, will be truncated before any uncompressed
407data is written to it.
408
409=item * A Filehandle
410
411If C<Append> is enabled, the filehandle will be positioned to the end of
412the file via a call to C<seek> before any uncompressed data is
413written to it.  Otherwise the file pointer will not be moved.
414
415=back
416
417When C<Append> is specified, and set to true, it will I<append> all uncompressed
418data to the output data stream.
419
420So when the output is a filehandle it will carry out a seek to the eof
421before writing any uncompressed data. If the output is a filename, it will be opened for
422appending. If the output is a buffer, all uncompressed data will be
423appended to the existing buffer.
424
425Conversely when C<Append> is not specified, or it is present and is set to
426false, it will operate as follows.
427
428When the output is a filename, it will truncate the contents of the file
429before writing any uncompressed data. If the output is a filehandle
430its position will not be changed. If the output is a buffer, it will be
431wiped before any uncompressed data is output.
432
433Defaults to 0.
434
435=item C<< MultiStream => 0|1 >>
436
437If the input file/buffer contains multiple compressed data streams, this
438option will uncompress the whole lot as a single data stream.
439
440Defaults to 0.
441
442=item C<< TrailingData => $scalar >>
443
444Returns the data, if any, that is present immediately after the compressed
445data stream once uncompression is complete.
446
447This option can be used when there is useful information immediately
448following the compressed data stream, and you don't know the length of the
449compressed data stream.
450
451If the input is a buffer, C<trailingData> will return everything from the
452end of the compressed data stream to the end of the buffer.
453
454If the input is a filehandle, C<trailingData> will return the data that is
455left in the filehandle input buffer once the end of the compressed data
456stream has been reached. You can then use the filehandle to read the rest
457of the input file.
458
459Don't bother using C<trailingData> if the input is a filename.
460
461If you know the length of the compressed data stream before you start
462uncompressing, you can avoid having to use C<trailingData> by setting the
463C<InputLength> option.
464
465=back
466
467=head2 Examples
468
469To read the contents of the file C<file1.txt.lzma> and write the
470uncompressed data to the file C<file1.txt>.
471
472    use strict ;
473    use warnings ;
474    use IO::Uncompress::UnLzma qw(unlzma $UnLzmaError) ;
475
476    my $input = "file1.txt.lzma";
477    my $output = "file1.txt";
478    unlzma $input => $output
479        or die "unlzma failed: $UnLzmaError\n";
480
481To read from an existing Perl filehandle, C<$input>, and write the
482uncompressed data to a buffer, C<$buffer>.
483
484    use strict ;
485    use warnings ;
486    use IO::Uncompress::UnLzma qw(unlzma $UnLzmaError) ;
487    use IO::File ;
488
489    my $input = IO::File->new( "<file1.txt.lzma" )
490        or die "Cannot open 'file1.txt.lzma': $!\n" ;
491    my $buffer ;
492    unlzma $input => \$buffer
493        or die "unlzma failed: $UnLzmaError\n";
494
495To uncompress all files in the directory "/my/home" that match "*.txt.lzma" and store the compressed data in the same directory
496
497    use strict ;
498    use warnings ;
499    use IO::Uncompress::UnLzma qw(unlzma $UnLzmaError) ;
500
501    unlzma '</my/home/*.txt.lzma>' => '</my/home/#1.txt>'
502        or die "unlzma failed: $UnLzmaError\n";
503
504and if you want to compress each file one at a time, this will do the trick
505
506    use strict ;
507    use warnings ;
508    use IO::Uncompress::UnLzma qw(unlzma $UnLzmaError) ;
509
510    for my $input ( glob "/my/home/*.txt.lzma" )
511    {
512        my $output = $input;
513        $output =~ s/.lzma// ;
514        unlzma $input => $output
515            or die "Error compressing '$input': $UnLzmaError\n";
516    }
517
518=head1 OO Interface
519
520=head2 Constructor
521
522The format of the constructor for IO::Uncompress::UnLzma is shown below
523
524    my $z = IO::Uncompress::UnLzma->new( $input [OPTS] )
525        or die "IO::Uncompress::UnLzma failed: $UnLzmaError\n";
526
527Returns an C<IO::Uncompress::UnLzma> object on success and undef on failure.
528The variable C<$UnLzmaError> will contain an error message on failure.
529
530If you are running Perl 5.005 or better the object, C<$z>, returned from
531IO::Uncompress::UnLzma can be used exactly like an L<IO::File|IO::File> filehandle.
532This means that all normal input file operations can be carried out with
533C<$z>.  For example, to read a line from a compressed file/buffer you can
534use either of these forms
535
536    $line = $z->getline();
537    $line = <$z>;
538
539The mandatory parameter C<$input> is used to determine the source of the
540compressed data. This parameter can take one of three forms.
541
542=over 5
543
544=item A filename
545
546If the C<$input> parameter is a scalar, it is assumed to be a filename. This
547file will be opened for reading and the compressed data will be read from it.
548
549=item A filehandle
550
551If the C<$input> parameter is a filehandle, the compressed data will be
552read from it.
553The string '-' can be used as an alias for standard input.
554
555=item A scalar reference
556
557If C<$input> is a scalar reference, the compressed data will be read from
558C<$$input>.
559
560=back
561
562=head2 Constructor Options
563
564The option names defined below are case insensitive and can be optionally
565prefixed by a '-'.  So all of the following are valid
566
567    -AutoClose
568    -autoclose
569    AUTOCLOSE
570    autoclose
571
572OPTS is a combination of the following options:
573
574=over 5
575
576=item C<< AutoClose => 0|1 >>
577
578This option is only valid when the C<$input> parameter is a filehandle. If
579specified, and the value is true, it will result in the file being closed once
580either the C<close> method is called or the IO::Uncompress::UnLzma object is
581destroyed.
582
583This parameter defaults to 0.
584
585=item C<< MultiStream => 0|1 >>
586
587Allows multiple concatenated compressed streams to be treated as a single
588compressed stream. Decompression will stop once either the end of the
589file/buffer is reached, an error is encountered (premature eof, corrupt
590compressed data) or the end of a stream is not immediately followed by the
591start of another stream.
592
593This parameter defaults to 0.
594
595=item C<< Prime => $string >>
596
597This option will uncompress the contents of C<$string> before processing the
598input file/buffer.
599
600This option can be useful when the compressed data is embedded in another
601file/data structure and it is not possible to work out where the compressed
602data begins without having to read the first few bytes. If this is the
603case, the uncompression can be I<primed> with these bytes using this
604option.
605
606=item C<< Transparent => 0|1 >>
607
608If this option is set and the input file/buffer is not compressed data,
609the module will allow reading of it anyway.
610
611In addition, if the input file/buffer does contain compressed data and
612there is non-compressed data immediately following it, setting this option
613will make this module treat the whole file/buffer as a single data stream.
614
615This option defaults to 1.
616
617=item C<< BlockSize => $num >>
618
619When reading the compressed input data, IO::Uncompress::UnLzma will read it in
620blocks of C<$num> bytes.
621
622This option defaults to 4096.
623
624=item C<< InputLength => $size >>
625
626When present this option will limit the number of compressed bytes read
627from the input file/buffer to C<$size>. This option can be used in the
628situation where there is useful data directly after the compressed data
629stream and you know beforehand the exact length of the compressed data
630stream.
631
632This option is mostly used when reading from a filehandle, in which case
633the file pointer will be left pointing to the first byte directly after the
634compressed data stream.
635
636This option defaults to off.
637
638=item C<< Append => 0|1 >>
639
640This option controls what the C<read> method does with uncompressed data.
641
642If set to 1, all uncompressed data will be appended to the output parameter
643of the C<read> method.
644
645If set to 0, the contents of the output parameter of the C<read> method
646will be overwritten by the uncompressed data.
647
648Defaults to 0.
649
650=item C<< Strict => 0|1 >>
651
652This option controls whether the extra checks defined below are used when
653carrying out the decompression. When Strict is on, the extra tests are
654carried out, when Strict is off they are not.
655
656The default for this option is off.
657
658=back
659
660=head2 Examples
661
662TODO
663
664=head1 Methods
665
666=head2 read
667
668Usage is
669
670    $status = $z->read($buffer)
671
672Reads a block of compressed data (the size of the compressed block is
673determined by the C<Buffer> option in the constructor), uncompresses it and
674writes any uncompressed data into C<$buffer>. If the C<Append> parameter is
675set in the constructor, the uncompressed data will be appended to the
676C<$buffer> parameter. Otherwise C<$buffer> will be overwritten.
677
678Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
679or a negative number on error.
680
681=head2 read
682
683Usage is
684
685    $status = $z->read($buffer, $length)
686    $status = $z->read($buffer, $length, $offset)
687
688    $status = read($z, $buffer, $length)
689    $status = read($z, $buffer, $length, $offset)
690
691Attempt to read C<$length> bytes of uncompressed data into C<$buffer>.
692
693The main difference between this form of the C<read> method and the
694previous one, is that this one will attempt to return I<exactly> C<$length>
695bytes. The only circumstances that this function will not is if end-of-file
696or an IO error is encountered.
697
698Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
699or a negative number on error.
700
701=head2 getline
702
703Usage is
704
705    $line = $z->getline()
706    $line = <$z>
707
708Reads a single line.
709
710This method fully supports the use of the variable C<$/> (or
711C<$INPUT_RECORD_SEPARATOR> or C<$RS> when C<English> is in use) to
712determine what constitutes an end of line. Paragraph mode, record mode and
713file slurp mode are all supported.
714
715=head2 getc
716
717Usage is
718
719    $char = $z->getc()
720
721Read a single character.
722
723=head2 ungetc
724
725Usage is
726
727    $char = $z->ungetc($string)
728
729=head2 getHeaderInfo
730
731Usage is
732
733    $hdr  = $z->getHeaderInfo();
734    @hdrs = $z->getHeaderInfo();
735
736This method returns either a hash reference (in scalar context) or a list
737or hash references (in array context) that contains information about each
738of the header fields in the compressed data stream(s).
739
740=head2 tell
741
742Usage is
743
744    $z->tell()
745    tell $z
746
747Returns the uncompressed file offset.
748
749=head2 eof
750
751Usage is
752
753    $z->eof();
754    eof($z);
755
756Returns true if the end of the compressed input stream has been reached.
757
758=head2 seek
759
760    $z->seek($position, $whence);
761    seek($z, $position, $whence);
762
763Provides a sub-set of the C<seek> functionality, with the restriction
764that it is only legal to seek forward in the input file/buffer.
765It is a fatal error to attempt to seek backward.
766
767Note that the implementation of C<seek> in this module does not provide
768true random access to a compressed file/buffer. It  works by uncompressing
769data from the current offset in the file/buffer until it reaches the
770uncompressed offset specified in the parameters to C<seek>. For very small
771files this may be acceptable behaviour. For large files it may cause an
772unacceptable delay.
773
774The C<$whence> parameter takes one the usual values, namely SEEK_SET,
775SEEK_CUR or SEEK_END.
776
777Returns 1 on success, 0 on failure.
778
779=head2 binmode
780
781Usage is
782
783    $z->binmode
784    binmode $z ;
785
786This is a noop provided for completeness.
787
788=head2 opened
789
790    $z->opened()
791
792Returns true if the object currently refers to a opened file/buffer.
793
794=head2 autoflush
795
796    my $prev = $z->autoflush()
797    my $prev = $z->autoflush(EXPR)
798
799If the C<$z> object is associated with a file or a filehandle, this method
800returns the current autoflush setting for the underlying filehandle. If
801C<EXPR> is present, and is non-zero, it will enable flushing after every
802write/print operation.
803
804If C<$z> is associated with a buffer, this method has no effect and always
805returns C<undef>.
806
807B<Note> that the special variable C<$|> B<cannot> be used to set or
808retrieve the autoflush setting.
809
810=head2 input_line_number
811
812    $z->input_line_number()
813    $z->input_line_number(EXPR)
814
815Returns the current uncompressed line number. If C<EXPR> is present it has
816the effect of setting the line number. Note that setting the line number
817does not change the current position within the file/buffer being read.
818
819The contents of C<$/> are used to determine what constitutes a line
820terminator.
821
822=head2 fileno
823
824    $z->fileno()
825    fileno($z)
826
827If the C<$z> object is associated with a file or a filehandle, C<fileno>
828will return the underlying file descriptor. Once the C<close> method is
829called C<fileno> will return C<undef>.
830
831If the C<$z> object is associated with a buffer, this method will return
832C<undef>.
833
834=head2 close
835
836    $z->close() ;
837    close $z ;
838
839Closes the output file/buffer.
840
841For most versions of Perl this method will be automatically invoked if
842the IO::Uncompress::UnLzma object is destroyed (either explicitly or by the
843variable with the reference to the object going out of scope). The
844exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
845these cases, the C<close> method will be called automatically, but
846not until global destruction of all live objects when the program is
847terminating.
848
849Therefore, if you want your scripts to be able to run on all versions
850of Perl, you should call C<close> explicitly and not rely on automatic
851closing.
852
853Returns true on success, otherwise 0.
854
855If the C<AutoClose> option has been enabled when the IO::Uncompress::UnLzma
856object was created, and the object is associated with a file, the
857underlying file will also be closed.
858
859=head2 nextStream
860
861Usage is
862
863    my $status = $z->nextStream();
864
865Skips to the next compressed data stream in the input file/buffer. If a new
866compressed data stream is found, the eof marker will be cleared and C<$.>
867will be reset to 0.
868
869Returns 1 if a new stream was found, 0 if none was found, and -1 if an
870error was encountered.
871
872=head2 trailingData
873
874Usage is
875
876    my $data = $z->trailingData();
877
878Returns the data, if any, that is present immediately after the compressed
879data stream once uncompression is complete. It only makes sense to call
880this method once the end of the compressed data stream has been
881encountered.
882
883This option can be used when there is useful information immediately
884following the compressed data stream, and you don't know the length of the
885compressed data stream.
886
887If the input is a buffer, C<trailingData> will return everything from the
888end of the compressed data stream to the end of the buffer.
889
890If the input is a filehandle, C<trailingData> will return the data that is
891left in the filehandle input buffer once the end of the compressed data
892stream has been reached. You can then use the filehandle to read the rest
893of the input file.
894
895Don't bother using C<trailingData> if the input is a filename.
896
897If you know the length of the compressed data stream before you start
898uncompressing, you can avoid having to use C<trailingData> by setting the
899C<InputLength> option in the constructor.
900
901=head1 Importing
902
903No symbolic constants are required by IO::Uncompress::UnLzma at present.
904
905=over 5
906
907=item :all
908
909Imports C<unlzma> and C<$UnLzmaError>.
910Same as doing this
911
912    use IO::Uncompress::UnLzma qw(unlzma $UnLzmaError) ;
913
914=back
915
916=head1 EXAMPLES
917
918=head1 SUPPORT
919
920General feedback/questions/bug reports should be sent to
921L<https://github.com/pmqs/IO-Compress-Lzma/issues> (preferred) or
922L<https://rt.cpan.org/Public/Dist/Display.html?Name=IO-Compress-Lzma>.
923
924=head1 SEE ALSO
925
926L<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::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>, L<IO::Uncompress::AnyUncompress>
927
928L<IO::Compress::FAQ|IO::Compress::FAQ>
929
930L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
931L<Archive::Tar|Archive::Tar>,
932L<IO::Zlib|IO::Zlib>
933
934=head1 AUTHOR
935
936This module was written by Paul Marquess, C<pmqs@cpan.org>.
937
938=head1 MODIFICATION HISTORY
939
940See the Changes file.
941
942=head1 COPYRIGHT AND LICENSE
943
944Copyright (c) 2005-2021 Paul Marquess. All rights reserved.
945
946This program is free software; you can redistribute it and/or
947modify it under the same terms as Perl itself.
948