1IO::Compress::Zip(3) User Contributed Perl Documentation IO::Compress::Zip(3)
2
3
4
6 IO::Compress::Zip - Write zip files/buffers
7
9 use IO::Compress::Zip qw(zip $ZipError) ;
10
11 my $status = zip $input => $output [,OPTS]
12 or die "zip failed: $ZipError\n";
13
14 my $z = new IO::Compress::Zip $output [,OPTS]
15 or die "zip failed: $ZipError\n";
16
17 $z->print($string);
18 $z->printf($format, $string);
19 $z->write($string);
20 $z->syswrite($string [, $length, $offset]);
21 $z->flush();
22 $z->tell();
23 $z->eof();
24 $z->seek($position, $whence);
25 $z->binmode();
26 $z->fileno();
27 $z->opened();
28 $z->autoflush();
29 $z->input_line_number();
30 $z->newStream( [OPTS] );
31
32 $z->deflateParams();
33
34 $z->close() ;
35
36 $ZipError ;
37
38 # IO::File mode
39
40 print $z $string;
41 printf $z $format, $string;
42 tell $z
43 eof $z
44 seek $z, $position, $whence
45 binmode $z
46 fileno $z
47 close $z ;
48
50 This module provides a Perl interface that allows writing zip
51 compressed data to files or buffer.
52
53 The primary purpose of this module is to provide streaming write access
54 to zip files and buffers. It is not a general-purpose file archiver. If
55 that is what you want, check out "Archive::Zip" or
56 "Archive::Zip::SimpleZip".
57
58 At present three compression methods are supported by
59 IO::Compress::Zip, namely Store (no compression at all), Deflate, Bzip2
60 and LZMA.
61
62 Note that to create Bzip2 content, the module "IO::Compress::Bzip2"
63 must be installed.
64
65 Note that to create LZMA content, the module "IO::Compress::Lzma" must
66 be installed.
67
68 For reading zip files/buffers, see the companion module
69 IO::Uncompress::Unzip.
70
72 A top-level function, "zip", is provided to carry out "one-shot"
73 compression between buffers and/or files. For finer control over the
74 compression process, see the "OO Interface" section.
75
76 use IO::Compress::Zip qw(zip $ZipError) ;
77
78 zip $input_filename_or_reference => $output_filename_or_reference [,OPTS]
79 or die "zip failed: $ZipError\n";
80
81 The functional interface needs Perl5.005 or better.
82
83 zip $input_filename_or_reference => $output_filename_or_reference [, OPTS]
84 "zip" expects at least two parameters, $input_filename_or_reference and
85 $output_filename_or_reference.
86
87 The $input_filename_or_reference parameter
88
89 The parameter, $input_filename_or_reference, is used to define the
90 source of the uncompressed data.
91
92 It can take one of the following forms:
93
94 A filename
95 If the <$input_filename_or_reference> parameter is a simple
96 scalar, it is assumed to be a filename. This file will be opened
97 for reading and the input data will be read from it.
98
99 A filehandle
100 If the $input_filename_or_reference parameter is a filehandle, the
101 input data will be read from it. The string '-' can be used as an
102 alias for standard input.
103
104 A scalar reference
105 If $input_filename_or_reference is a scalar reference, the input
106 data will be read from $$input_filename_or_reference.
107
108 An array reference
109 If $input_filename_or_reference is an array reference, each
110 element in the array must be a filename.
111
112 The input data will be read from each file in turn.
113
114 The complete array will be walked to ensure that it only contains
115 valid filenames before any data is compressed.
116
117 An Input FileGlob string
118 If $input_filename_or_reference is a string that is delimited by
119 the characters "<" and ">" "zip" will assume that it is an input
120 fileglob string. The input is the list of files that match the
121 fileglob.
122
123 See File::GlobMapper for more details.
124
125 If the $input_filename_or_reference parameter is any other type,
126 "undef" will be returned.
127
128 In addition, if $input_filename_or_reference is a simple filename, the
129 default values for the "Name", "Time", "TextFlag", "ExtAttr", "exUnixN"
130 and "exTime" options will be sourced from that file.
131
132 If you do not want to use these defaults they can be overridden by
133 explicitly setting the "Name", "Time", "TextFlag", "ExtAttr", "exUnixN"
134 and "exTime" options or by setting the "Minimal" parameter.
135
136 The $output_filename_or_reference parameter
137
138 The parameter $output_filename_or_reference is used to control the
139 destination of the compressed data. This parameter can take one of
140 these forms.
141
142 A filename
143 If the $output_filename_or_reference parameter is a simple scalar,
144 it is assumed to be a filename. This file will be opened for
145 writing and the compressed data will be written to it.
146
147 A filehandle
148 If the $output_filename_or_reference parameter is a filehandle,
149 the compressed data will be written to it. The string '-' can be
150 used as an alias for standard output.
151
152 A scalar reference
153 If $output_filename_or_reference is a scalar reference, the
154 compressed data will be stored in $$output_filename_or_reference.
155
156 An Array Reference
157 If $output_filename_or_reference is an array reference, the
158 compressed data will be pushed onto the array.
159
160 An Output FileGlob
161 If $output_filename_or_reference is a string that is delimited by
162 the characters "<" and ">" "zip" will assume that it is an output
163 fileglob string. The output is the list of files that match the
164 fileglob.
165
166 When $output_filename_or_reference is an fileglob string,
167 $input_filename_or_reference must also be a fileglob string.
168 Anything else is an error.
169
170 See File::GlobMapper for more details.
171
172 If the $output_filename_or_reference parameter is any other type,
173 "undef" will be returned.
174
175 Notes
176 When $input_filename_or_reference maps to multiple files/buffers and
177 $output_filename_or_reference is a single file/buffer the input
178 files/buffers will each be stored in $output_filename_or_reference as a
179 distinct entry.
180
181 Optional Parameters
182 Unless specified below, the optional parameters for "zip", "OPTS", are
183 the same as those used with the OO interface defined in the
184 "Constructor Options" section below.
185
186 "AutoClose => 0|1"
187 This option applies to any input or output data streams to "zip"
188 that are filehandles.
189
190 If "AutoClose" is specified, and the value is true, it will result
191 in all input and/or output filehandles being closed once "zip" has
192 completed.
193
194 This parameter defaults to 0.
195
196 "BinModeIn => 0|1"
197 This option is now a no-op. All files will be read in binmode.
198
199 "Append => 0|1"
200 The behaviour of this option is dependent on the type of output
201 data stream.
202
203 · A Buffer
204
205 If "Append" is enabled, all compressed data will be append to
206 the end of the output buffer. Otherwise the output buffer
207 will be cleared before any compressed data is written to it.
208
209 · A Filename
210
211 If "Append" is enabled, the file will be opened in append
212 mode. Otherwise the contents of the file, if any, will be
213 truncated before any compressed data is written to it.
214
215 · A Filehandle
216
217 If "Append" is enabled, the filehandle will be positioned to
218 the end of the file via a call to "seek" before any
219 compressed data is written to it. Otherwise the file pointer
220 will not be moved.
221
222 When "Append" is specified, and set to true, it will append all
223 compressed data to the output data stream.
224
225 So when the output is a filehandle it will carry out a seek to the
226 eof before writing any compressed data. If the output is a
227 filename, it will be opened for appending. If the output is a
228 buffer, all compressed data will be appended to the existing
229 buffer.
230
231 Conversely when "Append" is not specified, or it is present and is
232 set to false, it will operate as follows.
233
234 When the output is a filename, it will truncate the contents of
235 the file before writing any compressed data. If the output is a
236 filehandle its position will not be changed. If the output is a
237 buffer, it will be wiped before any compressed data is output.
238
239 Defaults to 0.
240
241 Examples
242 To read the contents of the file "file1.txt" and write the compressed
243 data to the file "file1.txt.zip".
244
245 use strict ;
246 use warnings ;
247 use IO::Compress::Zip qw(zip $ZipError) ;
248
249 my $input = "file1.txt";
250 zip $input => "$input.zip"
251 or die "zip failed: $ZipError\n";
252
253 To read from an existing Perl filehandle, $input, and write the
254 compressed data to a buffer, $buffer.
255
256 use strict ;
257 use warnings ;
258 use IO::Compress::Zip qw(zip $ZipError) ;
259 use IO::File ;
260
261 my $input = new IO::File "<file1.txt"
262 or die "Cannot open 'file1.txt': $!\n" ;
263 my $buffer ;
264 zip $input => \$buffer
265 or die "zip failed: $ZipError\n";
266
267 To create a zip file, "output.zip", that contains the compressed
268 contents of the files "alpha.txt" and "beta.txt"
269
270 use strict ;
271 use warnings ;
272 use IO::Compress::Zip qw(zip $ZipError) ;
273
274 zip [ 'alpha.txt', 'beta.txt' ] => 'output.zip'
275 or die "zip failed: $ZipError\n";
276
277 Alternatively, rather than having to explicitly name each of the files
278 that you want to compress, you could use a fileglob to select all the
279 "txt" files in the current directory, as follows
280
281 use strict ;
282 use warnings ;
283 use IO::Compress::Zip qw(zip $ZipError) ;
284
285 my @files = <*.txt>;
286 zip \@files => 'output.zip'
287 or die "zip failed: $ZipError\n";
288
289 or more succinctly
290
291 zip [ <*.txt> ] => 'output.zip'
292 or die "zip failed: $ZipError\n";
293
295 Constructor
296 The format of the constructor for "IO::Compress::Zip" is shown below
297
298 my $z = new IO::Compress::Zip $output [,OPTS]
299 or die "IO::Compress::Zip failed: $ZipError\n";
300
301 It returns an "IO::Compress::Zip" object on success and undef on
302 failure. The variable $ZipError will contain an error message on
303 failure.
304
305 If you are running Perl 5.005 or better the object, $z, returned from
306 IO::Compress::Zip can be used exactly like an IO::File filehandle.
307 This means that all normal output file operations can be carried out
308 with $z. For example, to write to a compressed file/buffer you can use
309 either of these forms
310
311 $z->print("hello world\n");
312 print $z "hello world\n";
313
314 The mandatory parameter $output is used to control the destination of
315 the compressed data. This parameter can take one of these forms.
316
317 A filename
318 If the $output parameter is a simple scalar, it is assumed to be a
319 filename. This file will be opened for writing and the compressed
320 data will be written to it.
321
322 A filehandle
323 If the $output parameter is a filehandle, the compressed data will
324 be written to it. The string '-' can be used as an alias for
325 standard output.
326
327 A scalar reference
328 If $output is a scalar reference, the compressed data will be
329 stored in $$output.
330
331 If the $output parameter is any other type, "IO::Compress::Zip"::new
332 will return undef.
333
334 Constructor Options
335 "OPTS" is any combination of the following options:
336
337 "AutoClose => 0|1"
338 This option is only valid when the $output parameter is a
339 filehandle. If specified, and the value is true, it will result in
340 the $output being closed once either the "close" method is called
341 or the "IO::Compress::Zip" object is destroyed.
342
343 This parameter defaults to 0.
344
345 "Append => 0|1"
346 Opens $output in append mode.
347
348 The behaviour of this option is dependent on the type of $output.
349
350 · A Buffer
351
352 If $output is a buffer and "Append" is enabled, all
353 compressed data will be append to the end of $output.
354 Otherwise $output will be cleared before any data is written
355 to it.
356
357 · A Filename
358
359 If $output is a filename and "Append" is enabled, the file
360 will be opened in append mode. Otherwise the contents of the
361 file, if any, will be truncated before any compressed data is
362 written to it.
363
364 · A Filehandle
365
366 If $output is a filehandle, the file pointer will be
367 positioned to the end of the file via a call to "seek" before
368 any compressed data is written to it. Otherwise the file
369 pointer will not be moved.
370
371 This parameter defaults to 0.
372
373 "Name => $string"
374 Stores the contents of $string in the zip filename header field.
375
376 If "Name" is not specified and the $input parameter is a filename,
377 the value of $input will be used for the zip filename header
378 field.
379
380 If "Name" is not specified and the $input parameter is not a
381 filename, no zip filename field will be created.
382
383 Note that both the "CanonicalName" and "FilterName" options can
384 modify the value used for the zip filename header field.
385
386 "CanonicalName => 0|1"
387 This option controls whether the filename field in the zip header
388 is normalized into Unix format before being written to the zip
389 file.
390
391 It is recommended that you enable this option unless you really
392 need to create a non-standard Zip file.
393
394 This is what APPNOTE.TXT has to say on what should be stored in
395 the zip filename header field.
396
397 The name of the file, with optional relative path.
398 The path stored should not contain a drive or
399 device letter, or a leading slash. All slashes
400 should be forward slashes '/' as opposed to
401 backwards slashes '\' for compatibility with Amiga
402 and UNIX file systems etc.
403
404 This option defaults to false.
405
406 "FilterName => sub { ... }"
407 This option allow the filename field in the zip header to be
408 modified before it is written to the zip file.
409
410 This option takes a parameter that must be a reference to a sub.
411 On entry to the sub the $_ variable will contain the name to be
412 filtered. If no filename is available $_ will contain an empty
413 string.
414
415 The value of $_ when the sub returns will be stored in the
416 filename header field.
417
418 Note that if "CanonicalName" is enabled, a normalized filename
419 will be passed to the sub.
420
421 If you use "FilterName" to modify the filename, it is your
422 responsibility to keep the filename in Unix format.
423
424 Although this option can be used with the OO interface, it is of
425 most use with the one-shot interface. For example, the code below
426 shows how "FilterName" can be used to remove the path component
427 from a series of filenames before they are stored in $zipfile.
428
429 sub compressTxtFiles
430 {
431 my $zipfile = shift ;
432 my $dir = shift ;
433
434 zip [ <$dir/*.txt> ] => $zipfile,
435 FilterName => sub { s[^$dir/][] } ;
436 }
437
438 "Time => $number"
439 Sets the last modified time field in the zip header to $number.
440
441 This field defaults to the time the "IO::Compress::Zip" object was
442 created if this option is not specified and the $input parameter
443 is not a filename.
444
445 "ExtAttr => $attr"
446 This option controls the "external file attributes" field in the
447 central header of the zip file. This is a 4 byte field.
448
449 If you are running a Unix derivative this value defaults to
450
451 0100644 << 16
452
453 This should allow read/write access to any files that are
454 extracted from the zip file/buffer`.
455
456 For all other systems it defaults to 0.
457
458 "exTime => [$atime, $mtime, $ctime]"
459 This option expects an array reference with exactly three
460 elements: $atime, "mtime" and $ctime. These correspond to the last
461 access time, last modification time and creation time
462 respectively.
463
464 It uses these values to set the extended timestamp field (ID is
465 "UT") in the local zip header using the three values, $atime,
466 $mtime, $ctime. In addition it sets the extended timestamp field
467 in the central zip header using $mtime.
468
469 If any of the three values is "undef" that time value will not be
470 used. So, for example, to set only the $mtime you would use this
471
472 exTime => [undef, $mtime, undef]
473
474 If the "Minimal" option is set to true, this option will be
475 ignored.
476
477 By default no extended time field is created.
478
479 "exUnix2 => [$uid, $gid]"
480 This option expects an array reference with exactly two elements:
481 $uid and $gid. These values correspond to the numeric User ID
482 (UID) and Group ID (GID) of the owner of the files respectively.
483
484 When the "exUnix2" option is present it will trigger the creation
485 of a Unix2 extra field (ID is "Ux") in the local zip header. This
486 will be populated with $uid and $gid. An empty Unix2 extra field
487 will also be created in the central zip header.
488
489 Note - The UID & GID are stored as 16-bit integers in the "Ux"
490 field. Use "exUnixN" if your UID or GID are 32-bit.
491
492 If the "Minimal" option is set to true, this option will be
493 ignored.
494
495 By default no Unix2 extra field is created.
496
497 "exUnixN => [$uid, $gid]"
498 This option expects an array reference with exactly two elements:
499 $uid and $gid. These values correspond to the numeric User ID
500 (UID) and Group ID (GID) of the owner of the files respectively.
501
502 When the "exUnixN" option is present it will trigger the creation
503 of a UnixN extra field (ID is "ux") in both the local and central
504 zip headers. This will be populated with $uid and $gid. The UID
505 & GID are stored as 32-bit integers.
506
507 If the "Minimal" option is set to true, this option will be
508 ignored.
509
510 By default no UnixN extra field is created.
511
512 "Comment => $comment"
513 Stores the contents of $comment in the Central File Header of the
514 zip file.
515
516 By default, no comment field is written to the zip file.
517
518 "ZipComment => $comment"
519 Stores the contents of $comment in the End of Central Directory
520 record of the zip file.
521
522 By default, no comment field is written to the zip file.
523
524 "Method => $method"
525 Controls which compression method is used. At present four
526 compression methods are supported, namely Store (no compression at
527 all), Deflate, Bzip2 and Lzma.
528
529 The symbols, ZIP_CM_STORE, ZIP_CM_DEFLATE, ZIP_CM_BZIP2 and
530 ZIP_CM_LZMA are used to select the compression method.
531
532 These constants are not imported by "IO::Compress::Zip" by
533 default.
534
535 use IO::Compress::Zip qw(:zip_method);
536 use IO::Compress::Zip qw(:constants);
537 use IO::Compress::Zip qw(:all);
538
539 Note that to create Bzip2 content, the module
540 "IO::Compress::Bzip2" must be installed. A fatal error will be
541 thrown if you attempt to create Bzip2 content when
542 "IO::Compress::Bzip2" is not available.
543
544 Note that to create Lzma content, the module "IO::Compress::Lzma"
545 must be installed. A fatal error will be thrown if you attempt to
546 create Lzma content when "IO::Compress::Lzma" is not available.
547
548 The default method is ZIP_CM_DEFLATE.
549
550 "Stream => 0|1"
551 This option controls whether the zip file/buffer output is created
552 in streaming mode.
553
554 Note that when outputting to a file with streaming mode disabled
555 ("Stream" is 0), the output file must be seekable.
556
557 The default is 1.
558
559 "Zip64 => 0|1"
560 Create a Zip64 zip file/buffer. This option is used if you want to
561 store files larger than 4 Gig or store more than 64K files in a
562 single zip archive.
563
564 "Zip64" will be automatically set, as needed, if working with the
565 one-shot interface when the input is either a filename or a scalar
566 reference.
567
568 If you intend to manipulate the Zip64 zip files created with this
569 module using an external zip/unzip, make sure that it supports
570 Zip64.
571
572 In particular, if you are using Info-Zip you need to have zip
573 version 3.x or better to update a Zip64 archive and unzip version
574 6.x to read a zip64 archive.
575
576 The default is 0.
577
578 "TextFlag => 0|1"
579 This parameter controls the setting of a bit in the zip central
580 header. It is used to signal that the data stored in the zip
581 file/buffer is probably text.
582
583 In one-shot mode this flag will be set to true if the Perl "-T"
584 operator thinks the file contains text.
585
586 The default is 0.
587
588 "ExtraFieldLocal => $data"
589 "ExtraFieldCentral => $data"
590 The "ExtraFieldLocal" option is used to store additional metadata
591 in the local header for the zip file/buffer. The
592 "ExtraFieldCentral" does the same for the matching central header.
593
594 An extra field consists of zero or more subfields. Each subfield
595 consists of a two byte header followed by the subfield data.
596
597 The list of subfields can be supplied in any of the following
598 formats
599
600 ExtraFieldLocal => [$id1, $data1,
601 $id2, $data2,
602 ...
603 ]
604
605 ExtraFieldLocal => [ [$id1 => $data1],
606 [$id2 => $data2],
607 ...
608 ]
609
610 ExtraFieldLocal => { $id1 => $data1,
611 $id2 => $data2,
612 ...
613 }
614
615 Where $id1, $id2 are two byte subfield ID's.
616
617 If you use the hash syntax, you have no control over the order in
618 which the ExtraSubFields are stored, plus you cannot have
619 SubFields with duplicate ID.
620
621 Alternatively the list of subfields can by supplied as a scalar,
622 thus
623
624 ExtraField => $rawdata
625
626 In this case "IO::Compress::Zip" will check that $rawdata consists
627 of zero or more conformant sub-fields.
628
629 The Extended Time field (ID "UT"), set using the "exTime" option,
630 and the Unix2 extra field (ID "Ux), set using the "exUnix2"
631 option, are examples of extra fields.
632
633 If the "Minimal" option is set to true, this option will be
634 ignored.
635
636 The maximum size of an extra field 65535 bytes.
637
638 "Minimal => 1|0"
639 If specified, this option will disable the creation of all extra
640 fields in the zip local and central headers. So the "exTime",
641 "exUnix2", "exUnixN", "ExtraFieldLocal" and "ExtraFieldCentral"
642 options will be ignored.
643
644 This parameter defaults to 0.
645
646 "BlockSize100K => number"
647 Specify the number of 100K blocks bzip2 uses during compression.
648
649 Valid values are from 1 to 9, where 9 is best compression.
650
651 This option is only valid if the "Method" is ZIP_CM_BZIP2. It is
652 ignored otherwise.
653
654 The default is 1.
655
656 "WorkFactor => number"
657 Specifies how much effort bzip2 should take before resorting to a
658 slower fallback compression algorithm.
659
660 Valid values range from 0 to 250, where 0 means use the default
661 value 30.
662
663 This option is only valid if the "Method" is ZIP_CM_BZIP2. It is
664 ignored otherwise.
665
666 The default is 0.
667
668 "Preset => number"
669 Used to choose the LZMA compression preset.
670
671 Valid values are 0-9 and "LZMA_PRESET_DEFAULT".
672
673 0 is the fastest compression with the lowest memory usage and the
674 lowest compression.
675
676 9 is the slowest compression with the highest memory usage but
677 with the best compression.
678
679 This option is only valid if the "Method" is ZIP_CM_LZMA. It is
680 ignored otherwise.
681
682 Defaults to "LZMA_PRESET_DEFAULT" (6).
683
684 "Extreme => 0|1"
685 Makes LZMA compression a lot slower, but a small compression gain.
686
687 This option is only valid if the "Method" is ZIP_CM_LZMA. It is
688 ignored otherwise.
689
690 Defaults to 0.
691
692 -Level
693 Defines the compression level used by zlib. The value should
694 either be a number between 0 and 9 (0 means no compression and 9
695 is maximum compression), or one of the symbolic constants defined
696 below.
697
698 Z_NO_COMPRESSION
699 Z_BEST_SPEED
700 Z_BEST_COMPRESSION
701 Z_DEFAULT_COMPRESSION
702
703 The default is Z_DEFAULT_COMPRESSION.
704
705 Note, these constants are not imported by "IO::Compress::Zip" by
706 default.
707
708 use IO::Compress::Zip qw(:strategy);
709 use IO::Compress::Zip qw(:constants);
710 use IO::Compress::Zip qw(:all);
711
712 -Strategy
713 Defines the strategy used to tune the compression. Use one of the
714 symbolic constants defined below.
715
716 Z_FILTERED
717 Z_HUFFMAN_ONLY
718 Z_RLE
719 Z_FIXED
720 Z_DEFAULT_STRATEGY
721
722 The default is Z_DEFAULT_STRATEGY.
723
724 "Strict => 0|1"
725 This is a placeholder option.
726
727 Examples
728 TODO
729
731 print
732 Usage is
733
734 $z->print($data)
735 print $z $data
736
737 Compresses and outputs the contents of the $data parameter. This has
738 the same behaviour as the "print" built-in.
739
740 Returns true if successful.
741
742 printf
743 Usage is
744
745 $z->printf($format, $data)
746 printf $z $format, $data
747
748 Compresses and outputs the contents of the $data parameter.
749
750 Returns true if successful.
751
752 syswrite
753 Usage is
754
755 $z->syswrite $data
756 $z->syswrite $data, $length
757 $z->syswrite $data, $length, $offset
758
759 Compresses and outputs the contents of the $data parameter.
760
761 Returns the number of uncompressed bytes written, or "undef" if
762 unsuccessful.
763
764 write
765 Usage is
766
767 $z->write $data
768 $z->write $data, $length
769 $z->write $data, $length, $offset
770
771 Compresses and outputs the contents of the $data parameter.
772
773 Returns the number of uncompressed bytes written, or "undef" if
774 unsuccessful.
775
776 flush
777 Usage is
778
779 $z->flush;
780 $z->flush($flush_type);
781
782 Flushes any pending compressed data to the output file/buffer.
783
784 This method takes an optional parameter, $flush_type, that controls how
785 the flushing will be carried out. By default the $flush_type used is
786 "Z_FINISH". Other valid values for $flush_type are "Z_NO_FLUSH",
787 "Z_SYNC_FLUSH", "Z_FULL_FLUSH" and "Z_BLOCK". It is strongly
788 recommended that you only set the "flush_type" parameter if you fully
789 understand the implications of what it does - overuse of "flush" can
790 seriously degrade the level of compression achieved. See the "zlib"
791 documentation for details.
792
793 Returns true on success.
794
795 tell
796 Usage is
797
798 $z->tell()
799 tell $z
800
801 Returns the uncompressed file offset.
802
803 eof
804 Usage is
805
806 $z->eof();
807 eof($z);
808
809 Returns true if the "close" method has been called.
810
811 seek
812 $z->seek($position, $whence);
813 seek($z, $position, $whence);
814
815 Provides a sub-set of the "seek" functionality, with the restriction
816 that it is only legal to seek forward in the output file/buffer. It is
817 a fatal error to attempt to seek backward.
818
819 Empty parts of the file/buffer will have NULL (0x00) bytes written to
820 them.
821
822 The $whence parameter takes one the usual values, namely SEEK_SET,
823 SEEK_CUR or SEEK_END.
824
825 Returns 1 on success, 0 on failure.
826
827 binmode
828 Usage is
829
830 $z->binmode
831 binmode $z ;
832
833 This is a noop provided for completeness.
834
835 opened
836 $z->opened()
837
838 Returns true if the object currently refers to a opened file/buffer.
839
840 autoflush
841 my $prev = $z->autoflush()
842 my $prev = $z->autoflush(EXPR)
843
844 If the $z object is associated with a file or a filehandle, this method
845 returns the current autoflush setting for the underlying filehandle. If
846 "EXPR" is present, and is non-zero, it will enable flushing after every
847 write/print operation.
848
849 If $z is associated with a buffer, this method has no effect and always
850 returns "undef".
851
852 Note that the special variable $| cannot be used to set or retrieve the
853 autoflush setting.
854
855 input_line_number
856 $z->input_line_number()
857 $z->input_line_number(EXPR)
858
859 This method always returns "undef" when compressing.
860
861 fileno
862 $z->fileno()
863 fileno($z)
864
865 If the $z object is associated with a file or a filehandle, "fileno"
866 will return the underlying file descriptor. Once the "close" method is
867 called "fileno" will return "undef".
868
869 If the $z object is associated with a buffer, this method will return
870 "undef".
871
872 close
873 $z->close() ;
874 close $z ;
875
876 Flushes any pending compressed data and then closes the output
877 file/buffer.
878
879 For most versions of Perl this method will be automatically invoked if
880 the IO::Compress::Zip object is destroyed (either explicitly or by the
881 variable with the reference to the object going out of scope). The
882 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In these
883 cases, the "close" method will be called automatically, but not until
884 global destruction of all live objects when the program is terminating.
885
886 Therefore, if you want your scripts to be able to run on all versions
887 of Perl, you should call "close" explicitly and not rely on automatic
888 closing.
889
890 Returns true on success, otherwise 0.
891
892 If the "AutoClose" option has been enabled when the IO::Compress::Zip
893 object was created, and the object is associated with a file, the
894 underlying file will also be closed.
895
896 newStream([OPTS])
897 Usage is
898
899 $z->newStream( [OPTS] )
900
901 Closes the current compressed data stream and starts a new one.
902
903 OPTS consists of any of the options that are available when creating
904 the $z object.
905
906 See the "Constructor Options" section for more details.
907
908 deflateParams
909 Usage is
910
911 $z->deflateParams
912
913 TODO
914
916 A number of symbolic constants are required by some methods in
917 "IO::Compress::Zip". None are imported by default.
918
919 :all Imports "zip", $ZipError and all symbolic constants that can be
920 used by "IO::Compress::Zip". Same as doing this
921
922 use IO::Compress::Zip qw(zip $ZipError :constants) ;
923
924 :constants
925 Import all symbolic constants. Same as doing this
926
927 use IO::Compress::Zip qw(:flush :level :strategy :zip_method) ;
928
929 :flush
930 These symbolic constants are used by the "flush" method.
931
932 Z_NO_FLUSH
933 Z_PARTIAL_FLUSH
934 Z_SYNC_FLUSH
935 Z_FULL_FLUSH
936 Z_FINISH
937 Z_BLOCK
938
939 :level
940 These symbolic constants are used by the "Level" option in the
941 constructor.
942
943 Z_NO_COMPRESSION
944 Z_BEST_SPEED
945 Z_BEST_COMPRESSION
946 Z_DEFAULT_COMPRESSION
947
948 :strategy
949 These symbolic constants are used by the "Strategy" option in the
950 constructor.
951
952 Z_FILTERED
953 Z_HUFFMAN_ONLY
954 Z_RLE
955 Z_FIXED
956 Z_DEFAULT_STRATEGY
957
958 :zip_method
959 These symbolic constants are used by the "Method" option in the
960 constructor.
961
962 ZIP_CM_STORE
963 ZIP_CM_DEFLATE
964 ZIP_CM_BZIP2
965
967 Apache::GZip Revisited
968 See IO::Compress::FAQ
969
970 Working with Net::FTP
971 See IO::Compress::FAQ
972
974 Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip,
975 IO::Compress::Deflate, IO::Uncompress::Inflate,
976 IO::Compress::RawDeflate, IO::Uncompress::RawInflate,
977 IO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzma,
978 IO::Uncompress::UnLzma, IO::Compress::Xz, IO::Uncompress::UnXz,
979 IO::Compress::Lzip, IO::Uncompress::UnLzip, IO::Compress::Lzop,
980 IO::Uncompress::UnLzop, IO::Compress::Lzf, IO::Uncompress::UnLzf,
981 IO::Compress::Zstd, IO::Uncompress::UnZstd, IO::Uncompress::AnyInflate,
982 IO::Uncompress::AnyUncompress
983
984 IO::Compress::FAQ
985
986 File::GlobMapper, Archive::Zip, Archive::Tar, IO::Zlib
987
988 For RFC 1950, 1951 and 1952 see
989 <http://www.faqs.org/rfcs/rfc1950.html>,
990 <http://www.faqs.org/rfcs/rfc1951.html> and
991 <http://www.faqs.org/rfcs/rfc1952.html>
992
993 The zlib compression library was written by Jean-loup Gailly
994 "gzip@prep.ai.mit.edu" and Mark Adler "madler@alumni.caltech.edu".
995
996 The primary site for the zlib compression library is
997 <http://www.zlib.org>.
998
999 The primary site for gzip is <http://www.gzip.org>.
1000
1002 This module was written by Paul Marquess, "pmqs@cpan.org".
1003
1005 See the Changes file.
1006
1008 Copyright (c) 2005-2019 Paul Marquess. All rights reserved.
1009
1010 This program is free software; you can redistribute it and/or modify it
1011 under the same terms as Perl itself.
1012
1013
1014
1015perl v5.28.1 2019-01-05 IO::Compress::Zip(3)