1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
4 .\" ========================================================================
5 .de Sh \" Subsection heading
13 .de Sp \" Vertical space (when we can't use .PP)
17 .de Vb \" Begin verbatim text
22 .de Ve \" End verbatim text
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<>.
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
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
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.
57 . tm Index:\\$1\t\\n%\t"\\$2"
63 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
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
79 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
85 . \" simple accents for nroff and troff
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'
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 \
129 .\" ========================================================================
131 .IX Title "IO::Compress::Zip 3"
132 .TH IO::Compress::Zip 3 "2009-11-09" "perl v5.8.7" "User Contributed Perl Documentation"
134 IO::Compress::Zip \- Write zip files/buffers
136 .IX Header "SYNOPSIS"
138 \& use IO::Compress::Zip qw(zip $ZipError) ;
142 \& my $status = zip $input => $output [,OPTS]
143 \& or die "zip failed: $ZipError\en";
147 \& my $z = new IO::Compress::Zip $output [,OPTS]
148 \& or die "zip failed: $ZipError\en";
152 \& $z\->print($string);
153 \& $z\->printf($format, $string);
154 \& $z\->write($string);
155 \& $z\->syswrite($string [, $length, $offset]);
159 \& $z\->seek($position, $whence);
164 \& $z\->input_line_number();
165 \& $z\->newStream( [OPTS] );
169 \& $z\->deflateParams();
186 \& printf $z $format, $string;
189 \& seek $z, $position, $whence
195 .IX Header "DESCRIPTION"
196 This module provides a Perl interface that allows writing zip
197 compressed data to files or buffer.
199 The primary purpose of this module is to provide streaming write access to
200 zip files and buffers. It is not a general-purpose file archiver. If that
201 is what you want, check out \f(CW\*(C`Archive::Zip\*(C'\fR.
203 At present three compression methods are supported by IO::Compress::Zip,
204 namely Store (no compression at all), Deflate and Bzip2.
206 Note that to create Bzip2 content, the module \f(CW\*(C`IO::Compress::Bzip2\*(C'\fR must
209 For reading zip files/buffers, see the companion module
210 IO::Uncompress::Unzip.
211 .SH "Functional Interface"
212 .IX Header "Functional Interface"
213 A top-level function, \f(CW\*(C`zip\*(C'\fR, is provided to carry out
214 \&\*(L"one\-shot\*(R" compression between buffers and/or files. For finer
215 control over the compression process, see the \*(L"\s-1OO\s0 Interface\*(R"
219 \& use IO::Compress::Zip qw(zip $ZipError) ;
223 \& zip $input => $output [,OPTS]
224 \& or die "zip failed: $ZipError\en";
227 The functional interface needs Perl5.005 or better.
228 .ie n .Sh "zip $input\fP => \f(CW$output [, \s-1OPTS\s0]"
229 .el .Sh "zip \f(CW$input\fP => \f(CW$output\fP [, \s-1OPTS\s0]"
230 .IX Subsection "zip $input => $output [, OPTS]"
231 \&\f(CW\*(C`zip\*(C'\fR expects at least two parameters, \f(CW$input\fR and \f(CW$output\fR.
233 \fIThe \f(CI$input\fI parameter\fR
234 .IX Subsection "The $input parameter"
236 The parameter, \f(CW$input\fR, is used to define the source of
237 the uncompressed data.
239 It can take one of the following forms:
241 .IX Item "A filename"
242 If the \f(CW$input\fR parameter is a simple scalar, it is assumed to be a
243 filename. This file will be opened for reading and the input data
244 will be read from it.
246 .IX Item "A filehandle"
247 If the \f(CW$input\fR parameter is a filehandle, the input data will be
249 The string '\-' can be used as an alias for standard input.
250 .IP "A scalar reference" 5
251 .IX Item "A scalar reference"
252 If \f(CW$input\fR is a scalar reference, the input data will be read
253 from \f(CW$$input\fR.
254 .IP "An array reference" 5
255 .IX Item "An array reference"
256 If \f(CW$input\fR is an array reference, each element in the array must be a
259 The input data will be read from each file in turn.
261 The complete array will be walked to ensure that it only
262 contains valid filenames before any data is compressed.
263 .IP "An Input FileGlob string" 5
264 .IX Item "An Input FileGlob string"
265 If \f(CW$input\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
266 \&\f(CW\*(C`zip\*(C'\fR will assume that it is an \fIinput fileglob string\fR. The
267 input is the list of files that match the fileglob.
269 If the fileglob does not match any files ...
271 See File::GlobMapper for more details.
273 If the \f(CW$input\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
275 In addition, if \f(CW$input\fR is a simple filename, the default values for
276 the \f(CW\*(C`Name\*(C'\fR, \f(CW\*(C`Time\*(C'\fR, \f(CW\*(C`ExtAttr\*(C'\fR and \f(CW\*(C`exTime\*(C'\fR options will be sourced from that file.
278 If you do not want to use these defaults they can be overridden by
279 explicitly setting the \f(CW\*(C`Name\*(C'\fR, \f(CW\*(C`Time\*(C'\fR, \f(CW\*(C`ExtAttr\*(C'\fR and \f(CW\*(C`exTime\*(C'\fR options or by setting the
280 \&\f(CW\*(C`Minimal\*(C'\fR parameter.
282 \fIThe \f(CI$output\fI parameter\fR
283 .IX Subsection "The $output parameter"
285 The parameter \f(CW$output\fR is used to control the destination of the
286 compressed data. This parameter can take one of these forms.
288 .IX Item "A filename"
289 If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a
290 filename. This file will be opened for writing and the compressed
291 data will be written to it.
293 .IX Item "A filehandle"
294 If the \f(CW$output\fR parameter is a filehandle, the compressed data
295 will be written to it.
296 The string '\-' can be used as an alias for standard output.
297 .IP "A scalar reference" 5
298 .IX Item "A scalar reference"
299 If \f(CW$output\fR is a scalar reference, the compressed data will be
300 stored in \f(CW$$output\fR.
301 .IP "An Array Reference" 5
302 .IX Item "An Array Reference"
303 If \f(CW$output\fR is an array reference, the compressed data will be
304 pushed onto the array.
305 .IP "An Output FileGlob" 5
306 .IX Item "An Output FileGlob"
307 If \f(CW$output\fR is a string that is delimited by the characters \*(L"<\*(R" and \*(L">\*(R"
308 \&\f(CW\*(C`zip\*(C'\fR will assume that it is an \fIoutput fileglob string\fR. The
309 output is the list of files that match the fileglob.
311 When \f(CW$output\fR is an fileglob string, \f(CW$input\fR must also be a fileglob
312 string. Anything else is an error.
314 If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`undef\*(C'\fR will be returned.
316 .IX Subsection "Notes"
317 When \f(CW$input\fR maps to multiple files/buffers and \f(CW$output\fR is a single
318 file/buffer the input files/buffers will each be stored
319 in \f(CW$output\fR as a distinct entry.
320 .Sh "Optional Parameters"
321 .IX Subsection "Optional Parameters"
322 Unless specified below, the optional parameters for \f(CW\*(C`zip\*(C'\fR,
323 \&\f(CW\*(C`OPTS\*(C'\fR, are the same as those used with the \s-1OO\s0 interface defined in the
324 \&\*(L"Constructor Options\*(R" section below.
325 .ie n .IP """AutoClose => 0|1""" 5
326 .el .IP "\f(CWAutoClose => 0|1\fR" 5
327 .IX Item "AutoClose => 0|1"
328 This option applies to any input or output data streams to
329 \&\f(CW\*(C`zip\*(C'\fR that are filehandles.
331 If \f(CW\*(C`AutoClose\*(C'\fR is specified, and the value is true, it will result in all
332 input and/or output filehandles being closed once \f(CW\*(C`zip\*(C'\fR has
335 This parameter defaults to 0.
336 .ie n .IP """BinModeIn => 0|1""" 5
337 .el .IP "\f(CWBinModeIn => 0|1\fR" 5
338 .IX Item "BinModeIn => 0|1"
339 When reading from a file or filehandle, set \f(CW\*(C`binmode\*(C'\fR before reading.
342 .ie n .IP """Append => 0|1""" 5
343 .el .IP "\f(CWAppend => 0|1\fR" 5
344 .IX Item "Append => 0|1"
345 The behaviour of this option is dependent on the type of output data
350 If \f(CW\*(C`Append\*(C'\fR is enabled, all compressed data will be append to the end of
351 the output buffer. Otherwise the output buffer will be cleared before any
352 compressed data is written to it.
354 .IX Item "A Filename"
355 If \f(CW\*(C`Append\*(C'\fR is enabled, the file will be opened in append mode. Otherwise
356 the contents of the file, if any, will be truncated before any compressed
357 data is written to it.
358 .IP "* A Filehandle" 5
359 .IX Item "A Filehandle"
360 If \f(CW\*(C`Append\*(C'\fR is enabled, the filehandle will be positioned to the end of
361 the file via a call to \f(CW\*(C`seek\*(C'\fR before any compressed data is
362 written to it. Otherwise the file pointer will not be moved.
366 When \f(CW\*(C`Append\*(C'\fR is specified, and set to true, it will \fIappend\fR all compressed
367 data to the output data stream.
369 So when the output is a filehandle it will carry out a seek to the eof
370 before writing any compressed data. If the output is a filename, it will be opened for
371 appending. If the output is a buffer, all compressed data will be appened to
374 Conversely when \f(CW\*(C`Append\*(C'\fR is not specified, or it is present and is set to
375 false, it will operate as follows.
377 When the output is a filename, it will truncate the contents of the file
378 before writing any compressed data. If the output is a filehandle
379 its position will not be changed. If the output is a buffer, it will be
380 wiped before any compressed data is output.
385 .IX Subsection "Examples"
386 To read the contents of the file \f(CW\*(C`file1.txt\*(C'\fR and write the compressed
387 data to the file \f(CW\*(C`file1.txt.zip\*(C'\fR.
392 \& use IO::Compress::Zip qw(zip $ZipError) ;
396 \& my $input = "file1.txt";
397 \& zip $input => "$input.zip"
398 \& or die "zip failed: $ZipError\en";
401 To read from an existing Perl filehandle, \f(CW$input\fR, and write the
402 compressed data to a buffer, \f(CW$buffer\fR.
407 \& use IO::Compress::Zip qw(zip $ZipError) ;
412 \& my $input = new IO::File "<file1.txt"
413 \& or die "Cannot open 'file1.txt': $!\en" ;
415 \& zip $input => \e$buffer
416 \& or die "zip failed: $ZipError\en";
419 To compress all files in the directory \*(L"/my/home\*(R" that match \*(L"*.txt\*(R"
420 and store the compressed data in the same directory
425 \& use IO::Compress::Zip qw(zip $ZipError) ;
429 \& zip '</my/home/*.txt>' => '<*.zip>'
430 \& or die "zip failed: $ZipError\en";
433 and if you want to compress each file one at a time, this will do the trick
438 \& use IO::Compress::Zip qw(zip $ZipError) ;
442 \& for my $input ( glob "/my/home/*.txt" )
444 \& my $output = "$input.zip" ;
445 \& zip $input => $output
446 \& or die "Error compressing '$input': $ZipError\en";
450 .IX Header "OO Interface"
452 .IX Subsection "Constructor"
453 The format of the constructor for \f(CW\*(C`IO::Compress::Zip\*(C'\fR is shown below
456 \& my $z = new IO::Compress::Zip $output [,OPTS]
457 \& or die "IO::Compress::Zip failed: $ZipError\en";
460 It returns an \f(CW\*(C`IO::Compress::Zip\*(C'\fR object on success and undef on failure.
461 The variable \f(CW$ZipError\fR will contain an error message on failure.
463 If you are running Perl 5.005 or better the object, \f(CW$z\fR, returned from
464 IO::Compress::Zip can be used exactly like an IO::File filehandle.
465 This means that all normal output file operations can be carried out
467 For example, to write to a compressed file/buffer you can use either of
471 \& $z\->print("hello world\en");
472 \& print $z "hello world\en";
475 The mandatory parameter \f(CW$output\fR is used to control the destination
476 of the compressed data. This parameter can take one of these forms.
478 .IX Item "A filename"
479 If the \f(CW$output\fR parameter is a simple scalar, it is assumed to be a
480 filename. This file will be opened for writing and the compressed data
481 will be written to it.
483 .IX Item "A filehandle"
484 If the \f(CW$output\fR parameter is a filehandle, the compressed data will be
486 The string '\-' can be used as an alias for standard output.
487 .IP "A scalar reference" 5
488 .IX Item "A scalar reference"
489 If \f(CW$output\fR is a scalar reference, the compressed data will be stored
492 If the \f(CW$output\fR parameter is any other type, \f(CW\*(C`IO::Compress::Zip\*(C'\fR::new will
494 .Sh "Constructor Options"
495 .IX Subsection "Constructor Options"
496 \&\f(CW\*(C`OPTS\*(C'\fR is any combination of the following options:
497 .ie n .IP """AutoClose => 0|1""" 5
498 .el .IP "\f(CWAutoClose => 0|1\fR" 5
499 .IX Item "AutoClose => 0|1"
500 This option is only valid when the \f(CW$output\fR parameter is a filehandle. If
501 specified, and the value is true, it will result in the \f(CW$output\fR being
502 closed once either the \f(CW\*(C`close\*(C'\fR method is called or the \f(CW\*(C`IO::Compress::Zip\*(C'\fR
505 This parameter defaults to 0.
506 .ie n .IP """Append => 0|1""" 5
507 .el .IP "\f(CWAppend => 0|1\fR" 5
508 .IX Item "Append => 0|1"
509 Opens \f(CW$output\fR in append mode.
511 The behaviour of this option is dependent on the type of \f(CW$output\fR.
515 If \f(CW$output\fR is a buffer and \f(CW\*(C`Append\*(C'\fR is enabled, all compressed data
516 will be append to the end of \f(CW$output\fR. Otherwise \f(CW$output\fR will be
517 cleared before any data is written to it.
519 .IX Item "A Filename"
520 If \f(CW$output\fR is a filename and \f(CW\*(C`Append\*(C'\fR is enabled, the file will be
521 opened in append mode. Otherwise the contents of the file, if any, will be
522 truncated before any compressed data is written to it.
523 .IP "* A Filehandle" 5
524 .IX Item "A Filehandle"
525 If \f(CW$output\fR is a filehandle, the file pointer will be positioned to the
526 end of the file via a call to \f(CW\*(C`seek\*(C'\fR before any compressed data is written
527 to it. Otherwise the file pointer will not be moved.
531 This parameter defaults to 0.
533 .ie n .IP """Name => $string""" 5
534 .el .IP "\f(CWName => $string\fR" 5
535 .IX Item "Name => $string"
536 Stores the contents of \f(CW$string\fR in the zip filename header field. If
537 \&\f(CW\*(C`Name\*(C'\fR is not specified, no zip filename field will be created.
538 .ie n .IP """Time => $number""" 5
539 .el .IP "\f(CWTime => $number\fR" 5
540 .IX Item "Time => $number"
541 Sets the last modified time field in the zip header to \f(CW$number\fR.
543 This field defaults to the time the \f(CW\*(C`IO::Compress::Zip\*(C'\fR object was created
544 if this option is not specified.
545 .ie n .IP """ExtAttr => $attr""" 5
546 .el .IP "\f(CWExtAttr => $attr\fR" 5
547 .IX Item "ExtAttr => $attr"
548 This option controls the \*(L"external file attributes\*(R" field in the central
549 header of the zip file. This is a 4 byte field.
551 If you are running a Unix derivative this value defaults to
557 This should allow read/write access to any files that are extracted from
560 For all other systems it defaults to 0.
561 .ie n .IP """exTime => [$atime, $mtime, $ctime]""" 5
562 .el .IP "\f(CWexTime => [$atime, $mtime, $ctime]\fR" 5
563 .IX Item "exTime => [$atime, $mtime, $ctime]"
564 This option expects an array reference with exactly three elements:
565 \&\f(CW$atime\fR, \f(CW\*(C`mtime\*(C'\fR and \f(CW$ctime\fR. These correspond to the last access
566 time, last modification time and creation time respectively.
568 It uses these values to set the extended timestamp field (\s-1ID\s0 is \*(L"\s-1UT\s0\*(R") in
569 the local zip header using the three values, \f(CW$atime\fR, \f(CW$mtime\fR, \f(CW$ctime\fR. In
570 addition it sets the extended timestamp field in the central zip header
571 using \f(CW$mtime\fR.
573 If any of the three values is \f(CW\*(C`undef\*(C'\fR that time value will not be used.
574 So, for example, to set only the \f(CW$mtime\fR you would use this
577 \& exTime => [undef, $mtime, undef]
580 If the \f(CW\*(C`Minimal\*(C'\fR option is set to true, this option will be ignored.
582 By default no extended time field is created.
583 .ie n .IP """exUnix2 => [$uid, $gid]""" 5
584 .el .IP "\f(CWexUnix2 => [$uid, $gid]\fR" 5
585 .IX Item "exUnix2 => [$uid, $gid]"
586 This option expects an array reference with exactly two elements: \f(CW$uid\fR
587 and \f(CW$gid\fR. These values correspond to the numeric user \s-1ID\s0 and group \s-1ID\s0
588 of the owner of the files respectively.
590 When the \f(CW\*(C`exUnix2\*(C'\fR option is present it will trigger the creation of a
591 Unix2 extra field (\s-1ID\s0 is \*(L"Ux\*(R") in the local zip. This will be populated
592 with \f(CW$uid\fR and \f(CW$gid\fR. In addition an empty Unix2 extra field will also
593 be created in the central zip header
595 If the \f(CW\*(C`Minimal\*(C'\fR option is set to true, this option will be ignored.
597 By default no Unix2 extra field is created.
598 .ie n .IP """Comment => $comment""" 5
599 .el .IP "\f(CWComment => $comment\fR" 5
600 .IX Item "Comment => $comment"
601 Stores the contents of \f(CW$comment\fR in the Central File Header of
604 By default, no comment field is written to the zip file.
605 .ie n .IP """ZipComment => $comment""" 5
606 .el .IP "\f(CWZipComment => $comment\fR" 5
607 .IX Item "ZipComment => $comment"
608 Stores the contents of \f(CW$comment\fR in the End of Central Directory record
611 By default, no comment field is written to the zip file.
612 .ie n .IP """Method => $method""" 5
613 .el .IP "\f(CWMethod => $method\fR" 5
614 .IX Item "Method => $method"
615 Controls which compression method is used. At present three compression
616 methods are supported, namely Store (no compression at all), Deflate and
619 The symbols, \s-1ZIP_CM_STORE\s0, \s-1ZIP_CM_DEFLATE\s0 and \s-1ZIP_CM_BZIP2\s0 are used to
620 select the compression method.
622 These constants are not imported by \f(CW\*(C`IO::Compress::Zip\*(C'\fR by default.
625 \& use IO::Compress::Zip qw(:zip_method);
626 \& use IO::Compress::Zip qw(:constants);
627 \& use IO::Compress::Zip qw(:all);
630 Note that to create Bzip2 content, the module \f(CW\*(C`IO::Compress::Bzip2\*(C'\fR must
631 be installed. A fatal error will be thrown if you attempt to create Bzip2
632 content when \f(CW\*(C`IO::Compress::Bzip2\*(C'\fR is not available.
634 The default method is \s-1ZIP_CM_DEFLATE\s0.
635 .ie n .IP """Stream => 0|1""" 5
636 .el .IP "\f(CWStream => 0|1\fR" 5
637 .IX Item "Stream => 0|1"
638 This option controls whether the zip file/buffer output is created in
641 Note that when outputting to a file with streaming mode disabled (\f(CW\*(C`Stream\*(C'\fR
642 is 0), the output file must be seekable.
645 .ie n .IP """Zip64 => 0|1""" 5
646 .el .IP "\f(CWZip64 => 0|1\fR" 5
647 .IX Item "Zip64 => 0|1"
648 Create a Zip64 zip file/buffer. This option should only be used if you want
649 to store files larger than 4 Gig.
651 If you intend to manipulate the Zip64 zip files created with this module
652 using an external zip/unzip make sure that it supports Zip64.
654 In particular, if you are using Info-Zip you need to have zip version 3.x
655 or better to update a Zip64 archive and unzip version 6.x to read a zip64
659 .ie n .IP """TextFlag => 0|1""" 5
660 .el .IP "\f(CWTextFlag => 0|1\fR" 5
661 .IX Item "TextFlag => 0|1"
662 This parameter controls the setting of a bit in the zip central header. It
663 is used to signal that the data stored in the zip file/buffer is probably
667 .ie n .IP """ExtraFieldLocal => $data""\fR =item \f(CW""ExtraFieldCentral => $data""" 5
668 .el .IP "\f(CWExtraFieldLocal => $data\fR =item \f(CWExtraFieldCentral => $data\fR" 5
669 .IX Item "ExtraFieldLocal => $data =item ExtraFieldCentral => $data"
670 The \f(CW\*(C`ExtraFieldLocal\*(C'\fR option is used to store additional metadata in the
671 local header for the zip file/buffer. The \f(CW\*(C`ExtraFieldCentral\*(C'\fR does the
672 same for the matching central header.
674 An extra field consists of zero or more subfields. Each subfield consists
675 of a two byte header followed by the subfield data.
677 The list of subfields can be supplied in any of the following formats
680 \& ExtraFieldLocal => [$id1, $data1,
687 \& ExtraFieldLocal => [ [$id1 => $data1],
694 \& ExtraFieldLocal => { $id1 => $data1,
700 Where \f(CW$id1\fR, \f(CW$id2\fR are two byte subfield \s-1ID\s0's.
702 If you use the hash syntax, you have no control over the order in which
703 the ExtraSubFields are stored, plus you cannot have SubFields with
706 Alternatively the list of subfields can by supplied as a scalar, thus
709 \& ExtraField => $rawdata
712 The Extended Time field (\s-1ID\s0 \*(L"\s-1UT\s0\*(R"), set using the \f(CW\*(C`exTime\*(C'\fR option, and the
713 Unix2 extra field (\s-1ID\s0 "Ux), set using the \f(CW\*(C`exUnix2\*(C'\fR option, are examples
716 If the \f(CW\*(C`Minimal\*(C'\fR option is set to true, this option will be ignored.
718 The maximum size of an extra field 65535 bytes.
719 .ie n .IP """Minimal => 1|0""" 5
720 .el .IP "\f(CWMinimal => 1|0\fR" 5
721 .IX Item "Minimal => 1|0"
722 If specified, this option will disable the creation of all extra fields
723 in the zip local and central headers. So the \f(CW\*(C`exTime\*(C'\fR, \f(CW\*(C`exUnix2\*(C'\fR,
724 \&\f(CW\*(C`ExtraFieldLocal\*(C'\fR and \f(CW\*(C`ExtraFieldCentral\*(C'\fR options will be ignored.
726 This parameter defaults to 0.
727 .ie n .IP """BlockSize100K => number""" 5
728 .el .IP "\f(CWBlockSize100K => number\fR" 5
729 .IX Item "BlockSize100K => number"
730 Specify the number of 100K blocks bzip2 uses during compression.
732 Valid values are from 1 to 9, where 9 is best compression.
734 This option is only valid if the \f(CW\*(C`Method\*(C'\fR is \s-1ZIP_CM_BZIP2\s0. It is ignored
738 .ie n .IP """WorkFactor => number""" 5
739 .el .IP "\f(CWWorkFactor => number\fR" 5
740 .IX Item "WorkFactor => number"
741 Specifies how much effort bzip2 should take before resorting to a slower
742 fallback compression algorithm.
744 Valid values range from 0 to 250, where 0 means use the default value 30.
746 This option is only valid if the \f(CW\*(C`Method\*(C'\fR is \s-1ZIP_CM_BZIP2\s0. It is ignored
752 Defines the compression level used by zlib. The value should either be
753 a number between 0 and 9 (0 means no compression and 9 is maximum
754 compression), or one of the symbolic constants defined below.
759 \& Z_BEST_COMPRESSION
760 \& Z_DEFAULT_COMPRESSION
763 The default is Z_DEFAULT_COMPRESSION.
765 Note, these constants are not imported by \f(CW\*(C`IO::Compress::Zip\*(C'\fR by default.
768 \& use IO::Compress::Zip qw(:strategy);
769 \& use IO::Compress::Zip qw(:constants);
770 \& use IO::Compress::Zip qw(:all);
774 Defines the strategy used to tune the compression. Use one of the symbolic
775 constants defined below.
782 \& Z_DEFAULT_STRATEGY
785 The default is Z_DEFAULT_STRATEGY.
786 .ie n .IP """Strict => 0|1""" 5
787 .el .IP "\f(CWStrict => 0|1\fR" 5
788 .IX Item "Strict => 0|1"
789 This is a placeholder option.
791 .IX Subsection "Examples"
796 .IX Subsection "print"
804 Compresses and outputs the contents of the \f(CW$data\fR parameter. This
805 has the same behaviour as the \f(CW\*(C`print\*(C'\fR built\-in.
807 Returns true if successful.
809 .IX Subsection "printf"
813 \& $z\->printf($format, $data)
814 \& printf $z $format, $data
817 Compresses and outputs the contents of the \f(CW$data\fR parameter.
819 Returns true if successful.
821 .IX Subsection "syswrite"
825 \& $z\->syswrite $data
826 \& $z\->syswrite $data, $length
827 \& $z\->syswrite $data, $length, $offset
830 Compresses and outputs the contents of the \f(CW$data\fR parameter.
832 Returns the number of uncompressed bytes written, or \f(CW\*(C`undef\*(C'\fR if
835 .IX Subsection "write"
840 \& $z\->write $data, $length
841 \& $z\->write $data, $length, $offset
844 Compresses and outputs the contents of the \f(CW$data\fR parameter.
846 Returns the number of uncompressed bytes written, or \f(CW\*(C`undef\*(C'\fR if
849 .IX Subsection "flush"
854 \& $z\->flush($flush_type);
857 Flushes any pending compressed data to the output file/buffer.
859 This method takes an optional parameter, \f(CW$flush_type\fR, that controls
860 how the flushing will be carried out. By default the \f(CW$flush_type\fR
861 used is \f(CW\*(C`Z_FINISH\*(C'\fR. Other valid values for \f(CW$flush_type\fR are
862 \&\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
863 strongly recommended that you only set the \f(CW\*(C`flush_type\*(C'\fR parameter if
864 you fully understand the implications of what it does \- overuse of \f(CW\*(C`flush\*(C'\fR
865 can seriously degrade the level of compression achieved. See the \f(CW\*(C`zlib\*(C'\fR
866 documentation for details.
868 Returns true on success.
870 .IX Subsection "tell"
878 Returns the uncompressed file offset.
888 Returns true if the \f(CW\*(C`close\*(C'\fR method has been called.
890 .IX Subsection "seek"
892 \& $z\->seek($position, $whence);
893 \& seek($z, $position, $whence);
896 Provides a sub-set of the \f(CW\*(C`seek\*(C'\fR functionality, with the restriction
897 that it is only legal to seek forward in the output file/buffer.
898 It is a fatal error to attempt to seek backward.
900 Empty parts of the file/buffer will have \s-1NULL\s0 (0x00) bytes written to them.
902 The \f(CW$whence\fR parameter takes one the usual values, namely \s-1SEEK_SET\s0,
903 \&\s-1SEEK_CUR\s0 or \s-1SEEK_END\s0.
905 Returns 1 on success, 0 on failure.
907 .IX Subsection "binmode"
915 This is a noop provided for completeness.
917 .IX Subsection "opened"
922 Returns true if the object currently refers to a opened file/buffer.
924 .IX Subsection "autoflush"
926 \& my $prev = $z\->autoflush()
927 \& my $prev = $z\->autoflush(EXPR)
930 If the \f(CW$z\fR object is associated with a file or a filehandle, this method
931 returns the current autoflush setting for the underlying filehandle. If
932 \&\f(CW\*(C`EXPR\*(C'\fR is present, and is non\-zero, it will enable flushing after every
933 write/print operation.
935 If \f(CW$z\fR is associated with a buffer, this method has no effect and always
936 returns \f(CW\*(C`undef\*(C'\fR.
938 \&\fBNote\fR that the special variable \f(CW$|\fR \fBcannot\fR be used to set or
939 retrieve the autoflush setting.
940 .Sh "input_line_number"
941 .IX Subsection "input_line_number"
943 \& $z\->input_line_number()
944 \& $z\->input_line_number(EXPR)
947 This method always returns \f(CW\*(C`undef\*(C'\fR when compressing.
949 .IX Subsection "fileno"
955 If the \f(CW$z\fR object is associated with a file or a filehandle, \f(CW\*(C`fileno\*(C'\fR
956 will return the underlying file descriptor. Once the \f(CW\*(C`close\*(C'\fR method is
957 called \f(CW\*(C`fileno\*(C'\fR will return \f(CW\*(C`undef\*(C'\fR.
959 If the \f(CW$z\fR object is is associated with a buffer, this method will return
960 \&\f(CW\*(C`undef\*(C'\fR.
962 .IX Subsection "close"
968 Flushes any pending compressed data and then closes the output file/buffer.
970 For most versions of Perl this method will be automatically invoked if
971 the IO::Compress::Zip object is destroyed (either explicitly or by the
972 variable with the reference to the object going out of scope). The
973 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
974 these cases, the \f(CW\*(C`close\*(C'\fR method will be called automatically, but
975 not until global destruction of all live objects when the program is
978 Therefore, if you want your scripts to be able to run on all versions
979 of Perl, you should call \f(CW\*(C`close\*(C'\fR explicitly and not rely on automatic
982 Returns true on success, otherwise 0.
984 If the \f(CW\*(C`AutoClose\*(C'\fR option has been enabled when the IO::Compress::Zip
985 object was created, and the object is associated with a file, the
986 underlying file will also be closed.
987 .Sh "newStream([\s-1OPTS\s0])"
988 .IX Subsection "newStream([OPTS])"
992 \& $z\->newStream( [OPTS] )
995 Closes the current compressed data stream and starts a new one.
997 \&\s-1OPTS\s0 consists of any of the the options that are available when creating
998 the \f(CW$z\fR object.
1000 See the \*(L"Constructor Options\*(R" section for more details.
1002 .IX Subsection "deflateParams"
1006 \& $z\->deflateParams
1011 .IX Header "Importing"
1012 A number of symbolic constants are required by some methods in
1013 \&\f(CW\*(C`IO::Compress::Zip\*(C'\fR. None are imported by default.
1016 Imports \f(CW\*(C`zip\*(C'\fR, \f(CW$ZipError\fR and all symbolic
1017 constants that can be used by \f(CW\*(C`IO::Compress::Zip\*(C'\fR. Same as doing this
1020 \& use IO::Compress::Zip qw(zip $ZipError :constants) ;
1023 .IX Item ":constants"
1024 Import all symbolic constants. Same as doing this
1027 \& use IO::Compress::Zip qw(:flush :level :strategy :zip_method) ;
1031 These symbolic constants are used by the \f(CW\*(C`flush\*(C'\fR method.
1043 These symbolic constants are used by the \f(CW\*(C`Level\*(C'\fR option in the constructor.
1048 \& Z_BEST_COMPRESSION
1049 \& Z_DEFAULT_COMPRESSION
1052 .IX Item ":strategy"
1053 These symbolic constants are used by the \f(CW\*(C`Strategy\*(C'\fR option in the constructor.
1060 \& Z_DEFAULT_STRATEGY
1063 .IX Item ":zip_method"
1064 These symbolic constants are used by the \f(CW\*(C`Method\*(C'\fR option in the
1073 .IX Header "EXAMPLES"
1074 .Sh "Apache::GZip Revisited"
1075 .IX Subsection "Apache::GZip Revisited"
1076 See IO::Compress::FAQ
1077 .Sh "Working with Net::FTP"
1078 .IX Subsection "Working with Net::FTP"
1079 See IO::Compress::FAQ
1081 .IX Header "SEE ALSO"
1082 Compress::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
1086 File::GlobMapper, Archive::Zip,
1090 For \s-1RFC\s0 1950, 1951 and 1952 see
1091 \&\fIhttp://www.faqs.org/rfcs/rfc1950.html\fR,
1092 \&\fIhttp://www.faqs.org/rfcs/rfc1951.html\fR and
1093 \&\fIhttp://www.faqs.org/rfcs/rfc1952.html\fR
1095 The \fIzlib\fR compression library was written by Jean-loup Gailly
1096 \&\fIgzip@prep.ai.mit.edu\fR and Mark Adler \fImadler@alumni.caltech.edu\fR.
1098 The primary site for the \fIzlib\fR compression library is
1099 \&\fIhttp://www.zlib.org\fR.
1101 The primary site for gzip is \fIhttp://www.gzip.org\fR.
1104 This module was written by Paul Marquess, \fIpmqs@cpan.org\fR.
1105 .SH "MODIFICATION HISTORY"
1106 .IX Header "MODIFICATION HISTORY"
1107 See the Changes file.
1108 .SH "COPYRIGHT AND LICENSE"
1109 .IX Header "COPYRIGHT AND LICENSE"
1110 Copyright (c) 2005\-2009 Paul Marquess. All rights reserved.
1112 This program is free software; you can redistribute it and/or
1113 modify it under the same terms as Perl itself.