require should ignore directories found when searching @INC not just
[p5sagit/p5-mst-13.2.git] / ext / Compress / IO / Zlib / lib / IO / Uncompress / RawInflate.pm
CommitLineData
642e522c 1package IO::Uncompress::RawInflate ;
2# for RFC1951
3
4use strict ;
5use warnings;
a02d0f6f 6use bytes;
1a6a8453 7
a02d0f6f 8use Compress::Raw::Zlib ;
9use IO::Compress::Base::Common qw(:Status createSelfTiedObject);
1a6a8453 10
11use IO::Uncompress::Base ;
a02d0f6f 12use IO::Uncompress::Adapter::Inflate ;
1a6a8453 13
14
15
642e522c 16
17require Exporter ;
1a6a8453 18our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $RawInflateError);
642e522c 19
a02d0f6f 20$VERSION = '2.000_08';
642e522c 21$RawInflateError = '';
22
1a6a8453 23@ISA = qw( Exporter IO::Uncompress::Base );
642e522c 24@EXPORT_OK = qw( $RawInflateError rawinflate ) ;
1a6a8453 25%DEFLATE_CONSTANTS = ();
26%EXPORT_TAGS = %IO::Uncompress::Base::EXPORT_TAGS ;
642e522c 27push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
28Exporter::export_ok_tags('all');
29
30
31
642e522c 32sub new
33{
1a6a8453 34 my $class = shift ;
35 my $obj = createSelfTiedObject($class, \$RawInflateError);
36 $obj->_create(undef, 0, @_);
642e522c 37}
38
39sub rawinflate
40{
1a6a8453 41 my $obj = createSelfTiedObject(undef, \$RawInflateError);
42 return $obj->_inf(@_);
43}
44
45sub getExtraParams
46{
47 return ();
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 $class = shift ;
62 my $got = shift ;
63
a02d0f6f 64 my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Inflate::mkUncompObject(
1a6a8453 65 $got->value('CRC32'),
66 $got->value('ADLER32'),
67 $got->value('Scan'),
68 );
69
70 return $self->saveErrorString(undef, $errstr, $errno)
71 if ! defined $obj;
72
73 *$self->{Uncomp} = $obj;
74
75 my $magic = $self->ckMagic()
76 or return 0;
77
78 *$self->{Info} = $self->readHeader($magic)
79 or return undef ;
80
81 return 1;
82
83}
84
85
86sub ckMagic
87{
88 my $self = shift;
89
90 return $self->_isRaw() ;
91}
92
93sub readHeader
94{
95 my $self = shift;
96 my $magic = shift ;
97
98 return {
99 'Type' => 'rfc1951',
100 'FingerprintLength' => 0,
101 'HeaderLength' => 0,
102 'TrailerLength' => 0,
103 'Header' => ''
104 };
105}
106
107sub chkTrailer
108{
a02d0f6f 109 return STATUS_OK ;
1a6a8453 110}
111
112sub _isRaw
113{
114 my $self = shift ;
115
116 my $got = $self->_isRawx(@_);
117
118 if ($got) {
119 *$self->{Pending} = *$self->{HeaderPending} ;
120 }
121 else {
122 $self->pushBack(*$self->{HeaderPending});
123 *$self->{Uncomp}->reset();
124 }
125 *$self->{HeaderPending} = '';
126
127 return $got ;
642e522c 128}
129
1a6a8453 130sub _isRawx
131{
132 my $self = shift ;
133 my $magic = shift ;
134
135 $magic = '' unless defined $magic ;
136
137 my $buffer = '';
138
139 $self->smartRead(\$buffer, *$self->{BlockSize}) >= 0
140 or return $self->saveErrorString(undef, "No data to read");
141
142 my $temp_buf = $magic . $buffer ;
143 *$self->{HeaderPending} = $temp_buf ;
144 $buffer = '';
145 my $status = *$self->{Uncomp}->uncompr(\$temp_buf, \$buffer, $self->smartEof()) ;
146 return $self->saveErrorString(undef, *$self->{Uncomp}{Error}, STATUS_ERROR)
147 if $status == STATUS_ERROR;
148
a02d0f6f 149 my $buf_len = *$self->{Uncomp}->uncompressedBytes();
1a6a8453 150
151 if ($status == STATUS_ENDSTREAM) {
152 if (*$self->{MultiStream}
153 && (length $temp_buf || ! $self->smartEof())){
154 *$self->{NewStream} = 1 ;
155 *$self->{EndStream} = 0 ;
156 $self->pushBack($temp_buf);
157 }
158 else {
159 *$self->{EndStream} = 1 ;
160 $self->pushBack($temp_buf);
161 }
162 }
163 *$self->{HeaderPending} = $buffer ;
164 *$self->{InflatedBytesRead} = $buf_len ;
165 *$self->{TotalInflatedBytesRead} += $buf_len ;
166 *$self->{Type} = 'rfc1951';
167
168 $self->saveStatus(STATUS_OK);
169
170 return {
171 'Type' => 'rfc1951',
172 'HeaderLength' => 0,
173 'TrailerLength' => 0,
174 'Header' => ''
175 };
176}
177
178
179sub inflateSync
180{
181 my $self = shift ;
182
183 # inflateSync is a no-op in Plain mode
184 return 1
185 if *$self->{Plain} ;
186
187 return 0 if *$self->{Closed} ;
188 #return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ;
189 return 0 if ! length *$self->{Pending} && *$self->{EndStream} ;
190
191 # Disable CRC check
192 *$self->{Strict} = 0 ;
193
194 my $status ;
195 while (1)
196 {
197 my $temp_buf ;
198
199 if (length *$self->{Pending} )
200 {
201 $temp_buf = *$self->{Pending} ;
202 *$self->{Pending} = '';
203 }
204 else
205 {
206 $status = $self->smartRead(\$temp_buf, *$self->{BlockSize}) ;
207 return $self->saveErrorString(0, "Error Reading Data")
208 if $status < 0 ;
209
210 if ($status == 0 ) {
211 *$self->{EndStream} = 1 ;
212 return $self->saveErrorString(0, "unexpected end of file", STATUS_ERROR);
213 }
214 }
215
216 $status = *$self->{Uncomp}->sync($temp_buf) ;
217
218 if ($status == STATUS_OK)
219 {
220 *$self->{Pending} .= $temp_buf ;
221 return 1 ;
222 }
223
224 last unless $status == STATUS_ERROR ;
225 }
226
227 return 0;
228}
229
230#sub performScan
231#{
232# my $self = shift ;
233#
234# my $status ;
235# my $end_offset = 0;
236#
237# $status = $self->scan()
238# #or return $self->saveErrorString(undef, "Error Scanning: $$error_ref", $self->errorNo) ;
239# or return $self->saveErrorString(G_ERR, "Error Scanning: $status")
240#
241# $status = $self->zap($end_offset)
242# or return $self->saveErrorString(G_ERR, "Error Zapping: $status");
243# #or return $self->saveErrorString(undef, "Error Zapping: $$error_ref", $self->errorNo) ;
244#
245# #(*$obj->{Deflate}, $status) = $inf->createDeflate();
246#
247## *$obj->{Header} = *$inf->{Info}{Header};
248## *$obj->{UnCompSize_32bit} =
249## *$obj->{BytesWritten} = *$inf->{UnCompSize_32bit} ;
250## *$obj->{CompSize_32bit} = *$inf->{CompSize_32bit} ;
251#
252#
253## if ( $outType eq 'buffer')
254## { substr( ${ *$self->{Buffer} }, $end_offset) = '' }
255## elsif ($outType eq 'handle' || $outType eq 'filename') {
256## *$self->{FH} = *$inf->{FH} ;
257## delete *$inf->{FH};
258## *$obj->{FH}->flush() ;
259## *$obj->{Handle} = 1 if $outType eq 'handle';
260##
261## #seek(*$obj->{FH}, $end_offset, SEEK_SET)
262## *$obj->{FH}->seek($end_offset, SEEK_SET)
263## or return $obj->saveErrorString(undef, $!, $!) ;
264## }
265#
266#}
267
268sub scan
269{
270 my $self = shift ;
271
272 return 1 if *$self->{Closed} ;
273 return 1 if !length *$self->{Pending} && *$self->{EndStream} ;
274
275 my $buffer = '' ;
276 my $len = 0;
277
278 $len = $self->_raw_read(\$buffer, 1)
279 while ! *$self->{EndStream} && $len >= 0 ;
280
281 #return $len if $len < 0 ? $len : 0 ;
282 return $len < 0 ? 0 : 1 ;
283}
284
285sub zap
286{
287 my $self = shift ;
288
289 my $headerLength = *$self->{Info}{HeaderLength};
290 my $block_offset = $headerLength + *$self->{Uncomp}->getLastBlockOffset();
291 $_[0] = $headerLength + *$self->{Uncomp}->getEndOffset();
292 #printf "# End $_[0], headerlen $headerLength \n";;
293 #printf "# block_offset $block_offset %x\n", $block_offset;
294 my $byte ;
295 ( $self->smartSeek($block_offset) &&
296 $self->smartRead(\$byte, 1) )
297 or return $self->saveErrorString(0, $!, $!);
298
299 #printf "#byte is %x\n", unpack('C*',$byte);
300 *$self->{Uncomp}->resetLastBlockByte($byte);
301 #printf "#to byte is %x\n", unpack('C*',$byte);
302
303 ( $self->smartSeek($block_offset) &&
304 $self->smartWrite($byte) )
305 or return $self->saveErrorString(0, $!, $!);
306
307 #$self->smartSeek($end_offset, 1);
308
309 return 1 ;
310}
311
312sub createDeflate
313{
314 my $self = shift ;
315 my ($def, $status) = *$self->{Uncomp}->createDeflateStream(
316 -AppendOutput => 1,
317 -WindowBits => - MAX_WBITS,
318 -CRC32 => *$self->{Params}->value('CRC32'),
319 -ADLER32 => *$self->{Params}->value('ADLER32'),
320 );
321
322 return wantarray ? ($status, $def) : $def ;
323}
324
325
642e522c 3261;
327
328__END__
329
330
331=head1 NAME
332
a02d0f6f 333
642e522c 334IO::Uncompress::RawInflate - Perl interface to read RFC 1951 files/buffers
335
a02d0f6f 336
642e522c 337=head1 SYNOPSIS
338
339 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
340
341 my $status = rawinflate $input => $output [,OPTS]
342 or die "rawinflate failed: $RawInflateError\n";
343
344 my $z = new IO::Uncompress::RawInflate $input [OPTS]
345 or die "rawinflate failed: $RawInflateError\n";
346
347 $status = $z->read($buffer)
348 $status = $z->read($buffer, $length)
349 $status = $z->read($buffer, $length, $offset)
350 $line = $z->getline()
351 $char = $z->getc()
352 $char = $z->ungetc()
a02d0f6f 353 $char = $z->opened()
354
642e522c 355 $status = $z->inflateSync()
a02d0f6f 356
642e522c 357 $z->trailingData()
358 $data = $z->getHeaderInfo()
359 $z->tell()
360 $z->seek($position, $whence)
361 $z->binmode()
362 $z->fileno()
363 $z->eof()
364 $z->close()
365
366 $RawInflateError ;
367
368 # IO::File mode
369
370 <$z>
371 read($z, $buffer);
372 read($z, $buffer, $length);
373 read($z, $buffer, $length, $offset);
374 tell($z)
375 seek($z, $position, $whence)
376 binmode($z)
377 fileno($z)
378 eof($z)
379 close($z)
380
381
382=head1 DESCRIPTION
383
384
385
386B<WARNING -- This is a Beta release>.
387
388=over 5
389
390=item * DO NOT use in production code.
391
392=item * The documentation is incomplete in places.
393
394=item * Parts of the interface defined here are tentative.
395
396=item * Please report any problems you find.
397
398=back
399
400
401
402
403
1a6a8453 404This module provides a Perl interface that allows the reading of
642e522c 405files/buffers that conform to RFC 1951.
406
1a6a8453 407For writing RFC 1951 files/buffers, see the companion module IO::Compress::RawDeflate.
642e522c 408
409
410
411=head1 Functional Interface
412
1a6a8453 413A top-level function, C<rawinflate>, is provided to carry out
414"one-shot" uncompression between buffers and/or files. For finer
415control over the uncompression process, see the L</"OO Interface">
416section.
642e522c 417
418 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
419
420 rawinflate $input => $output [,OPTS]
421 or die "rawinflate failed: $RawInflateError\n";
422
1a6a8453 423
642e522c 424
425The functional interface needs Perl5.005 or better.
426
427
428=head2 rawinflate $input => $output [, OPTS]
429
1a6a8453 430
431C<rawinflate> expects at least two parameters, C<$input> and C<$output>.
642e522c 432
433=head3 The C<$input> parameter
434
435The parameter, C<$input>, is used to define the source of
436the compressed data.
437
438It can take one of the following forms:
439
440=over 5
441
442=item A filename
443
444If the C<$input> parameter is a simple scalar, it is assumed to be a
445filename. This file will be opened for reading and the input data
446will be read from it.
447
448=item A filehandle
449
450If the C<$input> parameter is a filehandle, the input data will be
451read from it.
452The string '-' can be used as an alias for standard input.
453
454=item A scalar reference
455
456If C<$input> is a scalar reference, the input data will be read
457from C<$$input>.
458
459=item An array reference
460
1a6a8453 461If C<$input> is an array reference, each element in the array must be a
462filename.
463
464The input data will be read from each file in turn.
465
642e522c 466The complete array will be walked to ensure that it only
1a6a8453 467contains valid filenames before any data is uncompressed.
468
469
642e522c 470
471=item An Input FileGlob string
472
473If C<$input> is a string that is delimited by the characters "<" and ">"
474C<rawinflate> will assume that it is an I<input fileglob string>. The
475input is the list of files that match the fileglob.
476
477If the fileglob does not match any files ...
478
479See L<File::GlobMapper|File::GlobMapper> for more details.
480
481
482=back
483
484If the C<$input> parameter is any other type, C<undef> will be returned.
485
486
487
488=head3 The C<$output> parameter
489
490The parameter C<$output> is used to control the destination of the
491uncompressed data. This parameter can take one of these forms.
492
493=over 5
494
495=item A filename
496
1a6a8453 497If the C<$output> parameter is a simple scalar, it is assumed to be a
498filename. This file will be opened for writing and the uncompressed
499data will be written to it.
642e522c 500
501=item A filehandle
502
1a6a8453 503If the C<$output> parameter is a filehandle, the uncompressed data
504will be written to it.
642e522c 505The string '-' can be used as an alias for standard output.
506
507
508=item A scalar reference
509
1a6a8453 510If C<$output> is a scalar reference, the uncompressed data will be
511stored in C<$$output>.
642e522c 512
513
642e522c 514
515=item An Array Reference
516
1a6a8453 517If C<$output> is an array reference, the uncompressed data will be
518pushed onto the array.
642e522c 519
520=item An Output FileGlob
521
522If C<$output> is a string that is delimited by the characters "<" and ">"
523C<rawinflate> will assume that it is an I<output fileglob string>. The
524output is the list of files that match the fileglob.
525
526When C<$output> is an fileglob string, C<$input> must also be a fileglob
527string. Anything else is an error.
528
529=back
530
531If the C<$output> parameter is any other type, C<undef> will be returned.
532
642e522c 533
642e522c 534
535=head2 Notes
536
537When C<$input> maps to multiple files/buffers and C<$output> is a single
1a6a8453 538file/buffer the uncompressed input files/buffers will all be stored
539in C<$output> as a single uncompressed stream.
642e522c 540
541
542
543=head2 Optional Parameters
544
545Unless specified below, the optional parameters for C<rawinflate>,
546C<OPTS>, are the same as those used with the OO interface defined in the
547L</"Constructor Options"> section below.
548
549=over 5
550
551=item AutoClose =E<gt> 0|1
552
1a6a8453 553This option applies to any input or output data streams to
554C<rawinflate> that are filehandles.
642e522c 555
556If C<AutoClose> is specified, and the value is true, it will result in all
557input and/or output filehandles being closed once C<rawinflate> has
558completed.
559
560This parameter defaults to 0.
561
562
563
1a6a8453 564=item BinModeOut =E<gt> 0|1
565
566When writing to a file or filehandle, set C<binmode> before writing to the
567file.
568
569Defaults to 0.
570
571
572
573
574
642e522c 575=item -Append =E<gt> 0|1
576
577TODO
578
1a6a8453 579=item -MultiStream =E<gt> 0|1
580
581Creates a new stream after each file.
582
583Defaults to 1.
584
642e522c 585
586
587=back
588
589
590
591
592=head2 Examples
593
594To read the contents of the file C<file1.txt.1951> and write the
595compressed data to the file C<file1.txt>.
596
597 use strict ;
598 use warnings ;
599 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
600
601 my $input = "file1.txt.1951";
602 my $output = "file1.txt";
603 rawinflate $input => $output
604 or die "rawinflate failed: $RawInflateError\n";
605
606
607To read from an existing Perl filehandle, C<$input>, and write the
608uncompressed data to a buffer, C<$buffer>.
609
610 use strict ;
611 use warnings ;
612 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
613 use IO::File ;
614
615 my $input = new IO::File "<file1.txt.1951"
616 or die "Cannot open 'file1.txt.1951': $!\n" ;
617 my $buffer ;
618 rawinflate $input => \$buffer
619 or die "rawinflate failed: $RawInflateError\n";
620
621To uncompress all files in the directory "/my/home" that match "*.txt.1951" and store the compressed data in the same directory
622
623 use strict ;
624 use warnings ;
625 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
626
627 rawinflate '</my/home/*.txt.1951>' => '</my/home/#1.txt>'
628 or die "rawinflate failed: $RawInflateError\n";
629
630and if you want to compress each file one at a time, this will do the trick
631
632 use strict ;
633 use warnings ;
634 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
635
636 for my $input ( glob "/my/home/*.txt.1951" )
637 {
638 my $output = $input;
639 $output =~ s/.1951// ;
640 rawinflate $input => $output
641 or die "Error compressing '$input': $RawInflateError\n";
642 }
643
644=head1 OO Interface
645
646=head2 Constructor
647
648The format of the constructor for IO::Uncompress::RawInflate is shown below
649
650
651 my $z = new IO::Uncompress::RawInflate $input [OPTS]
652 or die "IO::Uncompress::RawInflate failed: $RawInflateError\n";
653
654Returns an C<IO::Uncompress::RawInflate> object on success and undef on failure.
655The variable C<$RawInflateError> will contain an error message on failure.
656
1a6a8453 657If you are running Perl 5.005 or better the object, C<$z>, returned from
658IO::Uncompress::RawInflate can be used exactly like an L<IO::File|IO::File> filehandle.
659This means that all normal input file operations can be carried out with
660C<$z>. For example, to read a line from a compressed file/buffer you can
661use either of these forms
642e522c 662
663 $line = $z->getline();
664 $line = <$z>;
665
666The mandatory parameter C<$input> is used to determine the source of the
667compressed data. This parameter can take one of three forms.
668
669=over 5
670
671=item A filename
672
673If the C<$input> parameter is a scalar, it is assumed to be a filename. This
674file will be opened for reading and the compressed data will be read from it.
675
676=item A filehandle
677
678If the C<$input> parameter is a filehandle, the compressed data will be
679read from it.
680The string '-' can be used as an alias for standard input.
681
682
683=item A scalar reference
684
685If C<$input> is a scalar reference, the compressed data will be read from
686C<$$output>.
687
688=back
689
690=head2 Constructor Options
691
692
693The option names defined below are case insensitive and can be optionally
694prefixed by a '-'. So all of the following are valid
695
696 -AutoClose
697 -autoclose
698 AUTOCLOSE
699 autoclose
700
701OPTS is a combination of the following options:
702
703=over 5
704
705=item -AutoClose =E<gt> 0|1
706
707This option is only valid when the C<$input> parameter is a filehandle. If
708specified, and the value is true, it will result in the file being closed once
709either the C<close> method is called or the IO::Uncompress::RawInflate object is
710destroyed.
711
712This parameter defaults to 0.
713
714=item -MultiStream =E<gt> 0|1
715
716
717
718This option is a no-op.
719
720
721
722=item -Prime =E<gt> $string
723
724This option will uncompress the contents of C<$string> before processing the
725input file/buffer.
726
727This option can be useful when the compressed data is embedded in another
728file/data structure and it is not possible to work out where the compressed
1a6a8453 729data begins without having to read the first few bytes. If this is the
730case, the uncompression can be I<primed> with these bytes using this
731option.
642e522c 732
733=item -Transparent =E<gt> 0|1
734
735If this option is set and the input file or buffer is not compressed data,
736the module will allow reading of it anyway.
737
738This option defaults to 1.
739
740=item -BlockSize =E<gt> $num
741
1a6a8453 742When reading the compressed input data, IO::Uncompress::RawInflate will read it in
743blocks of C<$num> bytes.
642e522c 744
745This option defaults to 4096.
746
747=item -InputLength =E<gt> $size
748
1a6a8453 749When present this option will limit the number of compressed bytes read
750from the input file/buffer to C<$size>. This option can be used in the
751situation where there is useful data directly after the compressed data
752stream and you know beforehand the exact length of the compressed data
753stream.
642e522c 754
1a6a8453 755This option is mostly used when reading from a filehandle, in which case
756the file pointer will be left pointing to the first byte directly after the
642e522c 757compressed data stream.
758
759
760
761This option defaults to off.
762
763=item -Append =E<gt> 0|1
764
765This option controls what the C<read> method does with uncompressed data.
766
1a6a8453 767If set to 1, all uncompressed data will be appended to the output parameter
768of the C<read> method.
642e522c 769
1a6a8453 770If set to 0, the contents of the output parameter of the C<read> method
771will be overwritten by the uncompressed data.
642e522c 772
773Defaults to 0.
774
775=item -Strict =E<gt> 0|1
776
777
778
779This option is a no-op.
780
781
782
783
784
a02d0f6f 785
642e522c 786=back
787
788=head2 Examples
789
790TODO
791
792=head1 Methods
793
794=head2 read
795
796Usage is
797
798 $status = $z->read($buffer)
799
800Reads a block of compressed data (the size the the compressed block is
801determined by the C<Buffer> option in the constructor), uncompresses it and
1a6a8453 802writes any uncompressed data into C<$buffer>. If the C<Append> parameter is
803set in the constructor, the uncompressed data will be appended to the
804C<$buffer> parameter. Otherwise C<$buffer> will be overwritten.
642e522c 805
1a6a8453 806Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
807or a negative number on error.
642e522c 808
809=head2 read
810
811Usage is
812
813 $status = $z->read($buffer, $length)
814 $status = $z->read($buffer, $length, $offset)
815
816 $status = read($z, $buffer, $length)
817 $status = read($z, $buffer, $length, $offset)
818
819Attempt to read C<$length> bytes of uncompressed data into C<$buffer>.
820
1a6a8453 821The main difference between this form of the C<read> method and the
822previous one, is that this one will attempt to return I<exactly> C<$length>
823bytes. The only circumstances that this function will not is if end-of-file
824or an IO error is encountered.
642e522c 825
1a6a8453 826Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
827or a negative number on error.
642e522c 828
829
830=head2 getline
831
832Usage is
833
834 $line = $z->getline()
835 $line = <$z>
836
837Reads a single line.
838
839This method fully supports the use of of the variable C<$/>
840(or C<$INPUT_RECORD_SEPARATOR> or C<$RS> when C<English> is in use) to
841determine what constitutes an end of line. Both paragraph mode and file
842slurp mode are supported.
843
844
845=head2 getc
846
847Usage is
848
849 $char = $z->getc()
850
851Read a single character.
852
853=head2 ungetc
854
855Usage is
856
857 $char = $z->ungetc($string)
858
859
a02d0f6f 860
642e522c 861=head2 inflateSync
862
863Usage is
864
865 $status = $z->inflateSync()
866
867TODO
868
a02d0f6f 869
642e522c 870=head2 getHeaderInfo
871
872Usage is
873
1a6a8453 874 $hdr = $z->getHeaderInfo();
875 @hdrs = $z->getHeaderInfo();
642e522c 876
1a6a8453 877This method returns either a hash reference (in scalar context) or a list
878or hash references (in array context) that contains information about each
879of the header fields in the compressed data stream(s).
642e522c 880
881
882
883
884=head2 tell
885
886Usage is
887
888 $z->tell()
889 tell $z
890
891Returns the uncompressed file offset.
892
893=head2 eof
894
895Usage is
896
897 $z->eof();
898 eof($z);
899
900
901
902Returns true if the end of the compressed input stream has been reached.
903
904
905
906=head2 seek
907
908 $z->seek($position, $whence);
909 seek($z, $position, $whence);
910
911
912
913
914Provides a sub-set of the C<seek> functionality, with the restriction
915that it is only legal to seek forward in the input file/buffer.
916It is a fatal error to attempt to seek backward.
917
918
919
920The C<$whence> parameter takes one the usual values, namely SEEK_SET,
921SEEK_CUR or SEEK_END.
922
923Returns 1 on success, 0 on failure.
924
925=head2 binmode
926
927Usage is
928
929 $z->binmode
930 binmode $z ;
931
932This is a noop provided for completeness.
933
a02d0f6f 934=head2 opened
935
936 $z->opened()
937
938Returns true if the object currently refers to a opened file/buffer.
939
940=head2 autoflush
941
942 my $prev = $z->autoflush()
943 my $prev = $z->autoflush(EXPR)
944
945If the C<$z> object is associated with a file or a filehandle, this method
946returns the current autoflush setting for the underlying filehandle. If
947C<EXPR> is present, and is non-zero, it will enable flushing after every
948write/print operation.
949
950If C<$z> is associated with a buffer, this method has no effect and always
951returns C<undef>.
952
953B<Note> that the special variable C<$|> B<cannot> be used to set or
954retrieve the autoflush setting.
955
956=head2 input_line_number
957
958 $z->input_line_number()
959 $z->input_line_number(EXPR)
960
961
962
963Returns the current uncompressed line number. If C<EXPR> is present it has
964the effect of setting the line number. Note that setting the line number
965does not change the current position within the file/buffer being read.
966
967The contents of C<$/> are used to to determine what constitutes a line
968terminator.
969
970
971
642e522c 972=head2 fileno
973
974 $z->fileno()
975 fileno($z)
976
a02d0f6f 977If the C<$z> object is associated with a file or a filehandle, this method
978will return the underlying file descriptor.
642e522c 979
980If the C<$z> object is is associated with a buffer, this method will
981return undef.
982
983=head2 close
984
985 $z->close() ;
986 close $z ;
987
988
989
990Closes the output file/buffer.
991
992
993
994For most versions of Perl this method will be automatically invoked if
995the IO::Uncompress::RawInflate object is destroyed (either explicitly or by the
996variable with the reference to the object going out of scope). The
997exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
998these cases, the C<close> method will be called automatically, but
999not until global destruction of all live objects when the program is
1000terminating.
1001
1002Therefore, if you want your scripts to be able to run on all versions
1003of Perl, you should call C<close> explicitly and not rely on automatic
1004closing.
1005
1006Returns true on success, otherwise 0.
1007
1008If the C<AutoClose> option has been enabled when the IO::Uncompress::RawInflate
1009object was created, and the object is associated with a file, the
1010underlying file will also be closed.
1011
1012
1013
1014
1015=head1 Importing
1016
1017No symbolic constants are required by this IO::Uncompress::RawInflate at present.
1018
1019=over 5
1020
1021=item :all
1022
1023Imports C<rawinflate> and C<$RawInflateError>.
1024Same as doing this
1025
1026 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
1027
1028=back
1029
1030=head1 EXAMPLES
1031
1032
1033
1034
1035=head1 SEE ALSO
1036
a02d0f6f 1037L<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>
642e522c 1038
1039L<Compress::Zlib::FAQ|Compress::Zlib::FAQ>
1040
a02d0f6f 1041L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
1042L<Archive::Tar|Archive::Tar>,
642e522c 1043L<IO::Zlib|IO::Zlib>
1044
a02d0f6f 1045
642e522c 1046For RFC 1950, 1951 and 1952 see
1047F<http://www.faqs.org/rfcs/rfc1950.html>,
1048F<http://www.faqs.org/rfcs/rfc1951.html> and
1049F<http://www.faqs.org/rfcs/rfc1952.html>
1050
a02d0f6f 1051The I<zlib> compression library was written by Jean-loup Gailly
1052F<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.
1053
1054The primary site for the I<zlib> compression library is
1055F<http://www.zlib.org>.
1056
1057The primary site for gzip is F<http://www.gzip.org>.
1058
1059
1060
1061
1062
1063
642e522c 1064
1065=head1 AUTHOR
1066
1067The I<IO::Uncompress::RawInflate> module was written by Paul Marquess,
a02d0f6f 1068F<pmqs@cpan.org>.
642e522c 1069
642e522c 1070
642e522c 1071
1072=head1 MODIFICATION HISTORY
1073
1074See the Changes file.
1075
1076=head1 COPYRIGHT AND LICENSE
1077
1078
1a6a8453 1079Copyright (c) 2005-2006 Paul Marquess. All rights reserved.
a02d0f6f 1080
642e522c 1081This program is free software; you can redistribute it and/or
1082modify it under the same terms as Perl itself.
1083