Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / IO::Uncompress::Unzip.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::Unzip 3"
132.TH IO::Uncompress::Unzip 3 "2009-11-09" "perl v5.8.7" "User Contributed Perl Documentation"
133.SH "NAME"
134IO::Uncompress::Unzip \- Read zip files/buffers
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
139.Ve
140.PP
141.Vb 2
142\& my $status = unzip $input => $output [,OPTS]
143\& or die "unzip failed: $UnzipError\en";
144.Ve
145.PP
146.Vb 2
147\& my $z = new IO::Uncompress::Unzip $input [OPTS]
148\& or die "unzip failed: $UnzipError\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\& $UnzipError ;
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
200zlib files/buffers.
201.PP
202For writing zip files/buffers, see the companion module IO::Compress::Zip.
203.SH "Functional Interface"
204.IX Header "Functional Interface"
205A top-level function, \f(CW\*(C`unzip\*(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::Unzip qw(unzip $UnzipError) ;
212.Ve
213.PP
214.Vb 2
215\& unzip $input => $output [,OPTS]
216\& or die "unzip failed: $UnzipError\en";
217.Ve
218.PP
219The functional interface needs Perl5.005 or better.
220.ie n .Sh "unzip $input\fP => \f(CW$output [, \s-1OPTS\s0]"
221.el .Sh "unzip \f(CW$input\fP => \f(CW$output\fP [, \s-1OPTS\s0]"
222.IX Subsection "unzip $input => $output [, OPTS]"
223\&\f(CW\*(C`unzip\*(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`unzip\*(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`unzip\*(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`unzip\*(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`unzip\*(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`unzip\*(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.zip\*(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::Unzip qw(unzip $UnzipError) ;
410.Ve
411.PP
412.Vb 4
413\& my $input = "file1.txt.zip";
414\& my $output = "file1.txt";
415\& unzip $input => $output
416\& or die "unzip failed: $UnzipError\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::Unzip qw(unzip $UnzipError) ;
426\& use IO::File ;
427.Ve
428.PP
429.Vb 5
430\& my $input = new IO::File "<file1.txt.zip"
431\& or die "Cannot open 'file1.txt.zip': $!\en" ;
432\& my $buffer ;
433\& unzip $input => \e$buffer
434\& or die "unzip failed: $UnzipError\en";
435.Ve
436.PP
437To uncompress all files in the directory \*(L"/my/home\*(R" that match \*(L"*.txt.zip\*(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::Unzip qw(unzip $UnzipError) ;
443.Ve
444.PP
445.Vb 2
446\& unzip '</my/home/*.txt.zip>' => '</my/home/#1.txt>'
447\& or die "unzip failed: $UnzipError\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::Unzip qw(unzip $UnzipError) ;
456.Ve
457.PP
458.Vb 7
459\& for my $input ( glob "/my/home/*.txt.zip" )
460\& {
461\& my $output = $input;
462\& $output =~ s/.zip// ;
463\& unzip $input => $output
464\& or die "Error compressing '$input': $UnzipError\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::Unzip is shown below
472.PP
473.Vb 2
474\& my $z = new IO::Uncompress::Unzip $input [OPTS]
475\& or die "IO::Uncompress::Unzip failed: $UnzipError\en";
476.Ve
477.PP
478Returns an \f(CW\*(C`IO::Uncompress::Unzip\*(C'\fR object on success and undef on failure.
479The variable \f(CW$UnzipError\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::Unzip 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::Unzip 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"
532Treats the complete zip file/buffer as a single compressed data
533stream. When reading in multi-stream mode each member of the zip
534file/buffer will be uncompressed in turn until the end of the file/buffer
535is encountered.
536.Sp
537This parameter defaults to 0.
538.ie n .IP """Prime => $string""" 5
539.el .IP "\f(CWPrime => $string\fR" 5
540.IX Item "Prime => $string"
541This option will uncompress the contents of \f(CW$string\fR before processing the
542input file/buffer.
543.Sp
544This option can be useful when the compressed data is embedded in another
545file/data structure and it is not possible to work out where the compressed
546data begins without having to read the first few bytes. If this is the
547case, the uncompression can be \fIprimed\fR with these bytes using this
548option.
549.ie n .IP """Transparent => 0|1""" 5
550.el .IP "\f(CWTransparent => 0|1\fR" 5
551.IX Item "Transparent => 0|1"
552If this option is set and the input file/buffer is not compressed data,
553the module will allow reading of it anyway.
554.Sp
555In addition, if the input file/buffer does contain compressed data and
556there is non-compressed data immediately following it, setting this option
557will make this module treat the whole file/bufffer as a single data stream.
558.Sp
559This option defaults to 1.
560.ie n .IP """BlockSize => $num""" 5
561.el .IP "\f(CWBlockSize => $num\fR" 5
562.IX Item "BlockSize => $num"
563When reading the compressed input data, IO::Uncompress::Unzip will read it in
564blocks of \f(CW$num\fR bytes.
565.Sp
566This option defaults to 4096.
567.ie n .IP """InputLength => $size""" 5
568.el .IP "\f(CWInputLength => $size\fR" 5
569.IX Item "InputLength => $size"
570When present this option will limit the number of compressed bytes read
571from the input file/buffer to \f(CW$size\fR. This option can be used in the
572situation where there is useful data directly after the compressed data
573stream and you know beforehand the exact length of the compressed data
574stream.
575.Sp
576This option is mostly used when reading from a filehandle, in which case
577the file pointer will be left pointing to the first byte directly after the
578compressed data stream.
579.Sp
580This option defaults to off.
581.ie n .IP """Append => 0|1""" 5
582.el .IP "\f(CWAppend => 0|1\fR" 5
583.IX Item "Append => 0|1"
584This option controls what the \f(CW\*(C`read\*(C'\fR method does with uncompressed data.
585.Sp
586If set to 1, all uncompressed data will be appended to the output parameter
587of the \f(CW\*(C`read\*(C'\fR method.
588.Sp
589If set to 0, the contents of the output parameter of the \f(CW\*(C`read\*(C'\fR method
590will be overwritten by the uncompressed data.
591.Sp
592Defaults to 0.
593.ie n .IP """Strict => 0|1""" 5
594.el .IP "\f(CWStrict => 0|1\fR" 5
595.IX Item "Strict => 0|1"
596This option controls whether the extra checks defined below are used when
597carrying out the decompression. When Strict is on, the extra tests are
598carried out, when Strict is off they are not.
599.Sp
600The default for this option is off.
601.Sh "Examples"
602.IX Subsection "Examples"
603\&\s-1TODO\s0
604.SH "Methods"
605.IX Header "Methods"
606.Sh "read"
607.IX Subsection "read"
608Usage is
609.PP
610.Vb 1
611\& $status = $z\->read($buffer)
612.Ve
613.PP
614Reads a block of compressed data (the size the the compressed block is
615determined by the \f(CW\*(C`Buffer\*(C'\fR option in the constructor), uncompresses it and
616writes any uncompressed data into \f(CW$buffer\fR. If the \f(CW\*(C`Append\*(C'\fR parameter is
617set in the constructor, the uncompressed data will be appended to the
618\&\f(CW$buffer\fR parameter. Otherwise \f(CW$buffer\fR will be overwritten.
619.PP
620Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
621or a negative number on error.
622.Sh "read"
623.IX Subsection "read"
624Usage is
625.PP
626.Vb 2
627\& $status = $z\->read($buffer, $length)
628\& $status = $z\->read($buffer, $length, $offset)
629.Ve
630.PP
631.Vb 2
632\& $status = read($z, $buffer, $length)
633\& $status = read($z, $buffer, $length, $offset)
634.Ve
635.PP
636Attempt to read \f(CW$length\fR bytes of uncompressed data into \f(CW$buffer\fR.
637.PP
638The main difference between this form of the \f(CW\*(C`read\*(C'\fR method and the
639previous one, is that this one will attempt to return \fIexactly\fR \f(CW$length\fR
640bytes. The only circumstances that this function will not is if end-of-file
641or an \s-1IO\s0 error is encountered.
642.PP
643Returns the number of uncompressed bytes written to \f(CW$buffer\fR, zero if eof
644or a negative number on error.
645.Sh "getline"
646.IX Subsection "getline"
647Usage is
648.PP
649.Vb 2
650\& $line = $z\->getline()
651\& $line = <$z>
652.Ve
653.PP
654Reads a single line.
655.PP
656This method fully supports the use of of the variable \f(CW$/\fR (or
657\&\f(CW$INPUT_RECORD_SEPARATOR\fR or \f(CW$RS\fR when \f(CW\*(C`English\*(C'\fR is in use) to
658determine what constitutes an end of line. Paragraph mode, record mode and
659file slurp mode are all supported.
660.Sh "getc"
661.IX Subsection "getc"
662Usage is
663.PP
664.Vb 1
665\& $char = $z\->getc()
666.Ve
667.PP
668Read a single character.
669.Sh "ungetc"
670.IX Subsection "ungetc"
671Usage is
672.PP
673.Vb 1
674\& $char = $z\->ungetc($string)
675.Ve
676.Sh "inflateSync"
677.IX Subsection "inflateSync"
678Usage is
679.PP
680.Vb 1
681\& $status = $z\->inflateSync()
682.Ve
683.PP
684\&\s-1TODO\s0
685.Sh "getHeaderInfo"
686.IX Subsection "getHeaderInfo"
687Usage is
688.PP
689.Vb 2
690\& $hdr = $z\->getHeaderInfo();
691\& @hdrs = $z\->getHeaderInfo();
692.Ve
693.PP
694This method returns either a hash reference (in scalar context) or a list
695or hash references (in array context) that contains information about each
696of the header fields in the compressed data stream(s).
697.Sh "tell"
698.IX Subsection "tell"
699Usage is
700.PP
701.Vb 2
702\& $z\->tell()
703\& tell $z
704.Ve
705.PP
706Returns the uncompressed file offset.
707.Sh "eof"
708.IX Subsection "eof"
709Usage is
710.PP
711.Vb 2
712\& $z\->eof();
713\& eof($z);
714.Ve
715.PP
716Returns true if the end of the compressed input stream has been reached.
717.Sh "seek"
718.IX Subsection "seek"
719.Vb 2
720\& $z\->seek($position, $whence);
721\& seek($z, $position, $whence);
722.Ve
723.PP
724Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction
725that it is only legal to seek forward in the input file/buffer.
726It is a fatal error to attempt to seek backward.
727.PP
728The \f(CW$whence\fR parameter takes one the usual values, namely \s-1SEEK_SET\s0,
729\&\s-1SEEK_CUR\s0 or \s-1SEEK_END\s0.
730.PP
731Returns 1 on success, 0 on failure.
732.Sh "binmode"
733.IX Subsection "binmode"
734Usage is
735.PP
736.Vb 2
737\& $z\->binmode
738\& binmode $z ;
739.Ve
740.PP
741This is a noop provided for completeness.
742.Sh "opened"
743.IX Subsection "opened"
744.Vb 1
745\& $z\->opened()
746.Ve
747.PP
748Returns true if the object currently refers to a opened file/buffer.
749.Sh "autoflush"
750.IX Subsection "autoflush"
751.Vb 2
752\& my $prev = $z\->autoflush()
753\& my $prev = $z\->autoflush(EXPR)
754.Ve
755.PP
756If the \f(CW$z\fR object is associated with a file or a filehandle, this method
757returns the current autoflush setting for the underlying filehandle. If
758\&\f(CW\*(C`EXPR\*(C'\fR is present, and is non\-zero, it will enable flushing after every
759write/print operation.
760.PP
761If \f(CW$z\fR is associated with a buffer, this method has no effect and always
762returns \f(CW\*(C`undef\*(C'\fR.
763.PP
764\&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or
765retrieve the autoflush setting.
766.Sh "input_line_number"
767.IX Subsection "input_line_number"
768.Vb 2
769\& $z\->input_line_number()
770\& $z\->input_line_number(EXPR)
771.Ve
772.PP
773Returns the current uncompressed line number. If \f(CW\*(C`EXPR\*(C'\fR is present it has
774the effect of setting the line number. Note that setting the line number
775does not change the current position within the file/buffer being read.
776.PP
777The contents of \f(CW$/\fR are used to to determine what constitutes a line
778terminator.
779.Sh "fileno"
780.IX Subsection "fileno"
781.Vb 2
782\& $z\->fileno()
783\& fileno($z)
784.Ve
785.PP
786If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR
787will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is
788called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR.
789.PP
790If the \f(CW$z\fR object is is associated with a buffer, this method will return
791\&\f(CW\*(C`undef\*(C'\fR.
792.Sh "close"
793.IX Subsection "close"
794.Vb 2
795\& $z\->close() ;
796\& close $z ;
797.Ve
798.PP
799Closes the output file/buffer.
800.PP
801For most versions of Perl this method will be automatically invoked if
802the IO::Uncompress::Unzip object is destroyed (either explicitly or by the
803variable with the reference to the object going out of scope). The
804exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
805these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but
806not until global destruction of all live objects when the program is
807terminating.
808.PP
809Therefore, if you want your scripts to be able to run on all versions
810of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic
811closing.
812.PP
813Returns true on success, otherwise 0.
814.PP
815If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Uncompress::Unzip
816object was created, and the object is associated with a file, the
817underlying file will also be closed.
818.Sh "nextStream"
819.IX Subsection "nextStream"
820Usage is
821.PP
822.Vb 1
823\& my $status = $z\->nextStream();
824.Ve
825.PP
826Skips to the next compressed data stream in the input file/buffer. If a new
827compressed data stream is found, the eof marker will be cleared and \f(CW$.\fR
828will be reset to 0.
829.PP
830Returns 1 if a new stream was found, 0 if none was found, and \-1 if an
831error was encountered.
832.Sh "trailingData"
833.IX Subsection "trailingData"
834Usage is
835.PP
836.Vb 1
837\& my $data = $z\->trailingData();
838.Ve
839.PP
840Returns the data, if any, that is present immediately after the compressed
841data stream once uncompression is complete. It only makes sense to call
842this method once the end of the compressed data stream has been
843encountered.
844.PP
845This option can be used when there is useful information immediately
846following the compressed data stream, and you don't know the length of the
847compressed data stream.
848.PP
849If the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from the
850end of the compressed data stream to the end of the buffer.
851.PP
852If the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that is
853left in the filehandle input buffer once the end of the compressed data
854stream has been reached. You can then use the filehandle to read the rest
855of the input file.
856.PP
857Don't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename.
858.PP
859If you know the length of the compressed data stream before you start
860uncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the
861\&\f(CW\*(C`InputLength\*(C'\fR option in the constructor.
862.SH "Importing"
863.IX Header "Importing"
864No symbolic constants are required by this IO::Uncompress::Unzip at present.
865.IP ":all" 5
866.IX Item ":all"
867Imports \f(CW\*(C`unzip\*(C'\fR and \f(CW$UnzipError\fR.
868Same as doing this
869.Sp
870.Vb 1
871\& use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
872.Ve
873.SH "EXAMPLES"
874.IX Header "EXAMPLES"
875.Sh "Working with Net::FTP"
876.IX Subsection "Working with Net::FTP"
877See IO::Uncompress::Unzip::FAQ
878.SH "SEE ALSO"
879.IX Header "SEE ALSO"
880Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, 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
881.PP
882Compress::Zlib::FAQ
883.PP
884File::GlobMapper, Archive::Zip,
885Archive::Tar,
886IO::Zlib
887.PP
888For \s-1RFC\s0 1950, 1951 and 1952 see
889\&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR,
890\&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and
891\&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR
892.PP
893The \fIzlib\fR compression library was written by Jean-loup Gailly
894\&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR.
895.PP
896The primary site for the \fIzlib\fR compression library is
897\&\fIhttp://www.zlib.org\fR.
898.PP
899The primary site for gzip is \fIhttp://www.gzip.org\fR.
900.SH "AUTHOR"
901.IX Header "AUTHOR"
902This module was written by Paul Marquess, \fIpmqs@cpan.org\fR.
903.SH "MODIFICATION HISTORY"
904.IX Header "MODIFICATION HISTORY"
905See the Changes file.
906.SH "COPYRIGHT AND LICENSE"
907.IX Header "COPYRIGHT AND LICENSE"
908Copyright (c) 2005\-2009 Paul Marquess. All rights reserved.
909.PP
910This program is free software; you can redistribute it and/or
911modify it under the same terms as Perl itself.