Compress::Zlib becomes zlib agnostic
[p5sagit/p5-mst-13.2.git] / ext / Compress / Zlib / lib / IO / Uncompress / RawInflate.pm
CommitLineData
642e522c 1package IO::Uncompress::RawInflate ;
2# for RFC1951
3
4use strict ;
5use warnings;
1a6a8453 6
7use Compress::Zlib 2 ;
8use Compress::Zlib::Common qw(:Status createSelfTiedObject);
9use Compress::Zlib::ParseParameters ;
10
11use IO::Uncompress::Base ;
12use UncompressPlugin::Inflate ;
13
14
15
642e522c 16
17require Exporter ;
1a6a8453 18our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $RawInflateError);
642e522c 19
1a6a8453 20$VERSION = '2.000_07';
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
64 my ($obj, $errstr, $errno) = UncompressPlugin::Inflate::mkUncompObject(
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{
109 return 1 ;
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
149 my $buf_len = *$self->{Uncomp}->count();
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
333IO::Uncompress::RawInflate - Perl interface to read RFC 1951 files/buffers
334
335=head1 SYNOPSIS
336
337 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
338
339 my $status = rawinflate $input => $output [,OPTS]
340 or die "rawinflate failed: $RawInflateError\n";
341
342 my $z = new IO::Uncompress::RawInflate $input [OPTS]
343 or die "rawinflate failed: $RawInflateError\n";
344
345 $status = $z->read($buffer)
346 $status = $z->read($buffer, $length)
347 $status = $z->read($buffer, $length, $offset)
348 $line = $z->getline()
349 $char = $z->getc()
350 $char = $z->ungetc()
351 $status = $z->inflateSync()
352 $z->trailingData()
353 $data = $z->getHeaderInfo()
354 $z->tell()
355 $z->seek($position, $whence)
356 $z->binmode()
357 $z->fileno()
358 $z->eof()
359 $z->close()
360
361 $RawInflateError ;
362
363 # IO::File mode
364
365 <$z>
366 read($z, $buffer);
367 read($z, $buffer, $length);
368 read($z, $buffer, $length, $offset);
369 tell($z)
370 seek($z, $position, $whence)
371 binmode($z)
372 fileno($z)
373 eof($z)
374 close($z)
375
376
377=head1 DESCRIPTION
378
379
380
381B<WARNING -- This is a Beta release>.
382
383=over 5
384
385=item * DO NOT use in production code.
386
387=item * The documentation is incomplete in places.
388
389=item * Parts of the interface defined here are tentative.
390
391=item * Please report any problems you find.
392
393=back
394
395
396
397
398
1a6a8453 399This module provides a Perl interface that allows the reading of
642e522c 400files/buffers that conform to RFC 1951.
401
1a6a8453 402For writing RFC 1951 files/buffers, see the companion module IO::Compress::RawDeflate.
642e522c 403
404
405
406=head1 Functional Interface
407
1a6a8453 408A top-level function, C<rawinflate>, is provided to carry out
409"one-shot" uncompression between buffers and/or files. For finer
410control over the uncompression process, see the L</"OO Interface">
411section.
642e522c 412
413 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
414
415 rawinflate $input => $output [,OPTS]
416 or die "rawinflate failed: $RawInflateError\n";
417
1a6a8453 418
642e522c 419
420The functional interface needs Perl5.005 or better.
421
422
423=head2 rawinflate $input => $output [, OPTS]
424
1a6a8453 425
426C<rawinflate> expects at least two parameters, C<$input> and C<$output>.
642e522c 427
428=head3 The C<$input> parameter
429
430The parameter, C<$input>, is used to define the source of
431the compressed data.
432
433It can take one of the following forms:
434
435=over 5
436
437=item A filename
438
439If the C<$input> parameter is a simple scalar, it is assumed to be a
440filename. This file will be opened for reading and the input data
441will be read from it.
442
443=item A filehandle
444
445If the C<$input> parameter is a filehandle, the input data will be
446read from it.
447The string '-' can be used as an alias for standard input.
448
449=item A scalar reference
450
451If C<$input> is a scalar reference, the input data will be read
452from C<$$input>.
453
454=item An array reference
455
1a6a8453 456If C<$input> is an array reference, each element in the array must be a
457filename.
458
459The input data will be read from each file in turn.
460
642e522c 461The complete array will be walked to ensure that it only
1a6a8453 462contains valid filenames before any data is uncompressed.
463
464
642e522c 465
466=item An Input FileGlob string
467
468If C<$input> is a string that is delimited by the characters "<" and ">"
469C<rawinflate> will assume that it is an I<input fileglob string>. The
470input is the list of files that match the fileglob.
471
472If the fileglob does not match any files ...
473
474See L<File::GlobMapper|File::GlobMapper> for more details.
475
476
477=back
478
479If the C<$input> parameter is any other type, C<undef> will be returned.
480
481
482
483=head3 The C<$output> parameter
484
485The parameter C<$output> is used to control the destination of the
486uncompressed data. This parameter can take one of these forms.
487
488=over 5
489
490=item A filename
491
1a6a8453 492If the C<$output> parameter is a simple scalar, it is assumed to be a
493filename. This file will be opened for writing and the uncompressed
494data will be written to it.
642e522c 495
496=item A filehandle
497
1a6a8453 498If the C<$output> parameter is a filehandle, the uncompressed data
499will be written to it.
642e522c 500The string '-' can be used as an alias for standard output.
501
502
503=item A scalar reference
504
1a6a8453 505If C<$output> is a scalar reference, the uncompressed data will be
506stored in C<$$output>.
642e522c 507
508
642e522c 509
510=item An Array Reference
511
1a6a8453 512If C<$output> is an array reference, the uncompressed data will be
513pushed onto the array.
642e522c 514
515=item An Output FileGlob
516
517If C<$output> is a string that is delimited by the characters "<" and ">"
518C<rawinflate> will assume that it is an I<output fileglob string>. The
519output is the list of files that match the fileglob.
520
521When C<$output> is an fileglob string, C<$input> must also be a fileglob
522string. Anything else is an error.
523
524=back
525
526If the C<$output> parameter is any other type, C<undef> will be returned.
527
642e522c 528
642e522c 529
530=head2 Notes
531
532When C<$input> maps to multiple files/buffers and C<$output> is a single
1a6a8453 533file/buffer the uncompressed input files/buffers will all be stored
534in C<$output> as a single uncompressed stream.
642e522c 535
536
537
538=head2 Optional Parameters
539
540Unless specified below, the optional parameters for C<rawinflate>,
541C<OPTS>, are the same as those used with the OO interface defined in the
542L</"Constructor Options"> section below.
543
544=over 5
545
546=item AutoClose =E<gt> 0|1
547
1a6a8453 548This option applies to any input or output data streams to
549C<rawinflate> that are filehandles.
642e522c 550
551If C<AutoClose> is specified, and the value is true, it will result in all
552input and/or output filehandles being closed once C<rawinflate> has
553completed.
554
555This parameter defaults to 0.
556
557
558
1a6a8453 559=item BinModeOut =E<gt> 0|1
560
561When writing to a file or filehandle, set C<binmode> before writing to the
562file.
563
564Defaults to 0.
565
566
567
568
569
642e522c 570=item -Append =E<gt> 0|1
571
572TODO
573
1a6a8453 574=item -MultiStream =E<gt> 0|1
575
576Creates a new stream after each file.
577
578Defaults to 1.
579
642e522c 580
581
582=back
583
584
585
586
587=head2 Examples
588
589To read the contents of the file C<file1.txt.1951> and write the
590compressed data to the file C<file1.txt>.
591
592 use strict ;
593 use warnings ;
594 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
595
596 my $input = "file1.txt.1951";
597 my $output = "file1.txt";
598 rawinflate $input => $output
599 or die "rawinflate failed: $RawInflateError\n";
600
601
602To read from an existing Perl filehandle, C<$input>, and write the
603uncompressed data to a buffer, C<$buffer>.
604
605 use strict ;
606 use warnings ;
607 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
608 use IO::File ;
609
610 my $input = new IO::File "<file1.txt.1951"
611 or die "Cannot open 'file1.txt.1951': $!\n" ;
612 my $buffer ;
613 rawinflate $input => \$buffer
614 or die "rawinflate failed: $RawInflateError\n";
615
616To uncompress all files in the directory "/my/home" that match "*.txt.1951" and store the compressed data in the same directory
617
618 use strict ;
619 use warnings ;
620 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
621
622 rawinflate '</my/home/*.txt.1951>' => '</my/home/#1.txt>'
623 or die "rawinflate failed: $RawInflateError\n";
624
625and if you want to compress each file one at a time, this will do the trick
626
627 use strict ;
628 use warnings ;
629 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
630
631 for my $input ( glob "/my/home/*.txt.1951" )
632 {
633 my $output = $input;
634 $output =~ s/.1951// ;
635 rawinflate $input => $output
636 or die "Error compressing '$input': $RawInflateError\n";
637 }
638
639=head1 OO Interface
640
641=head2 Constructor
642
643The format of the constructor for IO::Uncompress::RawInflate is shown below
644
645
646 my $z = new IO::Uncompress::RawInflate $input [OPTS]
647 or die "IO::Uncompress::RawInflate failed: $RawInflateError\n";
648
649Returns an C<IO::Uncompress::RawInflate> object on success and undef on failure.
650The variable C<$RawInflateError> will contain an error message on failure.
651
1a6a8453 652If you are running Perl 5.005 or better the object, C<$z>, returned from
653IO::Uncompress::RawInflate can be used exactly like an L<IO::File|IO::File> filehandle.
654This means that all normal input file operations can be carried out with
655C<$z>. For example, to read a line from a compressed file/buffer you can
656use either of these forms
642e522c 657
658 $line = $z->getline();
659 $line = <$z>;
660
661The mandatory parameter C<$input> is used to determine the source of the
662compressed data. This parameter can take one of three forms.
663
664=over 5
665
666=item A filename
667
668If the C<$input> parameter is a scalar, it is assumed to be a filename. This
669file will be opened for reading and the compressed data will be read from it.
670
671=item A filehandle
672
673If the C<$input> parameter is a filehandle, the compressed data will be
674read from it.
675The string '-' can be used as an alias for standard input.
676
677
678=item A scalar reference
679
680If C<$input> is a scalar reference, the compressed data will be read from
681C<$$output>.
682
683=back
684
685=head2 Constructor Options
686
687
688The option names defined below are case insensitive and can be optionally
689prefixed by a '-'. So all of the following are valid
690
691 -AutoClose
692 -autoclose
693 AUTOCLOSE
694 autoclose
695
696OPTS is a combination of the following options:
697
698=over 5
699
700=item -AutoClose =E<gt> 0|1
701
702This option is only valid when the C<$input> parameter is a filehandle. If
703specified, and the value is true, it will result in the file being closed once
704either the C<close> method is called or the IO::Uncompress::RawInflate object is
705destroyed.
706
707This parameter defaults to 0.
708
709=item -MultiStream =E<gt> 0|1
710
711
712
713This option is a no-op.
714
715
716
717=item -Prime =E<gt> $string
718
719This option will uncompress the contents of C<$string> before processing the
720input file/buffer.
721
722This option can be useful when the compressed data is embedded in another
723file/data structure and it is not possible to work out where the compressed
1a6a8453 724data begins without having to read the first few bytes. If this is the
725case, the uncompression can be I<primed> with these bytes using this
726option.
642e522c 727
728=item -Transparent =E<gt> 0|1
729
730If this option is set and the input file or buffer is not compressed data,
731the module will allow reading of it anyway.
732
733This option defaults to 1.
734
735=item -BlockSize =E<gt> $num
736
1a6a8453 737When reading the compressed input data, IO::Uncompress::RawInflate will read it in
738blocks of C<$num> bytes.
642e522c 739
740This option defaults to 4096.
741
742=item -InputLength =E<gt> $size
743
1a6a8453 744When present this option will limit the number of compressed bytes read
745from the input file/buffer to C<$size>. This option can be used in the
746situation where there is useful data directly after the compressed data
747stream and you know beforehand the exact length of the compressed data
748stream.
642e522c 749
1a6a8453 750This option is mostly used when reading from a filehandle, in which case
751the file pointer will be left pointing to the first byte directly after the
642e522c 752compressed data stream.
753
754
755
756This option defaults to off.
757
758=item -Append =E<gt> 0|1
759
760This option controls what the C<read> method does with uncompressed data.
761
1a6a8453 762If set to 1, all uncompressed data will be appended to the output parameter
763of the C<read> method.
642e522c 764
1a6a8453 765If set to 0, the contents of the output parameter of the C<read> method
766will be overwritten by the uncompressed data.
642e522c 767
768Defaults to 0.
769
770=item -Strict =E<gt> 0|1
771
772
773
774This option is a no-op.
775
776
777
778
779
780=back
781
782=head2 Examples
783
784TODO
785
786=head1 Methods
787
788=head2 read
789
790Usage is
791
792 $status = $z->read($buffer)
793
794Reads a block of compressed data (the size the the compressed block is
795determined by the C<Buffer> option in the constructor), uncompresses it and
1a6a8453 796writes any uncompressed data into C<$buffer>. If the C<Append> parameter is
797set in the constructor, the uncompressed data will be appended to the
798C<$buffer> parameter. Otherwise C<$buffer> will be overwritten.
642e522c 799
1a6a8453 800Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
801or a negative number on error.
642e522c 802
803=head2 read
804
805Usage is
806
807 $status = $z->read($buffer, $length)
808 $status = $z->read($buffer, $length, $offset)
809
810 $status = read($z, $buffer, $length)
811 $status = read($z, $buffer, $length, $offset)
812
813Attempt to read C<$length> bytes of uncompressed data into C<$buffer>.
814
1a6a8453 815The main difference between this form of the C<read> method and the
816previous one, is that this one will attempt to return I<exactly> C<$length>
817bytes. The only circumstances that this function will not is if end-of-file
818or an IO error is encountered.
642e522c 819
1a6a8453 820Returns the number of uncompressed bytes written to C<$buffer>, zero if eof
821or a negative number on error.
642e522c 822
823
824=head2 getline
825
826Usage is
827
828 $line = $z->getline()
829 $line = <$z>
830
831Reads a single line.
832
833This method fully supports the use of of the variable C<$/>
834(or C<$INPUT_RECORD_SEPARATOR> or C<$RS> when C<English> is in use) to
835determine what constitutes an end of line. Both paragraph mode and file
836slurp mode are supported.
837
838
839=head2 getc
840
841Usage is
842
843 $char = $z->getc()
844
845Read a single character.
846
847=head2 ungetc
848
849Usage is
850
851 $char = $z->ungetc($string)
852
853
854=head2 inflateSync
855
856Usage is
857
858 $status = $z->inflateSync()
859
860TODO
861
862=head2 getHeaderInfo
863
864Usage is
865
1a6a8453 866 $hdr = $z->getHeaderInfo();
867 @hdrs = $z->getHeaderInfo();
642e522c 868
1a6a8453 869This method returns either a hash reference (in scalar context) or a list
870or hash references (in array context) that contains information about each
871of the header fields in the compressed data stream(s).
642e522c 872
873
874
875
876=head2 tell
877
878Usage is
879
880 $z->tell()
881 tell $z
882
883Returns the uncompressed file offset.
884
885=head2 eof
886
887Usage is
888
889 $z->eof();
890 eof($z);
891
892
893
894Returns true if the end of the compressed input stream has been reached.
895
896
897
898=head2 seek
899
900 $z->seek($position, $whence);
901 seek($z, $position, $whence);
902
903
904
905
906Provides a sub-set of the C<seek> functionality, with the restriction
907that it is only legal to seek forward in the input file/buffer.
908It is a fatal error to attempt to seek backward.
909
910
911
912The C<$whence> parameter takes one the usual values, namely SEEK_SET,
913SEEK_CUR or SEEK_END.
914
915Returns 1 on success, 0 on failure.
916
917=head2 binmode
918
919Usage is
920
921 $z->binmode
922 binmode $z ;
923
924This is a noop provided for completeness.
925
926=head2 fileno
927
928 $z->fileno()
929 fileno($z)
930
931If the C<$z> object is associated with a file, this method will return
932the underlying filehandle.
933
934If the C<$z> object is is associated with a buffer, this method will
935return undef.
936
937=head2 close
938
939 $z->close() ;
940 close $z ;
941
942
943
944Closes the output file/buffer.
945
946
947
948For most versions of Perl this method will be automatically invoked if
949the IO::Uncompress::RawInflate object is destroyed (either explicitly or by the
950variable with the reference to the object going out of scope). The
951exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
952these cases, the C<close> method will be called automatically, but
953not until global destruction of all live objects when the program is
954terminating.
955
956Therefore, if you want your scripts to be able to run on all versions
957of Perl, you should call C<close> explicitly and not rely on automatic
958closing.
959
960Returns true on success, otherwise 0.
961
962If the C<AutoClose> option has been enabled when the IO::Uncompress::RawInflate
963object was created, and the object is associated with a file, the
964underlying file will also be closed.
965
966
967
968
969=head1 Importing
970
971No symbolic constants are required by this IO::Uncompress::RawInflate at present.
972
973=over 5
974
975=item :all
976
977Imports C<rawinflate> and C<$RawInflateError>.
978Same as doing this
979
980 use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError) ;
981
982=back
983
984=head1 EXAMPLES
985
986
987
988
989=head1 SEE ALSO
990
991L<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::AnyInflate>
992
993L<Compress::Zlib::FAQ|Compress::Zlib::FAQ>
994
995L<File::GlobMapper|File::GlobMapper>, L<Archive::Tar|Archive::Zip>,
996L<IO::Zlib|IO::Zlib>
997
998For RFC 1950, 1951 and 1952 see
999F<http://www.faqs.org/rfcs/rfc1950.html>,
1000F<http://www.faqs.org/rfcs/rfc1951.html> and
1001F<http://www.faqs.org/rfcs/rfc1952.html>
1002
1003The primary site for the gzip program is F<http://www.gzip.org>.
1004
1005=head1 AUTHOR
1006
1007The I<IO::Uncompress::RawInflate> module was written by Paul Marquess,
1008F<pmqs@cpan.org>. The latest copy of the module can be
1009found on CPAN in F<modules/by-module/Compress/Compress-Zlib-x.x.tar.gz>.
1010
1011The I<zlib> compression library was written by Jean-loup Gailly
1012F<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.
1013
1014The primary site for the I<zlib> compression library is
1015F<http://www.zlib.org>.
1016
1017=head1 MODIFICATION HISTORY
1018
1019See the Changes file.
1020
1021=head1 COPYRIGHT AND LICENSE
1022
1023
1a6a8453 1024Copyright (c) 2005-2006 Paul Marquess. All rights reserved.
642e522c 1025This program is free software; you can redistribute it and/or
1026modify it under the same terms as Perl itself.
1027
1028
1029