Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / IO::Compress::Gzip.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::Compress::Gzip 3"
132.TH IO::Compress::Gzip 3 "2009-11-09" "perl v5.8.7" "User Contributed Perl Documentation"
133.SH "NAME"
134IO::Compress::Gzip \- Write RFC 1952 files/buffers
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use IO::Compress::Gzip qw(gzip $GzipError) ;
139.Ve
140.PP
141.Vb 2
142\& my $status = gzip $input => $output [,OPTS]
143\& or die "gzip failed: $GzipError\en";
144.Ve
145.PP
146.Vb 2
147\& my $z = new IO::Compress::Gzip $output [,OPTS]
148\& or die "gzip failed: $GzipError\en";
149.Ve
150.PP
151.Vb 14
152\& $z\->print($string);
153\& $z\->printf($format, $string);
154\& $z\->write($string);
155\& $z\->syswrite($string [, $length, $offset]);
156\& $z\->flush();
157\& $z\->tell();
158\& $z\->eof();
159\& $z\->seek($position, $whence);
160\& $z\->binmode();
161\& $z\->fileno();
162\& $z\->opened();
163\& $z\->autoflush();
164\& $z\->input_line_number();
165\& $z\->newStream( [OPTS] );
166.Ve
167.PP
168.Vb 1
169\& $z\->deflateParams();
170.Ve
171.PP
172.Vb 1
173\& $z\->close() ;
174.Ve
175.PP
176.Vb 1
177\& $GzipError ;
178.Ve
179.PP
180.Vb 1
181\& # IO::File mode
182.Ve
183.PP
184.Vb 8
185\& print $z $string;
186\& printf $z $format, $string;
187\& tell $z
188\& eof $z
189\& seek $z, $position, $whence
190\& binmode $z
191\& fileno $z
192\& close $z ;
193.Ve
194.SH "DESCRIPTION"
195.IX Header "DESCRIPTION"
196This module provides a Perl interface that allows writing compressed
197data to files or buffer as defined in \s-1RFC\s0 1952.
198.PP
199All the gzip headers defined in \s-1RFC\s0 1952 can be created using
200this module.
201.PP
202For reading \s-1RFC\s0 1952 files/buffers, see the companion module
203IO::Uncompress::Gunzip.
204.SH "Functional Interface"
205.IX Header "Functional Interface"
206A top-level function, \f(CW\*(C`gzip\*(C'\fR, is provided to carry out
207\&\*(L"one\-shot\*(R" compression between buffers and/or files. For finer
208control over the compression process, see the \*(L"\s-1OO\s0 Interface\*(R"
209section.
210.PP
211.Vb 1
212\& use IO::Compress::Gzip qw(gzip $GzipError) ;
213.Ve
214.PP
215.Vb 2
216\& gzip $input => $output [,OPTS]
217\& or die "gzip failed: $GzipError\en";
218.Ve
219.PP
220The functional interface needs Perl5.005 or better.
221.ie n .Sh "gzip $input\fP => \f(CW$output [, \s-1OPTS\s0]"
222.el .Sh "gzip \f(CW$input\fP => \f(CW$output\fP [, \s-1OPTS\s0]"
223.IX Subsection "gzip $input => $output [, OPTS]"
224\&\f(CW\*(C`gzip\*(C'\fR expects at least two parameters, \f(CW$input\fR and \f(CW$output\fR.
225.PP
226\fIThe \f(CI$input\fI parameter\fR
227.IX Subsection "The $input parameter"
228.PP
229The parameter, \f(CW$input\fR, is used to define the source of
230the uncompressed data.
231.PP
232It can take one of the following forms:
233.IP "A filename" 5
234.IX Item "A filename"
235If the \f(CW$input\fR parameter is a simple scalar, it is assumed to be a
236filename. This file will be opened for reading and the input data
237will be read from it.
238.IP "A filehandle" 5
239.IX Item "A filehandle"
240If the \f(CW$input\fR parameter is a filehandle, the input data will be
241read from it.
242The string '\-' can be used as an alias for standard input.
243.IP "A scalar reference" 5
244.IX Item "A scalar reference"
245If \f(CW$input\fR is a scalar reference, the input data will be read
246from \f(CW$$input\fR.
247.IP "An array reference" 5
248.IX Item "An array reference"
249If \f(CW$input\fR is an array reference, each element in the array must be a
250filename.
251.Sp
252The input data will be read from each file in turn.
253.Sp
254The complete array will be walked to ensure that it only
255contains valid filenames before any data is compressed.
256.IP "An Input FileGlob string" 5
257.IX Item "An Input FileGlob string"
258If \f(CW$input\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
259\&\f(CW\*(C`gzip\*(C'\fR will assume that it is an \fIinput fileglob string\fR. The
260input is the list of files that match the fileglob.
261.Sp
262If the fileglob does not match any files ...
263.Sp
264See File::GlobMapper for more details.
265.PP
266If the \f(CW$input\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
267.PP
268In addition, if \f(CW$input\fR is a simple filename, the default values for
269the \f(CW\*(C`Name\*(C'\fR and \f(CW\*(C`Time\*(C'\fR options will be sourced from that file.
270.PP
271If you do not want to use these defaults they can be overridden by
272explicitly setting the \f(CW\*(C`Name\*(C'\fR and \f(CW\*(C`Time\*(C'\fR options or by setting the
273\&\f(CW\*(C`Minimal\*(C'\fR parameter.
274.PP
275\fIThe \f(CI$output\fI parameter\fR
276.IX Subsection "The $output parameter"
277.PP
278The parameter \f(CW$output\fR is used to control the destination of the
279compressed data. This parameter can take one of these forms.
280.IP "A filename" 5
281.IX Item "A filename"
282If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a
283filename. This file will be opened for writing and the compressed
284data will be written to it.
285.IP "A filehandle" 5
286.IX Item "A filehandle"
287If the \f(CW$output\fR parameter is a filehandle, the compressed data
288will be written to it.
289The string '\-' can be used as an alias for standard output.
290.IP "A scalar reference" 5
291.IX Item "A scalar reference"
292If \f(CW$output\fR is a scalar reference, the compressed data will be
293stored in \f(CW$$output\fR.
294.IP "An Array Reference" 5
295.IX Item "An Array Reference"
296If \f(CW$output\fR is an array reference, the compressed data will be
297pushed onto the array.
298.IP "An Output FileGlob" 5
299.IX Item "An Output FileGlob"
300If \f(CW$output\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
301\&\f(CW\*(C`gzip\*(C'\fR will assume that it is an \fIoutput fileglob string\fR. The
302output is the list of files that match the fileglob.
303.Sp
304When \f(CW$output\fR is an fileglob string, \f(CW$input\fR must also be a fileglob
305string. Anything else is an error.
306.PP
307If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
308.Sh "Notes"
309.IX Subsection "Notes"
310When \f(CW$input\fR maps to multiple files/buffers and \f(CW$output\fR is a single
311file/buffer the input files/buffers will be stored
312in \f(CW$output\fR as a concatenated series of compressed data streams.
313.Sh "Optional Parameters"
314.IX Subsection "Optional Parameters"
315Unless specified below, the optional parameters for \f(CW\*(C`gzip\*(C'\fR,
316\&\f(CW\*(C`OPTS\*(C'\fR, are the same as those used with the \s-1OO\s0 interface defined in the
317\&\*(L"Constructor Options\*(R" section below.
318.ie n .IP """AutoClose => 0|1""" 5
319.el .IP "\f(CWAutoClose => 0|1\fR" 5
320.IX Item "AutoClose => 0|1"
321This option applies to any input or output data streams to
322\&\f(CW\*(C`gzip\*(C'\fR that are filehandles.
323.Sp
324If \f(CW\*(C`AutoClose\*(C'\fR is specified, and the value is true, it will result in all
325input and/or output filehandles being closed once \f(CW\*(C`gzip\*(C'\fR has
326completed.
327.Sp
328This parameter defaults to 0.
329.ie n .IP """BinModeIn => 0|1""" 5
330.el .IP "\f(CWBinModeIn => 0|1\fR" 5
331.IX Item "BinModeIn => 0|1"
332When reading from a file or filehandle, set \f(CW\*(C`binmode\*(C'\fR before reading.
333.Sp
334Defaults to 0.
335.ie n .IP """Append => 0|1""" 5
336.el .IP "\f(CWAppend => 0|1\fR" 5
337.IX Item "Append => 0|1"
338The behaviour of this option is dependent on the type of output data
339stream.
340.RS 5
341.IP "* A Buffer" 5
342.IX Item "A Buffer"
343If \f(CW\*(C`Append\*(C'\fR is enabled, all compressed data will be append to the end of
344the output buffer. Otherwise the output buffer will be cleared before any
345compressed data is written to it.
346.IP "* A Filename" 5
347.IX Item "A Filename"
348If \f(CW\*(C`Append\*(C'\fR is enabled, the file will be opened in append mode. Otherwise
349the contents of the file, if any, will be truncated before any compressed
350data is written to it.
351.IP "* A Filehandle" 5
352.IX Item "A Filehandle"
353If \f(CW\*(C`Append\*(C'\fR is enabled, the filehandle will be positioned to the end of
354the file via a call to \f(CW\*(C`seek\*(C'\fR before any compressed data is
355written to it. Otherwise the file pointer will not be moved.
356.RE
357.RS 5
358.Sp
359When \f(CW\*(C`Append\*(C'\fR is specified, and set to true, it will \fIappend\fR all compressed
360data to the output data stream.
361.Sp
362So when the output is a filehandle it will carry out a seek to the eof
363before writing any compressed data. If the output is a filename, it will be opened for
364appending. If the output is a buffer, all compressed data will be appened to
365the existing buffer.
366.Sp
367Conversely when \f(CW\*(C`Append\*(C'\fR is not specified, or it is present and is set to
368false, it will operate as follows.
369.Sp
370When the output is a filename, it will truncate the contents of the file
371before writing any compressed data. If the output is a filehandle
372its position will not be changed. If the output is a buffer, it will be
373wiped before any compressed data is output.
374.Sp
375Defaults to 0.
376.RE
377.Sh "Examples"
378.IX Subsection "Examples"
379To read the contents of the file \f(CW\*(C`file1.txt\*(C'\fR and write the compressed
380data to the file \f(CW\*(C`file1.txt.gz\*(C'\fR.
381.PP
382.Vb 3
383\& use strict ;
384\& use warnings ;
385\& use IO::Compress::Gzip qw(gzip $GzipError) ;
386.Ve
387.PP
388.Vb 3
389\& my $input = "file1.txt";
390\& gzip $input => "$input.gz"
391\& or die "gzip failed: $GzipError\en";
392.Ve
393.PP
394To read from an existing Perl filehandle, \f(CW$input\fR, and write the
395compressed data to a buffer, \f(CW$buffer\fR.
396.PP
397.Vb 4
398\& use strict ;
399\& use warnings ;
400\& use IO::Compress::Gzip qw(gzip $GzipError) ;
401\& use IO::File ;
402.Ve
403.PP
404.Vb 5
405\& my $input = new IO::File "<file1.txt"
406\& or die "Cannot open 'file1.txt': $!\en" ;
407\& my $buffer ;
408\& gzip $input => \e$buffer
409\& or die "gzip failed: $GzipError\en";
410.Ve
411.PP
412To compress all files in the directory \*(L"/my/home\*(R" that match \*(L"*.txt\*(R"
413and store the compressed data in the same directory
414.PP
415.Vb 3
416\& use strict ;
417\& use warnings ;
418\& use IO::Compress::Gzip qw(gzip $GzipError) ;
419.Ve
420.PP
421.Vb 2
422\& gzip '</my/home/*.txt>' => '<*.gz>'
423\& or die "gzip failed: $GzipError\en";
424.Ve
425.PP
426and if you want to compress each file one at a time, this will do the trick
427.PP
428.Vb 3
429\& use strict ;
430\& use warnings ;
431\& use IO::Compress::Gzip qw(gzip $GzipError) ;
432.Ve
433.PP
434.Vb 6
435\& for my $input ( glob "/my/home/*.txt" )
436\& {
437\& my $output = "$input.gz" ;
438\& gzip $input => $output
439\& or die "Error compressing '$input': $GzipError\en";
440\& }
441.Ve
442.SH "OO Interface"
443.IX Header "OO Interface"
444.Sh "Constructor"
445.IX Subsection "Constructor"
446The format of the constructor for \f(CW\*(C`IO::Compress::Gzip\*(C'\fR is shown below
447.PP
448.Vb 2
449\& my $z = new IO::Compress::Gzip $output [,OPTS]
450\& or die "IO::Compress::Gzip failed: $GzipError\en";
451.Ve
452.PP
453It returns an \f(CW\*(C`IO::Compress::Gzip\*(C'\fR object on success and undef on failure.
454The variable \f(CW$GzipError\fR will contain an error message on failure.
455.PP
456If you are running Perl 5.005 or better the object, \f(CW$z\fR, returned from
457IO::Compress::Gzip can be used exactly like an IO::File filehandle.
458This means that all normal output file operations can be carried out
459with \f(CW$z\fR.
460For example, to write to a compressed file/buffer you can use either of
461these forms
462.PP
463.Vb 2
464\& $z\->print("hello world\en");
465\& print $z "hello world\en";
466.Ve
467.PP
468The mandatory parameter \f(CW$output\fR is used to control the destination
469of the compressed data. This parameter can take one of these forms.
470.IP "A filename" 5
471.IX Item "A filename"
472If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a
473filename. This file will be opened for writing and the compressed data
474will be written to it.
475.IP "A filehandle" 5
476.IX Item "A filehandle"
477If the \f(CW$output\fR parameter is a filehandle, the compressed data will be
478written to it.
479The string '\-' can be used as an alias for standard output.
480.IP "A scalar reference" 5
481.IX Item "A scalar reference"
482If \f(CW$output\fR is a scalar reference, the compressed data will be stored
483in \f(CW$$output\fR.
484.PP
485If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`IO::Compress::Gzip\*(C'\fR::new will
486return undef.
487.Sh "Constructor Options"
488.IX Subsection "Constructor Options"
489\&\f(CW\*(C`OPTS\*(C'\fR is any combination of the following options:
490.ie n .IP """AutoClose => 0|1""" 5
491.el .IP "\f(CWAutoClose => 0|1\fR" 5
492.IX Item "AutoClose => 0|1"
493This option is only valid when the \f(CW$output\fR parameter is a filehandle. If
494specified, and the value is true, it will result in the \f(CW$output\fR being
495closed once either the \f(CW\*(C`close\*(C'\fR method is called or the \f(CW\*(C`IO::Compress::Gzip\*(C'\fR
496object is destroyed.
497.Sp
498This parameter defaults to 0.
499.ie n .IP """Append => 0|1""" 5
500.el .IP "\f(CWAppend => 0|1\fR" 5
501.IX Item "Append => 0|1"
502Opens \f(CW$output\fR in append mode.
503.Sp
504The behaviour of this option is dependent on the type of \f(CW$output\fR.
505.RS 5
506.IP "* A Buffer" 5
507.IX Item "A Buffer"
508If \f(CW$output\fR is a buffer and \f(CW\*(C`Append\*(C'\fR is enabled, all compressed data
509will be append to the end of \f(CW$output\fR. Otherwise \f(CW$output\fR will be
510cleared before any data is written to it.
511.IP "* A Filename" 5
512.IX Item "A Filename"
513If \f(CW$output\fR is a filename and \f(CW\*(C`Append\*(C'\fR is enabled, the file will be
514opened in append mode. Otherwise the contents of the file, if any, will be
515truncated before any compressed data is written to it.
516.IP "* A Filehandle" 5
517.IX Item "A Filehandle"
518If \f(CW$output\fR is a filehandle, the file pointer will be positioned to the
519end of the file via a call to \f(CW\*(C`seek\*(C'\fR before any compressed data is written
520to it. Otherwise the file pointer will not be moved.
521.RE
522.RS 5
523.Sp
524This parameter defaults to 0.
525.RE
526.ie n .IP """Merge => 0|1""" 5
527.el .IP "\f(CWMerge => 0|1\fR" 5
528.IX Item "Merge => 0|1"
529This option is used to compress input data and append it to an existing
530compressed data stream in \f(CW$output\fR. The end result is a single compressed
531data stream stored in \f(CW$output\fR.
532.Sp
533It is a fatal error to attempt to use this option when \f(CW$output\fR is not an
534\&\s-1RFC\s0 1952 data stream.
535.Sp
536There are a number of other limitations with the \f(CW\*(C`Merge\*(C'\fR option:
537.RS 5
538.IP "1" 5
539.IX Item "1"
540This module needs to have been built with zlib 1.2.1 or better to work. A
541fatal error will be thrown if \f(CW\*(C`Merge\*(C'\fR is used with an older version of
542zlib.
543.IP "2" 5
544.IX Item "2"
545If \f(CW$output\fR is a file or a filehandle, it must be seekable.
546.RE
547.RS 5
548.Sp
549This parameter defaults to 0.
550.RE
551.IP "\-Level" 5
552.IX Item "-Level"
553Defines the compression level used by zlib. The value should either be
554a number between 0 and 9 (0 means no compression and 9 is maximum
555compression), or one of the symbolic constants defined below.
556.Sp
557.Vb 4
558\& Z_NO_COMPRESSION
559\& Z_BEST_SPEED
560\& Z_BEST_COMPRESSION
561\& Z_DEFAULT_COMPRESSION
562.Ve
563.Sp
564The default is Z_DEFAULT_COMPRESSION.
565.Sp
566Note, these constants are not imported by \f(CW\*(C`IO::Compress::Gzip\*(C'\fR by default.
567.Sp
568.Vb 3
569\& use IO::Compress::Gzip qw(:strategy);
570\& use IO::Compress::Gzip qw(:constants);
571\& use IO::Compress::Gzip qw(:all);
572.Ve
573.IP "\-Strategy" 5
574.IX Item "-Strategy"
575Defines the strategy used to tune the compression. Use one of the symbolic
576constants defined below.
577.Sp
578.Vb 5
579\& Z_FILTERED
580\& Z_HUFFMAN_ONLY
581\& Z_RLE
582\& Z_FIXED
583\& Z_DEFAULT_STRATEGY
584.Ve
585.Sp
586The default is Z_DEFAULT_STRATEGY.
587.ie n .IP """Minimal => 0|1""" 5
588.el .IP "\f(CWMinimal => 0|1\fR" 5
589.IX Item "Minimal => 0|1"
590If specified, this option will force the creation of the smallest possible
591compliant gzip header (which is exactly 10 bytes long) as defined in
592\&\s-1RFC\s0 1952.
593.Sp
594See the section titled \*(L"Compliance\*(R" in \s-1RFC\s0 1952 for a definition
595of the values used for the fields in the gzip header.
596.Sp
597All other parameters that control the content of the gzip header will
598be ignored if this parameter is set to 1.
599.Sp
600This parameter defaults to 0.
601.ie n .IP """Comment => $comment""" 5
602.el .IP "\f(CWComment => $comment\fR" 5
603.IX Item "Comment => $comment"
604Stores the contents of \f(CW$comment\fR in the \s-1COMMENT\s0 field in
605the gzip header.
606By default, no comment field is written to the gzip file.
607.Sp
608If the \f(CW\*(C`\-Strict\*(C'\fR option is enabled, the comment can only consist of \s-1ISO\s0
6098859\-1 characters plus line feed.
610.Sp
611If the \f(CW\*(C`\-Strict\*(C'\fR option is disabled, the comment field can contain any
612character except \s-1NULL\s0. If any null characters are present, the field
613will be truncated at the first \s-1NULL\s0.
614.ie n .IP """Name => $string""" 5
615.el .IP "\f(CWName => $string\fR" 5
616.IX Item "Name => $string"
617Stores the contents of \f(CW$string\fR in the gzip \s-1NAME\s0 header field. If
618\&\f(CW\*(C`Name\*(C'\fR is not specified, no gzip \s-1NAME\s0 field will be created.
619.Sp
620If the \f(CW\*(C`\-Strict\*(C'\fR option is enabled, \f(CW$string\fR can only consist of \s-1ISO\s0
6218859\-1 characters.
622.Sp
623If \f(CW\*(C`\-Strict\*(C'\fR is disabled, then \f(CW$string\fR can contain any character
624except \s-1NULL\s0. If any null characters are present, the field will be
625truncated at the first \s-1NULL\s0.
626.ie n .IP """Time => $number""" 5
627.el .IP "\f(CWTime => $number\fR" 5
628.IX Item "Time => $number"
629Sets the \s-1MTIME\s0 field in the gzip header to \f(CW$number\fR.
630.Sp
631This field defaults to the time the \f(CW\*(C`IO::Compress::Gzip\*(C'\fR object was created
632if this option is not specified.
633.ie n .IP """TextFlag => 0|1""" 5
634.el .IP "\f(CWTextFlag => 0|1\fR" 5
635.IX Item "TextFlag => 0|1"
636This parameter controls the setting of the \s-1FLG\s0.FTEXT bit in the gzip
637header. It is used to signal that the data stored in the gzip file/buffer
638is probably text.
639.Sp
640The default is 0.
641.ie n .IP """HeaderCRC => 0|1""" 5
642.el .IP "\f(CWHeaderCRC => 0|1\fR" 5
643.IX Item "HeaderCRC => 0|1"
644When true this parameter will set the \s-1FLG\s0.FHCRC bit to 1 in the gzip header
645and set the \s-1CRC16\s0 header field to the \s-1CRC\s0 of the complete gzip header
646except the \s-1CRC16\s0 field itself.
647.Sp
648\&\fBNote\fR that gzip files created with the \f(CW\*(C`HeaderCRC\*(C'\fR flag set to 1 cannot
649be read by most, if not all, of the the standard gunzip utilities, most
650notably gzip version 1.2.4. You should therefore avoid using this option if
651you want to maximize the portability of your gzip files.
652.Sp
653This parameter defaults to 0.
654.ie n .IP """OS_Code => $value""" 5
655.el .IP "\f(CWOS_Code => $value\fR" 5
656.IX Item "OS_Code => $value"
657Stores \f(CW$value\fR in the gzip \s-1OS\s0 header field. A number between 0 and 255 is
658valid.
659.Sp
660If not specified, this parameter defaults to the \s-1OS\s0 code of the Operating
661System this module was built on. The value 3 is used as a catch-all for all
662Unix variants and unknown Operating Systems.
663.ie n .IP """ExtraField => $data""" 5
664.el .IP "\f(CWExtraField => $data\fR" 5
665.IX Item "ExtraField => $data"
666This parameter allows additional metadata to be stored in the ExtraField in
667the gzip header. An \s-1RFC\s0 1952 compliant ExtraField consists of zero or more
668subfields. Each subfield consists of a two byte header followed by the
669subfield data.
670.Sp
671The list of subfields can be supplied in any of the following formats
672.Sp
673.Vb 12
674\& \-ExtraField => [$id1, $data1,
675\& $id2, $data2,
676\& ...
677\& ]
678\& \-ExtraField => [ [$id1 => $data1],
679\& [$id2 => $data2],
680\& ...
681\& ]
682\& \-ExtraField => { $id1 => $data1,
683\& $id2 => $data2,
684\& ...
685\& }
686.Ve
687.Sp
688Where \f(CW$id1\fR, \f(CW$id2\fR are two byte subfield \s-1ID\s0's. The second byte of
689the \s-1ID\s0 cannot be 0, unless the \f(CW\*(C`Strict\*(C'\fR option has been disabled.
690.Sp
691If you use the hash syntax, you have no control over the order in which
692the ExtraSubFields are stored, plus you cannot have SubFields with
693duplicate \s-1ID\s0.
694.Sp
695Alternatively the list of subfields can by supplied as a scalar, thus
696.Sp
697.Vb 1
698\& \-ExtraField => $rawdata
699.Ve
700.Sp
701If you use the raw format, and the \f(CW\*(C`Strict\*(C'\fR option is enabled,
702\&\f(CW\*(C`IO::Compress::Gzip\*(C'\fR will check that \f(CW$rawdata\fR consists of zero or more
703conformant sub\-fields. When \f(CW\*(C`Strict\*(C'\fR is disabled, \f(CW$rawdata\fR can
704consist of any arbitrary byte stream.
705.Sp
706The maximum size of the Extra Field 65535 bytes.
707.ie n .IP """ExtraFlags => $value""" 5
708.el .IP "\f(CWExtraFlags => $value\fR" 5
709.IX Item "ExtraFlags => $value"
710Sets the \s-1XFL\s0 byte in the gzip header to \f(CW$value\fR.
711.Sp
712If this option is not present, the value stored in \s-1XFL\s0 field will be
713determined by the setting of the \f(CW\*(C`Level\*(C'\fR option.
714.Sp
715If \f(CW\*(C`Level => Z_BEST_SPEED\*(C'\fR has been specified then \s-1XFL\s0 is set to 2.
716If \f(CW\*(C`Level => Z_BEST_COMPRESSION\*(C'\fR has been specified then \s-1XFL\s0 is set to 4.
717Otherwise \s-1XFL\s0 is set to 0.
718.ie n .IP """Strict => 0|1""" 5
719.el .IP "\f(CWStrict => 0|1\fR" 5
720.IX Item "Strict => 0|1"
721\&\f(CW\*(C`Strict\*(C'\fR will optionally police the values supplied with other options
722to ensure they are compliant with \s-1RFC1952\s0.
723.Sp
724This option is enabled by default.
725.Sp
726If \f(CW\*(C`Strict\*(C'\fR is enabled the following behaviour will be policed:
727.RS 5
728.IP "*" 5
729The value supplied with the \f(CW\*(C`Name\*(C'\fR option can only contain \s-1ISO\s0 8859\-1
730characters.
731.IP "*" 5
732The value supplied with the \f(CW\*(C`Comment\*(C'\fR option can only contain \s-1ISO\s0 8859\-1
733characters plus line\-feed.
734.IP "*" 5
735The values supplied with the \f(CW\*(C`\-Name\*(C'\fR and \f(CW\*(C`\-Comment\*(C'\fR options cannot
736contain multiple embedded nulls.
737.IP "*" 5
738If an \f(CW\*(C`ExtraField\*(C'\fR option is specified and it is a simple scalar,
739it must conform to the sub-field structure as defined in \s-1RFC\s0 1952.
740.IP "*" 5
741If an \f(CW\*(C`ExtraField\*(C'\fR option is specified the second byte of the \s-1ID\s0 will be
742checked in each subfield to ensure that it does not contain the reserved
743value 0x00.
744.RE
745.RS 5
746.Sp
747When \f(CW\*(C`Strict\*(C'\fR is disabled the following behaviour will be policed:
748.IP "*" 5
749The value supplied with \f(CW\*(C`\-Name\*(C'\fR option can contain
750any character except \s-1NULL\s0.
751.IP "*" 5
752The value supplied with \f(CW\*(C`\-Comment\*(C'\fR option can contain any character
753except \s-1NULL\s0.
754.IP "*" 5
755The values supplied with the \f(CW\*(C`\-Name\*(C'\fR and \f(CW\*(C`\-Comment\*(C'\fR options can contain
756multiple embedded nulls. The string written to the gzip header will
757consist of the characters up to, but not including, the first embedded
758\&\s-1NULL\s0.
759.IP "*" 5
760If an \f(CW\*(C`ExtraField\*(C'\fR option is specified and it is a simple scalar, the
761structure will not be checked. The only error is if the length is too big.
762.IP "*" 5
763The \s-1ID\s0 header in an \f(CW\*(C`ExtraField\*(C'\fR sub-field can consist of any two bytes.
764.RE
765.RS 5
766.RE
767.Sh "Examples"
768.IX Subsection "Examples"
769\&\s-1TODO\s0
770.SH "Methods"
771.IX Header "Methods"
772.Sh "print"
773.IX Subsection "print"
774Usage is
775.PP
776.Vb 2
777\& $z\->print($data)
778\& print $z $data
779.Ve
780.PP
781Compresses and outputs the contents of the \f(CW$data\fR parameter. This
782has the same behaviour as the \f(CW\*(C`print\*(C'\fR built\-in.
783.PP
784Returns true if successful.
785.Sh "printf"
786.IX Subsection "printf"
787Usage is
788.PP
789.Vb 2
790\& $z\->printf($format, $data)
791\& printf $z $format, $data
792.Ve
793.PP
794Compresses and outputs the contents of the \f(CW$data\fR parameter.
795.PP
796Returns true if successful.
797.Sh "syswrite"
798.IX Subsection "syswrite"
799Usage is
800.PP
801.Vb 3
802\& $z\->syswrite $data
803\& $z\->syswrite $data, $length
804\& $z\->syswrite $data, $length, $offset
805.Ve
806.PP
807Compresses and outputs the contents of the \f(CW$data\fR parameter.
808.PP
809Returns the number of uncompressed bytes written, or \f(CW\*(C`undef\*(C'\fR if
810unsuccessful.
811.Sh "write"
812.IX Subsection "write"
813Usage is
814.PP
815.Vb 3
816\& $z\->write $data
817\& $z\->write $data, $length
818\& $z\->write $data, $length, $offset
819.Ve
820.PP
821Compresses and outputs the contents of the \f(CW$data\fR parameter.
822.PP
823Returns the number of uncompressed bytes written, or \f(CW\*(C`undef\*(C'\fR if
824unsuccessful.
825.Sh "flush"
826.IX Subsection "flush"
827Usage is
828.PP
829.Vb 2
830\& $z\->flush;
831\& $z\->flush($flush_type);
832.Ve
833.PP
834Flushes any pending compressed data to the output file/buffer.
835.PP
836This method takes an optional parameter, \f(CW$flush_type\fR, that controls
837how the flushing will be carried out. By default the \f(CW$flush_type\fR
838used is \f(CW\*(C`Z_FINISH\*(C'\fR. Other valid values for \f(CW$flush_type\fR are
839\&\f(CW\*(C`Z_NO_FLUSH\*(C'\fR, \f(CW\*(C`Z_SYNC_FLUSH\*(C'\fR, \f(CW\*(C`Z_FULL_FLUSH\*(C'\fR and \f(CW\*(C`Z_BLOCK\*(C'\fR. It is
840strongly recommended that you only set the \f(CW\*(C`flush_type\*(C'\fR parameter if
841you fully understand the implications of what it does \- overuse of \f(CW\*(C`flush\*(C'\fR
842can seriously degrade the level of compression achieved. See the \f(CW\*(C`zlib\*(C'\fR
843documentation for details.
844.PP
845Returns true on success.
846.Sh "tell"
847.IX Subsection "tell"
848Usage is
849.PP
850.Vb 2
851\& $z\->tell()
852\& tell $z
853.Ve
854.PP
855Returns the uncompressed file offset.
856.Sh "eof"
857.IX Subsection "eof"
858Usage is
859.PP
860.Vb 2
861\& $z\->eof();
862\& eof($z);
863.Ve
864.PP
865Returns true if the \f(CW\*(C`close\*(C'\fR method has been called.
866.Sh "seek"
867.IX Subsection "seek"
868.Vb 2
869\& $z\->seek($position, $whence);
870\& seek($z, $position, $whence);
871.Ve
872.PP
873Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction
874that it is only legal to seek forward in the output file/buffer.
875It is a fatal error to attempt to seek backward.
876.PP
877Empty parts of the file/buffer will have \s-1NULL\s0 (0x00) bytes written to them.
878.PP
879The \f(CW$whence\fR parameter takes one the usual values, namely \s-1SEEK_SET\s0,
880\&\s-1SEEK_CUR\s0 or \s-1SEEK_END\s0.
881.PP
882Returns 1 on success, 0 on failure.
883.Sh "binmode"
884.IX Subsection "binmode"
885Usage is
886.PP
887.Vb 2
888\& $z\->binmode
889\& binmode $z ;
890.Ve
891.PP
892This is a noop provided for completeness.
893.Sh "opened"
894.IX Subsection "opened"
895.Vb 1
896\& $z\->opened()
897.Ve
898.PP
899Returns true if the object currently refers to a opened file/buffer.
900.Sh "autoflush"
901.IX Subsection "autoflush"
902.Vb 2
903\& my $prev = $z\->autoflush()
904\& my $prev = $z\->autoflush(EXPR)
905.Ve
906.PP
907If the \f(CW$z\fR object is associated with a file or a filehandle, this method
908returns the current autoflush setting for the underlying filehandle. If
909\&\f(CW\*(C`EXPR\*(C'\fR is present, and is non\-zero, it will enable flushing after every
910write/print operation.
911.PP
912If \f(CW$z\fR is associated with a buffer, this method has no effect and always
913returns \f(CW\*(C`undef\*(C'\fR.
914.PP
915\&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or
916retrieve the autoflush setting.
917.Sh "input_line_number"
918.IX Subsection "input_line_number"
919.Vb 2
920\& $z\->input_line_number()
921\& $z\->input_line_number(EXPR)
922.Ve
923.PP
924This method always returns \f(CW\*(C`undef\*(C'\fR when compressing.
925.Sh "fileno"
926.IX Subsection "fileno"
927.Vb 2
928\& $z\->fileno()
929\& fileno($z)
930.Ve
931.PP
932If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR
933will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is
934called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR.
935.PP
936If the \f(CW$z\fR object is is associated with a buffer, this method will return
937\&\f(CW\*(C`undef\*(C'\fR.
938.Sh "close"
939.IX Subsection "close"
940.Vb 2
941\& $z\->close() ;
942\& close $z ;
943.Ve
944.PP
945Flushes any pending compressed data and then closes the output file/buffer.
946.PP
947For most versions of Perl this method will be automatically invoked if
948the IO::Compress::Gzip object is destroyed (either explicitly or by the
949variable with the reference to the object going out of scope). The
950exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
951these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but
952not until global destruction of all live objects when the program is
953terminating.
954.PP
955Therefore, if you want your scripts to be able to run on all versions
956of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic
957closing.
958.PP
959Returns true on success, otherwise 0.
960.PP
961If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Compress::Gzip
962object was created, and the object is associated with a file, the
963underlying file will also be closed.
964.Sh "newStream([\s-1OPTS\s0])"
965.IX Subsection "newStream([OPTS])"
966Usage is
967.PP
968.Vb 1
969\& $z\->newStream( [OPTS] )
970.Ve
971.PP
972Closes the current compressed data stream and starts a new one.
973.PP
974\&\s-1OPTS\s0 consists of any of the the options that are available when creating
975the \f(CW$z\fR object.
976.PP
977See the \*(L"Constructor Options\*(R" section for more details.
978.Sh "deflateParams"
979.IX Subsection "deflateParams"
980Usage is
981.PP
982.Vb 1
983\& $z\->deflateParams
984.Ve
985.PP
986\&\s-1TODO\s0
987.SH "Importing"
988.IX Header "Importing"
989A number of symbolic constants are required by some methods in
990\&\f(CW\*(C`IO::Compress::Gzip\*(C'\fR. None are imported by default.
991.IP ":all" 5
992.IX Item ":all"
993Imports \f(CW\*(C`gzip\*(C'\fR, \f(CW$GzipError\fR and all symbolic
994constants that can be used by \f(CW\*(C`IO::Compress::Gzip\*(C'\fR. Same as doing this
995.Sp
996.Vb 1
997\& use IO::Compress::Gzip qw(gzip $GzipError :constants) ;
998.Ve
999.IP ":constants" 5
1000.IX Item ":constants"
1001Import all symbolic constants. Same as doing this
1002.Sp
1003.Vb 1
1004\& use IO::Compress::Gzip qw(:flush :level :strategy) ;
1005.Ve
1006.IP ":flush" 5
1007.IX Item ":flush"
1008These symbolic constants are used by the \f(CW\*(C`flush\*(C'\fR method.
1009.Sp
1010.Vb 6
1011\& Z_NO_FLUSH
1012\& Z_PARTIAL_FLUSH
1013\& Z_SYNC_FLUSH
1014\& Z_FULL_FLUSH
1015\& Z_FINISH
1016\& Z_BLOCK
1017.Ve
1018.IP ":level" 5
1019.IX Item ":level"
1020These symbolic constants are used by the \f(CW\*(C`Level\*(C'\fR option in the constructor.
1021.Sp
1022.Vb 4
1023\& Z_NO_COMPRESSION
1024\& Z_BEST_SPEED
1025\& Z_BEST_COMPRESSION
1026\& Z_DEFAULT_COMPRESSION
1027.Ve
1028.IP ":strategy" 5
1029.IX Item ":strategy"
1030These symbolic constants are used by the \f(CW\*(C`Strategy\*(C'\fR option in the constructor.
1031.Sp
1032.Vb 5
1033\& Z_FILTERED
1034\& Z_HUFFMAN_ONLY
1035\& Z_RLE
1036\& Z_FIXED
1037\& Z_DEFAULT_STRATEGY
1038.Ve
1039.SH "EXAMPLES"
1040.IX Header "EXAMPLES"
1041.Sh "Apache::GZip Revisited"
1042.IX Subsection "Apache::GZip Revisited"
1043See IO::Compress::FAQ
1044.Sh "Working with Net::FTP"
1045.IX Subsection "Working with Net::FTP"
1046See IO::Compress::FAQ
1047.SH "SEE ALSO"
1048.IX Header "SEE ALSO"
1049Compress::Zlib, 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
1050.PP
1051Compress::Zlib::FAQ
1052.PP
1053File::GlobMapper, Archive::Zip,
1054Archive::Tar,
1055IO::Zlib
1056.PP
1057For \s-1RFC\s0 1950, 1951 and 1952 see
1058\&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR,
1059\&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and
1060\&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR
1061.PP
1062The \fIzlib\fR compression library was written by Jean-loup Gailly
1063\&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR.
1064.PP
1065The primary site for the \fIzlib\fR compression library is
1066\&\fIhttp://www.zlib.org\fR.
1067.PP
1068The primary site for gzip is \fIhttp://www.gzip.org\fR.
1069.SH "AUTHOR"
1070.IX Header "AUTHOR"
1071This module was written by Paul Marquess, \fIpmqs@cpan.org\fR.
1072.SH "MODIFICATION HISTORY"
1073.IX Header "MODIFICATION HISTORY"
1074See the Changes file.
1075.SH "COPYRIGHT AND LICENSE"
1076.IX Header "COPYRIGHT AND LICENSE"
1077Copyright (c) 2005\-2009 Paul Marquess. All rights reserved.
1078.PP
1079This program is free software; you can redistribute it and/or
1080modify it under the same terms as Perl itself.