Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / IO::Uncompress::Gunzip.3pm
CommitLineData
3fea05b9 1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "IO::Uncompress::Gunzip 3"
132.TH IO::Uncompress::Gunzip 3 "2009-11-09" "perl v5.8.7" "User Contributed Perl Documentation"
133.SH "NAME"
134IO::Uncompress::Gunzip \- Read RFC 1952 files/buffers
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
139.Ve
140.PP
141.Vb 2
142\& my $status = gunzip $input => $output [,OPTS]
143\& or die "gunzip failed: $GunzipError\en";
144.Ve
145.PP
146.Vb 2
147\& my $z = new IO::Uncompress::Gunzip $input [OPTS]
148\& or die "gunzip failed: $GunzipError\en";
149.Ve
150.PP
151.Vb 7
152\& $status = $z\->read($buffer)
153\& $status = $z\->read($buffer, $length)
154\& $status = $z\->read($buffer, $length, $offset)
155\& $line = $z\->getline()
156\& $char = $z\->getc()
157\& $char = $z\->ungetc()
158\& $char = $z\->opened()
159.Ve
160.PP
161.Vb 1
162\& $status = $z\->inflateSync()
163.Ve
164.PP
165.Vb 9
166\& $data = $z\->trailingData()
167\& $status = $z\->nextStream()
168\& $data = $z\->getHeaderInfo()
169\& $z\->tell()
170\& $z\->seek($position, $whence)
171\& $z\->binmode()
172\& $z\->fileno()
173\& $z\->eof()
174\& $z\->close()
175.Ve
176.PP
177.Vb 1
178\& $GunzipError ;
179.Ve
180.PP
181.Vb 1
182\& # IO::File mode
183.Ve
184.PP
185.Vb 10
186\& <$z>
187\& read($z, $buffer);
188\& read($z, $buffer, $length);
189\& read($z, $buffer, $length, $offset);
190\& tell($z)
191\& seek($z, $position, $whence)
192\& binmode($z)
193\& fileno($z)
194\& eof($z)
195\& close($z)
196.Ve
197.SH "DESCRIPTION"
198.IX Header "DESCRIPTION"
199This module provides a Perl interface that allows the reading of
200files/buffers that conform to \s-1RFC\s0 1952.
201.PP
202For writing \s-1RFC\s0 1952 files/buffers, see the companion module IO::Compress::Gzip.
203.SH "Functional Interface"
204.IX Header "Functional Interface"
205A top-level function, \f(CW\*(C`gunzip\*(C'\fR, is provided to carry out
206\&\*(L"one\-shot\*(R" uncompression between buffers and/or files. For finer
207control over the uncompression process, see the \*(L"\s-1OO\s0 Interface\*(R"
208section.
209.PP
210.Vb 1
211\& use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
212.Ve
213.PP
214.Vb 2
215\& gunzip $input => $output [,OPTS]
216\& or die "gunzip failed: $GunzipError\en";
217.Ve
218.PP
219The functional interface needs Perl5.005 or better.
220.ie n .Sh "gunzip $input\fP => \f(CW$output [, \s-1OPTS\s0]"
221.el .Sh "gunzip \f(CW$input\fP => \f(CW$output\fP [, \s-1OPTS\s0]"
222.IX Subsection "gunzip $input => $output [, OPTS]"
223\&\f(CW\*(C`gunzip\*(C'\fR expects at least two parameters, \f(CW$input\fR and \f(CW$output\fR.
224.PP
225\fIThe \f(CI$input\fI parameter\fR
226.IX Subsection "The $input parameter"
227.PP
228The parameter, \f(CW$input\fR, is used to define the source of
229the compressed data.
230.PP
231It can take one of the following forms:
232.IP "A filename" 5
233.IX Item "A filename"
234If the \f(CW$input\fR parameter is a simple scalar, it is assumed to be a
235filename. This file will be opened for reading and the input data
236will be read from it.
237.IP "A filehandle" 5
238.IX Item "A filehandle"
239If the \f(CW$input\fR parameter is a filehandle, the input data will be
240read from it.
241The string '\-' can be used as an alias for standard input.
242.IP "A scalar reference" 5
243.IX Item "A scalar reference"
244If \f(CW$input\fR is a scalar reference, the input data will be read
245from \f(CW$$input\fR.
246.IP "An array reference" 5
247.IX Item "An array reference"
248If \f(CW$input\fR is an array reference, each element in the array must be a
249filename.
250.Sp
251The input data will be read from each file in turn.
252.Sp
253The complete array will be walked to ensure that it only
254contains valid filenames before any data is uncompressed.
255.IP "An Input FileGlob string" 5
256.IX Item "An Input FileGlob string"
257If \f(CW$input\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
258\&\f(CW\*(C`gunzip\*(C'\fR will assume that it is an \fIinput fileglob string\fR. The
259input is the list of files that match the fileglob.
260.Sp
261If the fileglob does not match any files ...
262.Sp
263See File::GlobMapper for more details.
264.PP
265If the \f(CW$input\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
266.PP
267\fIThe \f(CI$output\fI parameter\fR
268.IX Subsection "The $output parameter"
269.PP
270The parameter \f(CW$output\fR is used to control the destination of the
271uncompressed data. This parameter can take one of these forms.
272.IP "A filename" 5
273.IX Item "A filename"
274If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a
275filename. This file will be opened for writing and the uncompressed
276data will be written to it.
277.IP "A filehandle" 5
278.IX Item "A filehandle"
279If the \f(CW$output\fR parameter is a filehandle, the uncompressed data
280will be written to it.
281The string '\-' can be used as an alias for standard output.
282.IP "A scalar reference" 5
283.IX Item "A scalar reference"
284If \f(CW$output\fR is a scalar reference, the uncompressed data will be
285stored in \f(CW$$output\fR.
286.IP "An Array Reference" 5
287.IX Item "An Array Reference"
288If \f(CW$output\fR is an array reference, the uncompressed data will be
289pushed onto the array.
290.IP "An Output FileGlob" 5
291.IX Item "An Output FileGlob"
292If \f(CW$output\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
293\&\f(CW\*(C`gunzip\*(C'\fR will assume that it is an \fIoutput fileglob string\fR. The
294output is the list of files that match the fileglob.
295.Sp
296When \f(CW$output\fR is an fileglob string, \f(CW$input\fR must also be a fileglob
297string. Anything else is an error.
298.PP
299If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
300.Sh "Notes"
301.IX Subsection "Notes"
302When \f(CW$input\fR maps to multiple compressed files/buffers and \f(CW$output\fR is
303a single file/buffer, after uncompression \f(CW$output\fR will contain a
304concatenation of all the uncompressed data from each of the input
305files/buffers.
306.Sh "Optional Parameters"
307.IX Subsection "Optional Parameters"
308Unless specified below, the optional parameters for \f(CW\*(C`gunzip\*(C'\fR,
309\&\f(CW\*(C`OPTS\*(C'\fR, are the same as those used with the \s-1OO\s0 interface defined in the
310\&\*(L"Constructor Options\*(R" section below.
311.ie n .IP """AutoClose => 0|1""" 5
312.el .IP "\f(CWAutoClose => 0|1\fR" 5
313.IX Item "AutoClose => 0|1"
314This option applies to any input or output data streams to
315\&\f(CW\*(C`gunzip\*(C'\fR that are filehandles.
316.Sp
317If \f(CW\*(C`AutoClose\*(C'\fR is specified, and the value is true, it will result in all
318input and/or output filehandles being closed once \f(CW\*(C`gunzip\*(C'\fR has
319completed.
320.Sp
321This parameter defaults to 0.
322.ie n .IP """BinModeOut => 0|1""" 5
323.el .IP "\f(CWBinModeOut => 0|1\fR" 5
324.IX Item "BinModeOut => 0|1"
325When writing to a file or filehandle, set \f(CW\*(C`binmode\*(C'\fR before writing to the
326file.
327.Sp
328Defaults to 0.
329.ie n .IP """Append => 0|1""" 5
330.el .IP "\f(CWAppend => 0|1\fR" 5
331.IX Item "Append => 0|1"
332The behaviour of this option is dependent on the type of output data
333stream.
334.RS 5
335.IP "* A Buffer" 5
336.IX Item "A Buffer"
337If \f(CW\*(C`Append\*(C'\fR is enabled, all uncompressed data will be append to the end of
338the output buffer. Otherwise the output buffer will be cleared before any
339uncompressed data is written to it.
340.IP "* A Filename" 5
341.IX Item "A Filename"
342If \f(CW\*(C`Append\*(C'\fR is enabled, the file will be opened in append mode. Otherwise
343the contents of the file, if any, will be truncated before any uncompressed
344data is written to it.
345.IP "* A Filehandle" 5
346.IX Item "A Filehandle"
347If \f(CW\*(C`Append\*(C'\fR is enabled, the filehandle will be positioned to the end of
348the file via a call to \f(CW\*(C`seek\*(C'\fR before any uncompressed data is
349written to it. Otherwise the file pointer will not be moved.
350.RE
351.RS 5
352.Sp
353When \f(CW\*(C`Append\*(C'\fR is specified, and set to true, it will \fIappend\fR all uncompressed
354data to the output data stream.
355.Sp
356So when the output is a filehandle it will carry out a seek to the eof
357before writing any uncompressed data. If the output is a filename, it will be opened for
358appending. If the output is a buffer, all uncompressed data will be appened to
359the existing buffer.
360.Sp
361Conversely when \f(CW\*(C`Append\*(C'\fR is not specified, or it is present and is set to
362false, it will operate as follows.
363.Sp
364When the output is a filename, it will truncate the contents of the file
365before writing any uncompressed data. If the output is a filehandle
366its position will not be changed. If the output is a buffer, it will be
367wiped before any uncompressed data is output.
368.Sp
369Defaults to 0.
370.RE
371.ie n .IP """MultiStream => 0|1""" 5
372.el .IP "\f(CWMultiStream => 0|1\fR" 5
373.IX Item "MultiStream => 0|1"
374If the input file/buffer contains multiple compressed data streams, this
375option will uncompress the whole lot as a single data stream.
376.Sp
377Defaults to 0.
378.ie n .IP """TrailingData => $scalar""" 5
379.el .IP "\f(CWTrailingData => $scalar\fR" 5
380.IX Item "TrailingData => $scalar"
381Returns the data, if any, that is present immediately after the compressed
382data stream once uncompression is complete.
383.Sp
384This option can be used when there is useful information immediately
385following the compressed data stream, and you don't know the length of the
386compressed data stream.
387.Sp
388If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the
389end of the compressed data stream to the end of the buffer.
390.Sp
391If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is
392left in the filehandle input buffer once the end of the compressed data
393stream has been reached. You can then use the filehandle to read the rest
394of the input file.
395.Sp
396Don't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename.
397.Sp
398If you know the length of the compressed data stream before you start
399uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the
400\&\f(CW\*(C`InputLength\*(C'\fR option.
401.Sh "Examples"
402.IX Subsection "Examples"
403To read the contents of the file \f(CW\*(C`file1.txt.gz\*(C'\fR and write the
404uncompressed data to the file \f(CW\*(C`file1.txt\*(C'\fR.
405.PP
406.Vb 3
407\& use strict ;
408\& use warnings ;
409\& use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
410.Ve
411.PP
412.Vb 4
413\& my $input = "file1.txt.gz";
414\& my $output = "file1.txt";
415\& gunzip $input => $output
416\& or die "gunzip failed: $GunzipError\en";
417.Ve
418.PP
419To read from an existing Perl filehandle, \f(CW$input\fR, and write the
420uncompressed data to a buffer, \f(CW$buffer\fR.
421.PP
422.Vb 4
423\& use strict ;
424\& use warnings ;
425\& use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
426\& use IO::File ;
427.Ve
428.PP
429.Vb 5
430\& my $input = new IO::File "<file1.txt.gz"
431\& or die "Cannot open 'file1.txt.gz': $!\en" ;
432\& my $buffer ;
433\& gunzip $input => \e$buffer
434\& or die "gunzip failed: $GunzipError\en";
435.Ve
436.PP
437To uncompress all files in the directory \*(L"/my/home\*(R" that match \*(L"*.txt.gz\*(R" and store the compressed data in the same directory
438.PP
439.Vb 3
440\& use strict ;
441\& use warnings ;
442\& use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
443.Ve
444.PP
445.Vb 2
446\& gunzip '</my/home/*.txt.gz>' => '</my/home/#1.txt>'
447\& or die "gunzip failed: $GunzipError\en";
448.Ve
449.PP
450and if you want to compress each file one at a time, this will do the trick
451.PP
452.Vb 3
453\& use strict ;
454\& use warnings ;
455\& use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
456.Ve
457.PP
458.Vb 7
459\& for my $input ( glob "/my/home/*.txt.gz" )
460\& {
461\& my $output = $input;
462\& $output =~ s/.gz// ;
463\& gunzip $input => $output
464\& or die "Error compressing '$input': $GunzipError\en";
465\& }
466.Ve
467.SH "OO Interface"
468.IX Header "OO Interface"
469.Sh "Constructor"
470.IX Subsection "Constructor"
471The format of the constructor for IO::Uncompress::Gunzip is shown below
472.PP
473.Vb 2
474\& my $z = new IO::Uncompress::Gunzip $input [OPTS]
475\& or die "IO::Uncompress::Gunzip failed: $GunzipError\en";
476.Ve
477.PP
478Returns an \f(CW\*(C`IO::Uncompress::Gunzip\*(C'\fR object on success and undef on failure.
479The variable \f(CW$GunzipError\fR will contain an error message on failure.
480.PP
481If you are running Perl 5.005 or better the object, \f(CW$z\fR, returned from
482IO::Uncompress::Gunzip can be used exactly like an IO::File filehandle.
483This means that all normal input file operations can be carried out with
484\&\f(CW$z\fR. For example, to read a line from a compressed file/buffer you can
485use either of these forms
486.PP
487.Vb 2
488\& $line = $z\->getline();
489\& $line = <$z>;
490.Ve
491.PP
492The mandatory parameter \f(CW$input\fR is used to determine the source of the
493compressed data. This parameter can take one of three forms.
494.IP "A filename" 5
495.IX Item "A filename"
496If the \f(CW$input\fR parameter is a scalar, it is assumed to be a filename. This
497file will be opened for reading and the compressed data will be read from it.
498.IP "A filehandle" 5
499.IX Item "A filehandle"
500If the \f(CW$input\fR parameter is a filehandle, the compressed data will be
501read from it.
502The string '\-' can be used as an alias for standard input.
503.IP "A scalar reference" 5
504.IX Item "A scalar reference"
505If \f(CW$input\fR is a scalar reference, the compressed data will be read from
506\&\f(CW$$output\fR.
507.Sh "Constructor Options"
508.IX Subsection "Constructor Options"
509The option names defined below are case insensitive and can be optionally
510prefixed by a '\-'. So all of the following are valid
511.PP
512.Vb 4
513\& \-AutoClose
514\& \-autoclose
515\& AUTOCLOSE
516\& autoclose
517.Ve
518.PP
519\&\s-1OPTS\s0 is a combination of the following options:
520.ie n .IP """AutoClose => 0|1""" 5
521.el .IP "\f(CWAutoClose => 0|1\fR" 5
522.IX Item "AutoClose => 0|1"
523This option is only valid when the \f(CW$input\fR parameter is a filehandle. If
524specified, and the value is true, it will result in the file being closed once
525either the \f(CW\*(C`close\*(C'\fR method is called or the IO::Uncompress::Gunzip object is
526destroyed.
527.Sp
528This parameter defaults to 0.
529.ie n .IP """MultiStream => 0|1""" 5
530.el .IP "\f(CWMultiStream => 0|1\fR" 5
531.IX Item "MultiStream => 0|1"
532Allows multiple concatenated compressed streams to be treated as a single
533compressed stream. Decompression will stop once either the end of the
534file/buffer is reached, an error is encountered (premature eof, corrupt
535compressed data) or the end of a stream is not immediately followed by the
536start of another stream.
537.Sp
538This parameter defaults to 0.
539.ie n .IP """Prime => $string""" 5
540.el .IP "\f(CWPrime => $string\fR" 5
541.IX Item "Prime => $string"
542This option will uncompress the contents of \f(CW$string\fR before processing the
543input file/buffer.
544.Sp
545This option can be useful when the compressed data is embedded in another
546file/data structure and it is not possible to work out where the compressed
547data begins without having to read the first few bytes. If this is the
548case, the uncompression can be \fIprimed\fR with these bytes using this
549option.
550.ie n .IP """Transparent => 0|1""" 5
551.el .IP "\f(CWTransparent => 0|1\fR" 5
552.IX Item "Transparent => 0|1"
553If this option is set and the input file/buffer is not compressed data,
554the module will allow reading of it anyway.
555.Sp
556In addition, if the input file/buffer does contain compressed data and
557there is non-compressed data immediately following it, setting this option
558will make this module treat the whole file/bufffer as a single data stream.
559.Sp
560This option defaults to 1.
561.ie n .IP """BlockSize => $num""" 5
562.el .IP "\f(CWBlockSize => $num\fR" 5
563.IX Item "BlockSize => $num"
564When reading the compressed input data, IO::Uncompress::Gunzip will read it in
565blocks of \f(CW$num\fR bytes.
566.Sp
567This option defaults to 4096.
568.ie n .IP """InputLength => $size""" 5
569.el .IP "\f(CWInputLength => $size\fR" 5
570.IX Item "InputLength => $size"
571When present this option will limit the number of compressed bytes read
572from the input file/buffer to \f(CW$size\fR. This option can be used in the
573situation where there is useful data directly after the compressed data
574stream and you know beforehand the exact length of the compressed data
575stream.
576.Sp
577This option is mostly used when reading from a filehandle, in which case
578the file pointer will be left pointing to the first byte directly after the
579compressed data stream.
580.Sp
581This option defaults to off.
582.ie n .IP """Append => 0|1""" 5
583.el .IP "\f(CWAppend => 0|1\fR" 5
584.IX Item "Append => 0|1"
585This option controls what the \f(CW\*(C`read\*(C'\fR method does with uncompressed data.
586.Sp
587If set to 1, all uncompressed data will be appended to the output parameter
588of the \f(CW\*(C`read\*(C'\fR method.
589.Sp
590If set to 0, the contents of the output parameter of the \f(CW\*(C`read\*(C'\fR method
591will be overwritten by the uncompressed data.
592.Sp
593Defaults to 0.
594.ie n .IP """Strict => 0|1""" 5
595.el .IP "\f(CWStrict => 0|1\fR" 5
596.IX Item "Strict => 0|1"
597This option controls whether the extra checks defined below are used when
598carrying out the decompression. When Strict is on, the extra tests are
599carried out, when Strict is off they are not.
600.Sp
601The default for this option is off.
602.RS 5
603.IP "1" 5
604.IX Item "1"
605If the \s-1FHCRC\s0 bit is set in the gzip \s-1FLG\s0 header byte, the \s-1CRC16\s0 bytes in the
606header must match the crc16 value of the gzip header actually read.
607.IP "2" 5
608.IX Item "2"
609If the gzip header contains a name field (\s-1FNAME\s0) it consists solely of \s-1ISO\s0
6108859\-1 characters.
611.IP "3" 5
612.IX Item "3"
613If the gzip header contains a comment field (\s-1FCOMMENT\s0) it consists solely
614of \s-1ISO\s0 8859\-1 characters plus line\-feed.
615.IP "4" 5
616.IX Item "4"
617If the gzip \s-1FEXTRA\s0 header field is present it must conform to the sub-field
618structure as defined in \s-1RFC\s0 1952.
619.IP "5" 5
620.IX Item "5"
621The \s-1CRC32\s0 and \s-1ISIZE\s0 trailer fields must be present.
622.IP "6" 5
623.IX Item "6"
624The value of the \s-1CRC32\s0 field read must match the crc32 value of the
625uncompressed data actually contained in the gzip file.
626.IP "7" 5
627.IX Item "7"
628The value of the \s-1ISIZE\s0 fields read must match the length of the
629uncompressed data actually read from the file.
630.RE
631.RS 5
632.RE
633.ie n .IP """ParseExtra => 0|1"" If the gzip \s-1FEXTRA\s0 header field is present and this option is set, it will force the module to check that it conforms to the sub-field structure as defined in \s-1RFC\s0 1952." 5
634.el .IP "\f(CWParseExtra => 0|1\fR If the gzip \s-1FEXTRA\s0 header field is present and this option is set, it will force the module to check that it conforms to the sub-field structure as defined in \s-1RFC\s0 1952." 5
635.IX Item "ParseExtra => 0|1 If the gzip FEXTRA header field is present and this option is set, it will force the module to check that it conforms to the sub-field structure as defined in RFC 1952."
636If the \f(CW\*(C`Strict\*(C'\fR is on it will automatically enable this option.
637.Sp
638Defaults to 0.
639.Sh "Examples"
640.IX Subsection "Examples"
641\&\s-1TODO\s0
642.SH "Methods"
643.IX Header "Methods"
644.Sh "read"
645.IX Subsection "read"
646Usage is
647.PP
648.Vb 1
649\& $status = $z\->read($buffer)
650.Ve
651.PP
652Reads a block of compressed data (the size the the compressed block is
653determined by the \f(CW\*(C`Buffer\*(C'\fR option in the constructor), uncompresses it and
654writes any uncompressed data into \f(CW$buffer\fR. If the \f(CW\*(C`Append\*(C'\fR parameter is
655set in the constructor, the uncompressed data will be appended to the
656\&\f(CW$buffer\fR parameter. Otherwise \f(CW$buffer\fR will be overwritten.
657.PP
658Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
659or a negative number on error.
660.Sh "read"
661.IX Subsection "read"
662Usage is
663.PP
664.Vb 2
665\& $status = $z\->read($buffer, $length)
666\& $status = $z\->read($buffer, $length, $offset)
667.Ve
668.PP
669.Vb 2
670\& $status = read($z, $buffer, $length)
671\& $status = read($z, $buffer, $length, $offset)
672.Ve
673.PP
674Attempt to read \f(CW$length\fR bytes of uncompressed data into \f(CW$buffer\fR.
675.PP
676The main difference between this form of the \f(CW\*(C`read\*(C'\fR method and the
677previous one, is that this one will attempt to return \fIexactly\fR \f(CW$length\fR
678bytes. The only circumstances that this function will not is if end-of-file
679or an \s-1IO\s0 error is encountered.
680.PP
681Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
682or a negative number on error.
683.Sh "getline"
684.IX Subsection "getline"
685Usage is
686.PP
687.Vb 2
688\& $line = $z\->getline()
689\& $line = <$z>
690.Ve
691.PP
692Reads a single line.
693.PP
694This method fully supports the use of of the variable \f(CW$/\fR (or
695\&\f(CW$INPUT_RECORD_SEPARATOR\fR or \f(CW$RS\fR when \f(CW\*(C`English\*(C'\fR is in use) to
696determine what constitutes an end of line. Paragraph mode, record mode and
697file slurp mode are all supported.
698.Sh "getc"
699.IX Subsection "getc"
700Usage is
701.PP
702.Vb 1
703\& $char = $z\->getc()
704.Ve
705.PP
706Read a single character.
707.Sh "ungetc"
708.IX Subsection "ungetc"
709Usage is
710.PP
711.Vb 1
712\& $char = $z\->ungetc($string)
713.Ve
714.Sh "inflateSync"
715.IX Subsection "inflateSync"
716Usage is
717.PP
718.Vb 1
719\& $status = $z\->inflateSync()
720.Ve
721.PP
722\&\s-1TODO\s0
723.Sh "getHeaderInfo"
724.IX Subsection "getHeaderInfo"
725Usage is
726.PP
727.Vb 2
728\& $hdr = $z\->getHeaderInfo();
729\& @hdrs = $z\->getHeaderInfo();
730.Ve
731.PP
732This method returns either a hash reference (in scalar context) or a list
733or hash references (in array context) that contains information about each
734of the header fields in the compressed data stream(s).
735.IP "Name" 5
736.IX Item "Name"
737The contents of the Name header field, if present. If no name is
738present, the value will be undef. Note this is different from a zero length
739name, which will return an empty string.
740.IP "Comment" 5
741.IX Item "Comment"
742The contents of the Comment header field, if present. If no comment is
743present, the value will be undef. Note this is different from a zero length
744comment, which will return an empty string.
745.Sh "tell"
746.IX Subsection "tell"
747Usage is
748.PP
749.Vb 2
750\& $z\->tell()
751\& tell $z
752.Ve
753.PP
754Returns the uncompressed file offset.
755.Sh "eof"
756.IX Subsection "eof"
757Usage is
758.PP
759.Vb 2
760\& $z\->eof();
761\& eof($z);
762.Ve
763.PP
764Returns true if the end of the compressed input stream has been reached.
765.Sh "seek"
766.IX Subsection "seek"
767.Vb 2
768\& $z\->seek($position, $whence);
769\& seek($z, $position, $whence);
770.Ve
771.PP
772Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction
773that it is only legal to seek forward in the input file/buffer.
774It is a fatal error to attempt to seek backward.
775.PP
776The \f(CW$whence\fR parameter takes one the usual values, namely \s-1SEEK_SET\s0,
777\&\s-1SEEK_CUR\s0 or \s-1SEEK_END\s0.
778.PP
779Returns 1 on success, 0 on failure.
780.Sh "binmode"
781.IX Subsection "binmode"
782Usage is
783.PP
784.Vb 2
785\& $z\->binmode
786\& binmode $z ;
787.Ve
788.PP
789This is a noop provided for completeness.
790.Sh "opened"
791.IX Subsection "opened"
792.Vb 1
793\& $z\->opened()
794.Ve
795.PP
796Returns true if the object currently refers to a opened file/buffer.
797.Sh "autoflush"
798.IX Subsection "autoflush"
799.Vb 2
800\& my $prev = $z\->autoflush()
801\& my $prev = $z\->autoflush(EXPR)
802.Ve
803.PP
804If the \f(CW$z\fR object is associated with a file or a filehandle, this method
805returns the current autoflush setting for the underlying filehandle. If
806\&\f(CW\*(C`EXPR\*(C'\fR is present, and is non\-zero, it will enable flushing after every
807write/print operation.
808.PP
809If \f(CW$z\fR is associated with a buffer, this method has no effect and always
810returns \f(CW\*(C`undef\*(C'\fR.
811.PP
812\&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or
813retrieve the autoflush setting.
814.Sh "input_line_number"
815.IX Subsection "input_line_number"
816.Vb 2
817\& $z\->input_line_number()
818\& $z\->input_line_number(EXPR)
819.Ve
820.PP
821Returns the current uncompressed line number. If \f(CW\*(C`EXPR\*(C'\fR is present it has
822the effect of setting the line number. Note that setting the line number
823does not change the current position within the file/buffer being read.
824.PP
825The contents of \f(CW$/\fR are used to to determine what constitutes a line
826terminator.
827.Sh "fileno"
828.IX Subsection "fileno"
829.Vb 2
830\& $z\->fileno()
831\& fileno($z)
832.Ve
833.PP
834If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR
835will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is
836called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR.
837.PP
838If the \f(CW$z\fR object is is associated with a buffer, this method will return
839\&\f(CW\*(C`undef\*(C'\fR.
840.Sh "close"
841.IX Subsection "close"
842.Vb 2
843\& $z\->close() ;
844\& close $z ;
845.Ve
846.PP
847Closes the output file/buffer.
848.PP
849For most versions of Perl this method will be automatically invoked if
850the IO::Uncompress::Gunzip object is destroyed (either explicitly or by the
851variable with the reference to the object going out of scope). The
852exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
853these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but
854not until global destruction of all live objects when the program is
855terminating.
856.PP
857Therefore, if you want your scripts to be able to run on all versions
858of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic
859closing.
860.PP
861Returns true on success, otherwise 0.
862.PP
863If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Uncompress::Gunzip
864object was created, and the object is associated with a file, the
865underlying file will also be closed.
866.Sh "nextStream"
867.IX Subsection "nextStream"
868Usage is
869.PP
870.Vb 1
871\& my $status = $z\->nextStream();
872.Ve
873.PP
874Skips to the next compressed data stream in the input file/buffer. If a new
875compressed data stream is found, the eof marker will be cleared and \f(CW$.\fR
876will be reset to 0.
877.PP
878Returns 1 if a new stream was found, 0 if none was found, and \-1 if an
879error was encountered.
880.Sh "trailingData"
881.IX Subsection "trailingData"
882Usage is
883.PP
884.Vb 1
885\& my $data = $z\->trailingData();
886.Ve
887.PP
888Returns the data, if any, that is present immediately after the compressed
889data stream once uncompression is complete. It only makes sense to call
890this method once the end of the compressed data stream has been
891encountered.
892.PP
893This option can be used when there is useful information immediately
894following the compressed data stream, and you don't know the length of the
895compressed data stream.
896.PP
897If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the
898end of the compressed data stream to the end of the buffer.
899.PP
900If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is
901left in the filehandle input buffer once the end of the compressed data
902stream has been reached. You can then use the filehandle to read the rest
903of the input file.
904.PP
905Don't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename.
906.PP
907If you know the length of the compressed data stream before you start
908uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the
909\&\f(CW\*(C`InputLength\*(C'\fR option in the constructor.
910.SH "Importing"
911.IX Header "Importing"
912No symbolic constants are required by this IO::Uncompress::Gunzip at present.
913.IP ":all" 5
914.IX Item ":all"
915Imports \f(CW\*(C`gunzip\*(C'\fR and \f(CW$GunzipError\fR.
916Same as doing this
917.Sp
918.Vb 1
919\& use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
920.Ve
921.SH "EXAMPLES"
922.IX Header "EXAMPLES"
923.Sh "Working with Net::FTP"
924.IX Subsection "Working with Net::FTP"
925See IO::Uncompress::Gunzip::FAQ
926.SH "SEE ALSO"
927.IX Header "SEE ALSO"
928Compress::Zlib, IO::Compress::Gzip, IO::Compress::Deflate, IO::Uncompress::Inflate, IO::Compress::RawDeflate, IO::Uncompress::RawInflate, IO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzma, IO::Uncompress::UnLzma, IO::Compress::Xz, IO::Uncompress::UnXz, IO::Compress::Lzop, IO::Uncompress::UnLzop, IO::Compress::Lzf, IO::Uncompress::UnLzf, IO::Uncompress::AnyInflate, IO::Uncompress::AnyUncompress
929.PP
930Compress::Zlib::FAQ
931.PP
932File::GlobMapper, Archive::Zip,
933Archive::Tar,
934IO::Zlib
935.PP
936For \s-1RFC\s0 1950, 1951 and 1952 see
937\&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR,
938\&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and
939\&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR
940.PP
941The \fIzlib\fR compression library was written by Jean-loup Gailly
942\&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR.
943.PP
944The primary site for the \fIzlib\fR compression library is
945\&\fIhttp://www.zlib.org\fR.
946.PP
947The primary site for gzip is \fIhttp://www.gzip.org\fR.
948.SH "AUTHOR"
949.IX Header "AUTHOR"
950This module was written by Paul Marquess, \fIpmqs@cpan.org\fR.
951.SH "MODIFICATION HISTORY"
952.IX Header "MODIFICATION HISTORY"
953See the Changes file.
954.SH "COPYRIGHT AND LICENSE"
955.IX Header "COPYRIGHT AND LICENSE"
956Copyright (c) 2005\-2009 Paul Marquess. All rights reserved.
957.PP
958This program is free software; you can redistribute it and/or
959modify it under the same terms as Perl itself.