Commit | Line | Data |
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::Deflate 3" |
132 | .TH IO::Compress::Deflate 3 "2009-11-09" "perl v5.8.7" "User Contributed Perl Documentation" |
133 | .SH "NAME" |
134 | IO::Compress::Deflate \- Write RFC 1950 files/buffers |
135 | .SH "SYNOPSIS" |
136 | .IX Header "SYNOPSIS" |
137 | .Vb 1 |
138 | \& use IO::Compress::Deflate qw(deflate $DeflateError) ; |
139 | .Ve |
140 | .PP |
141 | .Vb 2 |
142 | \& my $status = deflate $input => $output [,OPTS] |
143 | \& or die "deflate failed: $DeflateError\en"; |
144 | .Ve |
145 | .PP |
146 | .Vb 2 |
147 | \& my $z = new IO::Compress::Deflate $output [,OPTS] |
148 | \& or die "deflate failed: $DeflateError\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 | \& $DeflateError ; |
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" |
196 | This module provides a Perl interface that allows writing compressed |
197 | data to files or buffer as defined in \s-1RFC\s0 1950. |
198 | .PP |
199 | For reading \s-1RFC\s0 1950 files/buffers, see the companion module |
200 | IO::Uncompress::Inflate. |
201 | .SH "Functional Interface" |
202 | .IX Header "Functional Interface" |
203 | A top-level function, \f(CW\*(C`deflate\*(C'\fR, is provided to carry out |
204 | \&\*(L"one\-shot\*(R" compression between buffers and/or files. For finer |
205 | control over the compression process, see the \*(L"\s-1OO\s0 Interface\*(R" |
206 | section. |
207 | .PP |
208 | .Vb 1 |
209 | \& use IO::Compress::Deflate qw(deflate $DeflateError) ; |
210 | .Ve |
211 | .PP |
212 | .Vb 2 |
213 | \& deflate $input => $output [,OPTS] |
214 | \& or die "deflate failed: $DeflateError\en"; |
215 | .Ve |
216 | .PP |
217 | The functional interface needs Perl5.005 or better. |
218 | .ie n .Sh "deflate $input\fP => \f(CW$output [, \s-1OPTS\s0]" |
219 | .el .Sh "deflate \f(CW$input\fP => \f(CW$output\fP [, \s-1OPTS\s0]" |
220 | .IX Subsection "deflate $input => $output [, OPTS]" |
221 | \&\f(CW\*(C`deflate\*(C'\fR expects at least two parameters, \f(CW$input\fR and \f(CW$output\fR. |
222 | .PP |
223 | \fIThe \f(CI$input\fI parameter\fR |
224 | .IX Subsection "The $input parameter" |
225 | .PP |
226 | The parameter, \f(CW$input\fR, is used to define the source of |
227 | the uncompressed data. |
228 | .PP |
229 | It can take one of the following forms: |
230 | .IP "A filename" 5 |
231 | .IX Item "A filename" |
232 | If the \f(CW$input\fR parameter is a simple scalar, it is assumed to be a |
233 | filename. This file will be opened for reading and the input data |
234 | will be read from it. |
235 | .IP "A filehandle" 5 |
236 | .IX Item "A filehandle" |
237 | If the \f(CW$input\fR parameter is a filehandle, the input data will be |
238 | read from it. |
239 | The string '\-' can be used as an alias for standard input. |
240 | .IP "A scalar reference" 5 |
241 | .IX Item "A scalar reference" |
242 | If \f(CW$input\fR is a scalar reference, the input data will be read |
243 | from \f(CW$$input\fR. |
244 | .IP "An array reference" 5 |
245 | .IX Item "An array reference" |
246 | If \f(CW$input\fR is an array reference, each element in the array must be a |
247 | filename. |
248 | .Sp |
249 | The input data will be read from each file in turn. |
250 | .Sp |
251 | The complete array will be walked to ensure that it only |
252 | contains valid filenames before any data is compressed. |
253 | .IP "An Input FileGlob string" 5 |
254 | .IX Item "An Input FileGlob string" |
255 | If \f(CW$input\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R" |
256 | \&\f(CW\*(C`deflate\*(C'\fR will assume that it is an \fIinput fileglob string\fR. The |
257 | input is the list of files that match the fileglob. |
258 | .Sp |
259 | If the fileglob does not match any files ... |
260 | .Sp |
261 | See File::GlobMapper for more details. |
262 | .PP |
263 | If the \f(CW$input\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned. |
264 | .PP |
265 | \fIThe \f(CI$output\fI parameter\fR |
266 | .IX Subsection "The $output parameter" |
267 | .PP |
268 | The parameter \f(CW$output\fR is used to control the destination of the |
269 | compressed data. This parameter can take one of these forms. |
270 | .IP "A filename" 5 |
271 | .IX Item "A filename" |
272 | If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a |
273 | filename. This file will be opened for writing and the compressed |
274 | data will be written to it. |
275 | .IP "A filehandle" 5 |
276 | .IX Item "A filehandle" |
277 | If the \f(CW$output\fR parameter is a filehandle, the compressed data |
278 | will be written to it. |
279 | The string '\-' can be used as an alias for standard output. |
280 | .IP "A scalar reference" 5 |
281 | .IX Item "A scalar reference" |
282 | If \f(CW$output\fR is a scalar reference, the compressed data will be |
283 | stored in \f(CW$$output\fR. |
284 | .IP "An Array Reference" 5 |
285 | .IX Item "An Array Reference" |
286 | If \f(CW$output\fR is an array reference, the compressed data will be |
287 | pushed onto the array. |
288 | .IP "An Output FileGlob" 5 |
289 | .IX Item "An Output FileGlob" |
290 | If \f(CW$output\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R" |
291 | \&\f(CW\*(C`deflate\*(C'\fR will assume that it is an \fIoutput fileglob string\fR. The |
292 | output is the list of files that match the fileglob. |
293 | .Sp |
294 | When \f(CW$output\fR is an fileglob string, \f(CW$input\fR must also be a fileglob |
295 | string. Anything else is an error. |
296 | .PP |
297 | If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned. |
298 | .Sh "Notes" |
299 | .IX Subsection "Notes" |
300 | When \f(CW$input\fR maps to multiple files/buffers and \f(CW$output\fR is a single |
301 | file/buffer the input files/buffers will be stored |
302 | in \f(CW$output\fR as a concatenated series of compressed data streams. |
303 | .Sh "Optional Parameters" |
304 | .IX Subsection "Optional Parameters" |
305 | Unless specified below, the optional parameters for \f(CW\*(C`deflate\*(C'\fR, |
306 | \&\f(CW\*(C`OPTS\*(C'\fR, are the same as those used with the \s-1OO\s0 interface defined in the |
307 | \&\*(L"Constructor Options\*(R" section below. |
308 | .ie n .IP """AutoClose => 0|1""" 5 |
309 | .el .IP "\f(CWAutoClose => 0|1\fR" 5 |
310 | .IX Item "AutoClose => 0|1" |
311 | This option applies to any input or output data streams to |
312 | \&\f(CW\*(C`deflate\*(C'\fR that are filehandles. |
313 | .Sp |
314 | If \f(CW\*(C`AutoClose\*(C'\fR is specified, and the value is true, it will result in all |
315 | input and/or output filehandles being closed once \f(CW\*(C`deflate\*(C'\fR has |
316 | completed. |
317 | .Sp |
318 | This parameter defaults to 0. |
319 | .ie n .IP """BinModeIn => 0|1""" 5 |
320 | .el .IP "\f(CWBinModeIn => 0|1\fR" 5 |
321 | .IX Item "BinModeIn => 0|1" |
322 | When reading from a file or filehandle, set \f(CW\*(C`binmode\*(C'\fR before reading. |
323 | .Sp |
324 | Defaults to 0. |
325 | .ie n .IP """Append => 0|1""" 5 |
326 | .el .IP "\f(CWAppend => 0|1\fR" 5 |
327 | .IX Item "Append => 0|1" |
328 | The behaviour of this option is dependent on the type of output data |
329 | stream. |
330 | .RS 5 |
331 | .IP "* A Buffer" 5 |
332 | .IX Item "A Buffer" |
333 | If \f(CW\*(C`Append\*(C'\fR is enabled, all compressed data will be append to the end of |
334 | the output buffer. Otherwise the output buffer will be cleared before any |
335 | compressed data is written to it. |
336 | .IP "* A Filename" 5 |
337 | .IX Item "A Filename" |
338 | If \f(CW\*(C`Append\*(C'\fR is enabled, the file will be opened in append mode. Otherwise |
339 | the contents of the file, if any, will be truncated before any compressed |
340 | data is written to it. |
341 | .IP "* A Filehandle" 5 |
342 | .IX Item "A Filehandle" |
343 | If \f(CW\*(C`Append\*(C'\fR is enabled, the filehandle will be positioned to the end of |
344 | the file via a call to \f(CW\*(C`seek\*(C'\fR before any compressed data is |
345 | written to it. Otherwise the file pointer will not be moved. |
346 | .RE |
347 | .RS 5 |
348 | .Sp |
349 | When \f(CW\*(C`Append\*(C'\fR is specified, and set to true, it will \fIappend\fR all compressed |
350 | data to the output data stream. |
351 | .Sp |
352 | So when the output is a filehandle it will carry out a seek to the eof |
353 | before writing any compressed data. If the output is a filename, it will be opened for |
354 | appending. If the output is a buffer, all compressed data will be appened to |
355 | the existing buffer. |
356 | .Sp |
357 | Conversely when \f(CW\*(C`Append\*(C'\fR is not specified, or it is present and is set to |
358 | false, it will operate as follows. |
359 | .Sp |
360 | When the output is a filename, it will truncate the contents of the file |
361 | before writing any compressed data. If the output is a filehandle |
362 | its position will not be changed. If the output is a buffer, it will be |
363 | wiped before any compressed data is output. |
364 | .Sp |
365 | Defaults to 0. |
366 | .RE |
367 | .Sh "Examples" |
368 | .IX Subsection "Examples" |
369 | To read the contents of the file \f(CW\*(C`file1.txt\*(C'\fR and write the compressed |
370 | data to the file \f(CW\*(C`file1.txt.1950\*(C'\fR. |
371 | .PP |
372 | .Vb 3 |
373 | \& use strict ; |
374 | \& use warnings ; |
375 | \& use IO::Compress::Deflate qw(deflate $DeflateError) ; |
376 | .Ve |
377 | .PP |
378 | .Vb 3 |
379 | \& my $input = "file1.txt"; |
380 | \& deflate $input => "$input.1950" |
381 | \& or die "deflate failed: $DeflateError\en"; |
382 | .Ve |
383 | .PP |
384 | To read from an existing Perl filehandle, \f(CW$input\fR, and write the |
385 | compressed data to a buffer, \f(CW$buffer\fR. |
386 | .PP |
387 | .Vb 4 |
388 | \& use strict ; |
389 | \& use warnings ; |
390 | \& use IO::Compress::Deflate qw(deflate $DeflateError) ; |
391 | \& use IO::File ; |
392 | .Ve |
393 | .PP |
394 | .Vb 5 |
395 | \& my $input = new IO::File "<file1.txt" |
396 | \& or die "Cannot open 'file1.txt': $!\en" ; |
397 | \& my $buffer ; |
398 | \& deflate $input => \e$buffer |
399 | \& or die "deflate failed: $DeflateError\en"; |
400 | .Ve |
401 | .PP |
402 | To compress all files in the directory \*(L"/my/home\*(R" that match \*(L"*.txt\*(R" |
403 | and store the compressed data in the same directory |
404 | .PP |
405 | .Vb 3 |
406 | \& use strict ; |
407 | \& use warnings ; |
408 | \& use IO::Compress::Deflate qw(deflate $DeflateError) ; |
409 | .Ve |
410 | .PP |
411 | .Vb 2 |
412 | \& deflate '</my/home/*.txt>' => '<*.1950>' |
413 | \& or die "deflate failed: $DeflateError\en"; |
414 | .Ve |
415 | .PP |
416 | and if you want to compress each file one at a time, this will do the trick |
417 | .PP |
418 | .Vb 3 |
419 | \& use strict ; |
420 | \& use warnings ; |
421 | \& use IO::Compress::Deflate qw(deflate $DeflateError) ; |
422 | .Ve |
423 | .PP |
424 | .Vb 6 |
425 | \& for my $input ( glob "/my/home/*.txt" ) |
426 | \& { |
427 | \& my $output = "$input.1950" ; |
428 | \& deflate $input => $output |
429 | \& or die "Error compressing '$input': $DeflateError\en"; |
430 | \& } |
431 | .Ve |
432 | .SH "OO Interface" |
433 | .IX Header "OO Interface" |
434 | .Sh "Constructor" |
435 | .IX Subsection "Constructor" |
436 | The format of the constructor for \f(CW\*(C`IO::Compress::Deflate\*(C'\fR is shown below |
437 | .PP |
438 | .Vb 2 |
439 | \& my $z = new IO::Compress::Deflate $output [,OPTS] |
440 | \& or die "IO::Compress::Deflate failed: $DeflateError\en"; |
441 | .Ve |
442 | .PP |
443 | It returns an \f(CW\*(C`IO::Compress::Deflate\*(C'\fR object on success and undef on failure. |
444 | The variable \f(CW$DeflateError\fR will contain an error message on failure. |
445 | .PP |
446 | If you are running Perl 5.005 or better the object, \f(CW$z\fR, returned from |
447 | IO::Compress::Deflate can be used exactly like an IO::File filehandle. |
448 | This means that all normal output file operations can be carried out |
449 | with \f(CW$z\fR. |
450 | For example, to write to a compressed file/buffer you can use either of |
451 | these forms |
452 | .PP |
453 | .Vb 2 |
454 | \& $z\->print("hello world\en"); |
455 | \& print $z "hello world\en"; |
456 | .Ve |
457 | .PP |
458 | The mandatory parameter \f(CW$output\fR is used to control the destination |
459 | of the compressed data. This parameter can take one of these forms. |
460 | .IP "A filename" 5 |
461 | .IX Item "A filename" |
462 | If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a |
463 | filename. This file will be opened for writing and the compressed data |
464 | will be written to it. |
465 | .IP "A filehandle" 5 |
466 | .IX Item "A filehandle" |
467 | If the \f(CW$output\fR parameter is a filehandle, the compressed data will be |
468 | written to it. |
469 | The string '\-' can be used as an alias for standard output. |
470 | .IP "A scalar reference" 5 |
471 | .IX Item "A scalar reference" |
472 | If \f(CW$output\fR is a scalar reference, the compressed data will be stored |
473 | in \f(CW$$output\fR. |
474 | .PP |
475 | If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`IO::Compress::Deflate\*(C'\fR::new will |
476 | return undef. |
477 | .Sh "Constructor Options" |
478 | .IX Subsection "Constructor Options" |
479 | \&\f(CW\*(C`OPTS\*(C'\fR is any combination of the following options: |
480 | .ie n .IP """AutoClose => 0|1""" 5 |
481 | .el .IP "\f(CWAutoClose => 0|1\fR" 5 |
482 | .IX Item "AutoClose => 0|1" |
483 | This option is only valid when the \f(CW$output\fR parameter is a filehandle. If |
484 | specified, and the value is true, it will result in the \f(CW$output\fR being |
485 | closed once either the \f(CW\*(C`close\*(C'\fR method is called or the \f(CW\*(C`IO::Compress::Deflate\*(C'\fR |
486 | object is destroyed. |
487 | .Sp |
488 | This parameter defaults to 0. |
489 | .ie n .IP """Append => 0|1""" 5 |
490 | .el .IP "\f(CWAppend => 0|1\fR" 5 |
491 | .IX Item "Append => 0|1" |
492 | Opens \f(CW$output\fR in append mode. |
493 | .Sp |
494 | The behaviour of this option is dependent on the type of \f(CW$output\fR. |
495 | .RS 5 |
496 | .IP "* A Buffer" 5 |
497 | .IX Item "A Buffer" |
498 | If \f(CW$output\fR is a buffer and \f(CW\*(C`Append\*(C'\fR is enabled, all compressed data |
499 | will be append to the end of \f(CW$output\fR. Otherwise \f(CW$output\fR will be |
500 | cleared before any data is written to it. |
501 | .IP "* A Filename" 5 |
502 | .IX Item "A Filename" |
503 | If \f(CW$output\fR is a filename and \f(CW\*(C`Append\*(C'\fR is enabled, the file will be |
504 | opened in append mode. Otherwise the contents of the file, if any, will be |
505 | truncated before any compressed data is written to it. |
506 | .IP "* A Filehandle" 5 |
507 | .IX Item "A Filehandle" |
508 | If \f(CW$output\fR is a filehandle, the file pointer will be positioned to the |
509 | end of the file via a call to \f(CW\*(C`seek\*(C'\fR before any compressed data is written |
510 | to it. Otherwise the file pointer will not be moved. |
511 | .RE |
512 | .RS 5 |
513 | .Sp |
514 | This parameter defaults to 0. |
515 | .RE |
516 | .ie n .IP """Merge => 0|1""" 5 |
517 | .el .IP "\f(CWMerge => 0|1\fR" 5 |
518 | .IX Item "Merge => 0|1" |
519 | This option is used to compress input data and append it to an existing |
520 | compressed data stream in \f(CW$output\fR. The end result is a single compressed |
521 | data stream stored in \f(CW$output\fR. |
522 | .Sp |
523 | It is a fatal error to attempt to use this option when \f(CW$output\fR is not an |
524 | \&\s-1RFC\s0 1950 data stream. |
525 | .Sp |
526 | There are a number of other limitations with the \f(CW\*(C`Merge\*(C'\fR option: |
527 | .RS 5 |
528 | .IP "1" 5 |
529 | .IX Item "1" |
530 | This module needs to have been built with zlib 1.2.1 or better to work. A |
531 | fatal error will be thrown if \f(CW\*(C`Merge\*(C'\fR is used with an older version of |
532 | zlib. |
533 | .IP "2" 5 |
534 | .IX Item "2" |
535 | If \f(CW$output\fR is a file or a filehandle, it must be seekable. |
536 | .RE |
537 | .RS 5 |
538 | .Sp |
539 | This parameter defaults to 0. |
540 | .RE |
541 | .IP "\-Level" 5 |
542 | .IX Item "-Level" |
543 | Defines the compression level used by zlib. The value should either be |
544 | a number between 0 and 9 (0 means no compression and 9 is maximum |
545 | compression), or one of the symbolic constants defined below. |
546 | .Sp |
547 | .Vb 4 |
548 | \& Z_NO_COMPRESSION |
549 | \& Z_BEST_SPEED |
550 | \& Z_BEST_COMPRESSION |
551 | \& Z_DEFAULT_COMPRESSION |
552 | .Ve |
553 | .Sp |
554 | The default is Z_DEFAULT_COMPRESSION. |
555 | .Sp |
556 | Note, these constants are not imported by \f(CW\*(C`IO::Compress::Deflate\*(C'\fR by default. |
557 | .Sp |
558 | .Vb 3 |
559 | \& use IO::Compress::Deflate qw(:strategy); |
560 | \& use IO::Compress::Deflate qw(:constants); |
561 | \& use IO::Compress::Deflate qw(:all); |
562 | .Ve |
563 | .IP "\-Strategy" 5 |
564 | .IX Item "-Strategy" |
565 | Defines the strategy used to tune the compression. Use one of the symbolic |
566 | constants defined below. |
567 | .Sp |
568 | .Vb 5 |
569 | \& Z_FILTERED |
570 | \& Z_HUFFMAN_ONLY |
571 | \& Z_RLE |
572 | \& Z_FIXED |
573 | \& Z_DEFAULT_STRATEGY |
574 | .Ve |
575 | .Sp |
576 | The default is Z_DEFAULT_STRATEGY. |
577 | .ie n .IP """Strict => 0|1""" 5 |
578 | .el .IP "\f(CWStrict => 0|1\fR" 5 |
579 | .IX Item "Strict => 0|1" |
580 | This is a placeholder option. |
581 | .Sh "Examples" |
582 | .IX Subsection "Examples" |
583 | \&\s-1TODO\s0 |
584 | .SH "Methods" |
585 | .IX Header "Methods" |
586 | .Sh "print" |
587 | .IX Subsection "print" |
588 | Usage is |
589 | .PP |
590 | .Vb 2 |
591 | \& $z\->print($data) |
592 | \& print $z $data |
593 | .Ve |
594 | .PP |
595 | Compresses and outputs the contents of the \f(CW$data\fR parameter. This |
596 | has the same behaviour as the \f(CW\*(C`print\*(C'\fR built\-in. |
597 | .PP |
598 | Returns true if successful. |
599 | .Sh "printf" |
600 | .IX Subsection "printf" |
601 | Usage is |
602 | .PP |
603 | .Vb 2 |
604 | \& $z\->printf($format, $data) |
605 | \& printf $z $format, $data |
606 | .Ve |
607 | .PP |
608 | Compresses and outputs the contents of the \f(CW$data\fR parameter. |
609 | .PP |
610 | Returns true if successful. |
611 | .Sh "syswrite" |
612 | .IX Subsection "syswrite" |
613 | Usage is |
614 | .PP |
615 | .Vb 3 |
616 | \& $z\->syswrite $data |
617 | \& $z\->syswrite $data, $length |
618 | \& $z\->syswrite $data, $length, $offset |
619 | .Ve |
620 | .PP |
621 | Compresses and outputs the contents of the \f(CW$data\fR parameter. |
622 | .PP |
623 | Returns the number of uncompressed bytes written, or \f(CW\*(C`undef\*(C'\fR if |
624 | unsuccessful. |
625 | .Sh "write" |
626 | .IX Subsection "write" |
627 | Usage is |
628 | .PP |
629 | .Vb 3 |
630 | \& $z\->write $data |
631 | \& $z\->write $data, $length |
632 | \& $z\->write $data, $length, $offset |
633 | .Ve |
634 | .PP |
635 | Compresses and outputs the contents of the \f(CW$data\fR parameter. |
636 | .PP |
637 | Returns the number of uncompressed bytes written, or \f(CW\*(C`undef\*(C'\fR if |
638 | unsuccessful. |
639 | .Sh "flush" |
640 | .IX Subsection "flush" |
641 | Usage is |
642 | .PP |
643 | .Vb 2 |
644 | \& $z\->flush; |
645 | \& $z\->flush($flush_type); |
646 | .Ve |
647 | .PP |
648 | Flushes any pending compressed data to the output file/buffer. |
649 | .PP |
650 | This method takes an optional parameter, \f(CW$flush_type\fR, that controls |
651 | how the flushing will be carried out. By default the \f(CW$flush_type\fR |
652 | used is \f(CW\*(C`Z_FINISH\*(C'\fR. Other valid values for \f(CW$flush_type\fR are |
653 | \&\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 |
654 | strongly recommended that you only set the \f(CW\*(C`flush_type\*(C'\fR parameter if |
655 | you fully understand the implications of what it does \- overuse of \f(CW\*(C`flush\*(C'\fR |
656 | can seriously degrade the level of compression achieved. See the \f(CW\*(C`zlib\*(C'\fR |
657 | documentation for details. |
658 | .PP |
659 | Returns true on success. |
660 | .Sh "tell" |
661 | .IX Subsection "tell" |
662 | Usage is |
663 | .PP |
664 | .Vb 2 |
665 | \& $z\->tell() |
666 | \& tell $z |
667 | .Ve |
668 | .PP |
669 | Returns the uncompressed file offset. |
670 | .Sh "eof" |
671 | .IX Subsection "eof" |
672 | Usage is |
673 | .PP |
674 | .Vb 2 |
675 | \& $z\->eof(); |
676 | \& eof($z); |
677 | .Ve |
678 | .PP |
679 | Returns true if the \f(CW\*(C`close\*(C'\fR method has been called. |
680 | .Sh "seek" |
681 | .IX Subsection "seek" |
682 | .Vb 2 |
683 | \& $z\->seek($position, $whence); |
684 | \& seek($z, $position, $whence); |
685 | .Ve |
686 | .PP |
687 | Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction |
688 | that it is only legal to seek forward in the output file/buffer. |
689 | It is a fatal error to attempt to seek backward. |
690 | .PP |
691 | Empty parts of the file/buffer will have \s-1NULL\s0 (0x00) bytes written to them. |
692 | .PP |
693 | The \f(CW$whence\fR parameter takes one the usual values, namely \s-1SEEK_SET\s0, |
694 | \&\s-1SEEK_CUR\s0 or \s-1SEEK_END\s0. |
695 | .PP |
696 | Returns 1 on success, 0 on failure. |
697 | .Sh "binmode" |
698 | .IX Subsection "binmode" |
699 | Usage is |
700 | .PP |
701 | .Vb 2 |
702 | \& $z\->binmode |
703 | \& binmode $z ; |
704 | .Ve |
705 | .PP |
706 | This is a noop provided for completeness. |
707 | .Sh "opened" |
708 | .IX Subsection "opened" |
709 | .Vb 1 |
710 | \& $z\->opened() |
711 | .Ve |
712 | .PP |
713 | Returns true if the object currently refers to a opened file/buffer. |
714 | .Sh "autoflush" |
715 | .IX Subsection "autoflush" |
716 | .Vb 2 |
717 | \& my $prev = $z\->autoflush() |
718 | \& my $prev = $z\->autoflush(EXPR) |
719 | .Ve |
720 | .PP |
721 | If the \f(CW$z\fR object is associated with a file or a filehandle, this method |
722 | returns the current autoflush setting for the underlying filehandle. If |
723 | \&\f(CW\*(C`EXPR\*(C'\fR is present, and is non\-zero, it will enable flushing after every |
724 | write/print operation. |
725 | .PP |
726 | If \f(CW$z\fR is associated with a buffer, this method has no effect and always |
727 | returns \f(CW\*(C`undef\*(C'\fR. |
728 | .PP |
729 | \&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or |
730 | retrieve the autoflush setting. |
731 | .Sh "input_line_number" |
732 | .IX Subsection "input_line_number" |
733 | .Vb 2 |
734 | \& $z\->input_line_number() |
735 | \& $z\->input_line_number(EXPR) |
736 | .Ve |
737 | .PP |
738 | This method always returns \f(CW\*(C`undef\*(C'\fR when compressing. |
739 | .Sh "fileno" |
740 | .IX Subsection "fileno" |
741 | .Vb 2 |
742 | \& $z\->fileno() |
743 | \& fileno($z) |
744 | .Ve |
745 | .PP |
746 | If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR |
747 | will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is |
748 | called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR. |
749 | .PP |
750 | If the \f(CW$z\fR object is is associated with a buffer, this method will return |
751 | \&\f(CW\*(C`undef\*(C'\fR. |
752 | .Sh "close" |
753 | .IX Subsection "close" |
754 | .Vb 2 |
755 | \& $z\->close() ; |
756 | \& close $z ; |
757 | .Ve |
758 | .PP |
759 | Flushes any pending compressed data and then closes the output file/buffer. |
760 | .PP |
761 | For most versions of Perl this method will be automatically invoked if |
762 | the IO::Compress::Deflate object is destroyed (either explicitly or by the |
763 | variable with the reference to the object going out of scope). The |
764 | exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In |
765 | these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but |
766 | not until global destruction of all live objects when the program is |
767 | terminating. |
768 | .PP |
769 | Therefore, if you want your scripts to be able to run on all versions |
770 | of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic |
771 | closing. |
772 | .PP |
773 | Returns true on success, otherwise 0. |
774 | .PP |
775 | If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Compress::Deflate |
776 | object was created, and the object is associated with a file, the |
777 | underlying file will also be closed. |
778 | .Sh "newStream([\s-1OPTS\s0])" |
779 | .IX Subsection "newStream([OPTS])" |
780 | Usage is |
781 | .PP |
782 | .Vb 1 |
783 | \& $z\->newStream( [OPTS] ) |
784 | .Ve |
785 | .PP |
786 | Closes the current compressed data stream and starts a new one. |
787 | .PP |
788 | \&\s-1OPTS\s0 consists of any of the the options that are available when creating |
789 | the \f(CW$z\fR object. |
790 | .PP |
791 | See the \*(L"Constructor Options\*(R" section for more details. |
792 | .Sh "deflateParams" |
793 | .IX Subsection "deflateParams" |
794 | Usage is |
795 | .PP |
796 | .Vb 1 |
797 | \& $z\->deflateParams |
798 | .Ve |
799 | .PP |
800 | \&\s-1TODO\s0 |
801 | .SH "Importing" |
802 | .IX Header "Importing" |
803 | A number of symbolic constants are required by some methods in |
804 | \&\f(CW\*(C`IO::Compress::Deflate\*(C'\fR. None are imported by default. |
805 | .IP ":all" 5 |
806 | .IX Item ":all" |
807 | Imports \f(CW\*(C`deflate\*(C'\fR, \f(CW$DeflateError\fR and all symbolic |
808 | constants that can be used by \f(CW\*(C`IO::Compress::Deflate\*(C'\fR. Same as doing this |
809 | .Sp |
810 | .Vb 1 |
811 | \& use IO::Compress::Deflate qw(deflate $DeflateError :constants) ; |
812 | .Ve |
813 | .IP ":constants" 5 |
814 | .IX Item ":constants" |
815 | Import all symbolic constants. Same as doing this |
816 | .Sp |
817 | .Vb 1 |
818 | \& use IO::Compress::Deflate qw(:flush :level :strategy) ; |
819 | .Ve |
820 | .IP ":flush" 5 |
821 | .IX Item ":flush" |
822 | These symbolic constants are used by the \f(CW\*(C`flush\*(C'\fR method. |
823 | .Sp |
824 | .Vb 6 |
825 | \& Z_NO_FLUSH |
826 | \& Z_PARTIAL_FLUSH |
827 | \& Z_SYNC_FLUSH |
828 | \& Z_FULL_FLUSH |
829 | \& Z_FINISH |
830 | \& Z_BLOCK |
831 | .Ve |
832 | .IP ":level" 5 |
833 | .IX Item ":level" |
834 | These symbolic constants are used by the \f(CW\*(C`Level\*(C'\fR option in the constructor. |
835 | .Sp |
836 | .Vb 4 |
837 | \& Z_NO_COMPRESSION |
838 | \& Z_BEST_SPEED |
839 | \& Z_BEST_COMPRESSION |
840 | \& Z_DEFAULT_COMPRESSION |
841 | .Ve |
842 | .IP ":strategy" 5 |
843 | .IX Item ":strategy" |
844 | These symbolic constants are used by the \f(CW\*(C`Strategy\*(C'\fR option in the constructor. |
845 | .Sp |
846 | .Vb 5 |
847 | \& Z_FILTERED |
848 | \& Z_HUFFMAN_ONLY |
849 | \& Z_RLE |
850 | \& Z_FIXED |
851 | \& Z_DEFAULT_STRATEGY |
852 | .Ve |
853 | .SH "EXAMPLES" |
854 | .IX Header "EXAMPLES" |
855 | .Sh "Apache::GZip Revisited" |
856 | .IX Subsection "Apache::GZip Revisited" |
857 | See IO::Compress::FAQ |
858 | .Sh "Working with Net::FTP" |
859 | .IX Subsection "Working with Net::FTP" |
860 | See IO::Compress::FAQ |
861 | .SH "SEE ALSO" |
862 | .IX Header "SEE ALSO" |
863 | Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip, 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 |
864 | .PP |
865 | Compress::Zlib::FAQ |
866 | .PP |
867 | File::GlobMapper, Archive::Zip, |
868 | Archive::Tar, |
869 | IO::Zlib |
870 | .PP |
871 | For \s-1RFC\s0 1950, 1951 and 1952 see |
872 | \&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR, |
873 | \&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and |
874 | \&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR |
875 | .PP |
876 | The \fIzlib\fR compression library was written by Jean-loup Gailly |
877 | \&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR. |
878 | .PP |
879 | The primary site for the \fIzlib\fR compression library is |
880 | \&\fIhttp://www.zlib.org\fR. |
881 | .PP |
882 | The primary site for gzip is \fIhttp://www.gzip.org\fR. |
883 | .SH "AUTHOR" |
884 | .IX Header "AUTHOR" |
885 | This module was written by Paul Marquess, \fIpmqs@cpan.org\fR. |
886 | .SH "MODIFICATION HISTORY" |
887 | .IX Header "MODIFICATION HISTORY" |
888 | See the Changes file. |
889 | .SH "COPYRIGHT AND LICENSE" |
890 | .IX Header "COPYRIGHT AND LICENSE" |
891 | Copyright (c) 2005\-2009 Paul Marquess. All rights reserved. |
892 | .PP |
893 | This program is free software; you can redistribute it and/or |
894 | modify it under the same terms as Perl itself. |