1IO::Compress::Zip(3)  User Contributed Perl Documentation IO::Compress::Zip(3)
2
3
4

NAME

6       IO::Compress::Zip - Write zip files/buffers
7

SYNOPSIS

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

DESCRIPTION

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".
56
57       At present three compression methods are supported by
58       IO::Compress::Zip, namely Store (no compression at all), Deflate, Bzip2
59       and LZMA.
60
61       Note that to create Bzip2 content, the module "IO::Compress::Bzip2"
62       must be installed.
63
64       Note that to create LZMA content, the module "IO::Compress::Lzma" must
65       be installed.
66
67       For reading zip files/buffers, see the companion module
68       IO::Uncompress::Unzip.
69

Functional Interface

71       A top-level function, "zip", is provided to carry out "one-shot"
72       compression between buffers and/or files. For finer control over the
73       compression process, see the "OO Interface" section.
74
75           use IO::Compress::Zip qw(zip $ZipError) ;
76
77           zip $input_filename_or_reference => $output_filename_or_reference [,OPTS]
78               or die "zip failed: $ZipError\n";
79
80       The functional interface needs Perl5.005 or better.
81
82   zip $input_filename_or_reference => $output_filename_or_reference [, OPTS]
83       "zip" expects at least two parameters, $input_filename_or_reference and
84       $output_filename_or_reference.
85
86       The $input_filename_or_reference parameter
87
88       The parameter, $input_filename_or_reference, is used to define the
89       source of the uncompressed data.
90
91       It can take one of the following forms:
92
93       A filename
94            If the <$input_filename_or_reference> parameter is a simple
95            scalar, it is assumed to be a filename. This file will be opened
96            for reading and the input data will be read from it.
97
98       A filehandle
99            If the $input_filename_or_reference parameter is a filehandle, the
100            input data will be read from it.  The string '-' can be used as an
101            alias for standard input.
102
103       A scalar reference
104            If $input_filename_or_reference is a scalar reference, the input
105            data will be read from $$input_filename_or_reference.
106
107       An array reference
108            If $input_filename_or_reference is an array reference, each
109            element in the array must be a filename.
110
111            The input data will be read from each file in turn.
112
113            The complete array will be walked to ensure that it only contains
114            valid filenames before any data is compressed.
115
116       An Input FileGlob string
117            If $input_filename_or_reference is a string that is delimited by
118            the characters "<" and ">" "zip" will assume that it is an input
119            fileglob string. The input is the list of files that match the
120            fileglob.
121
122            See File::GlobMapper for more details.
123
124       If the $input_filename_or_reference parameter is any other type,
125       "undef" will be returned.
126
127       In addition, if $input_filename_or_reference is a simple filename, the
128       default values for the "Name", "Time", "TextFlag", "ExtAttr", "exUnixN"
129       and "exTime" options will be sourced from that file.
130
131       If you do not want to use these defaults they can be overridden by
132       explicitly setting the "Name", "Time", "TextFlag", "ExtAttr", "exUnixN"
133       and "exTime" options or by setting the "Minimal" parameter.
134
135       The $output_filename_or_reference parameter
136
137       The parameter $output_filename_or_reference is used to control the
138       destination of the compressed data. This parameter can take one of
139       these forms.
140
141       A filename
142            If the $output_filename_or_reference parameter is a simple scalar,
143            it is assumed to be a filename.  This file will be opened for
144            writing and the compressed data will be written to it.
145
146       A filehandle
147            If the $output_filename_or_reference parameter is a filehandle,
148            the compressed data will be written to it.  The string '-' can be
149            used as an alias for standard output.
150
151       A scalar reference
152            If $output_filename_or_reference is a scalar reference, the
153            compressed data will be stored in $$output_filename_or_reference.
154
155       An Array Reference
156            If $output_filename_or_reference is an array reference, the
157            compressed data will be pushed onto the array.
158
159       An Output FileGlob
160            If $output_filename_or_reference is a string that is delimited by
161            the characters "<" and ">" "zip" will assume that it is an output
162            fileglob string. The output is the list of files that match the
163            fileglob.
164
165            When $output_filename_or_reference is an fileglob string,
166            $input_filename_or_reference must also be a fileglob string.
167            Anything else is an error.
168
169            See File::GlobMapper for more details.
170
171       If the $output_filename_or_reference parameter is any other type,
172       "undef" will be returned.
173
174   Notes
175       When $input_filename_or_reference maps to multiple files/buffers and
176       $output_filename_or_reference is a single file/buffer the input
177       files/buffers will each be stored in $output_filename_or_reference as a
178       distinct entry.
179
180   Optional Parameters
181       Unless specified below, the optional parameters for "zip", "OPTS", are
182       the same as those used with the OO interface defined in the
183       "Constructor Options" section below.
184
185       "AutoClose => 0|1"
186            This option applies to any input or output data streams to "zip"
187            that are filehandles.
188
189            If "AutoClose" is specified, and the value is true, it will result
190            in all input and/or output filehandles being closed once "zip" has
191            completed.
192
193            This parameter defaults to 0.
194
195       "BinModeIn => 0|1"
196            When reading from a file or filehandle, set "binmode" before
197            reading.
198
199            Defaults to 0.
200
201       "Append => 0|1"
202            The behaviour of this option is dependent on the type of output
203            data stream.
204
205            ·    A Buffer
206
207                 If "Append" is enabled, all compressed data will be append to
208                 the end of the output buffer. Otherwise the output buffer
209                 will be cleared before any compressed data is written to it.
210
211            ·    A Filename
212
213                 If "Append" is enabled, the file will be opened in append
214                 mode. Otherwise the contents of the file, if any, will be
215                 truncated before any compressed data is written to it.
216
217            ·    A Filehandle
218
219                 If "Append" is enabled, the filehandle will be positioned to
220                 the end of the file via a call to "seek" before any
221                 compressed data is written to it.  Otherwise the file pointer
222                 will not be moved.
223
224            When "Append" is specified, and set to true, it will append all
225            compressed data to the output data stream.
226
227            So when the output is a filehandle it will carry out a seek to the
228            eof before writing any compressed data. If the output is a
229            filename, it will be opened for appending. If the output is a
230            buffer, all compressed data will be appended to the existing
231            buffer.
232
233            Conversely when "Append" is not specified, or it is present and is
234            set to false, it will operate as follows.
235
236            When the output is a filename, it will truncate the contents of
237            the file before writing any compressed data. If the output is a
238            filehandle its position will not be changed. If the output is a
239            buffer, it will be wiped before any compressed data is output.
240
241            Defaults to 0.
242
243   Examples
244       To read the contents of the file "file1.txt" and write the compressed
245       data to the file "file1.txt.zip".
246
247           use strict ;
248           use warnings ;
249           use IO::Compress::Zip qw(zip $ZipError) ;
250
251           my $input = "file1.txt";
252           zip $input => "$input.zip"
253               or die "zip failed: $ZipError\n";
254
255       To read from an existing Perl filehandle, $input, and write the
256       compressed data to a buffer, $buffer.
257
258           use strict ;
259           use warnings ;
260           use IO::Compress::Zip qw(zip $ZipError) ;
261           use IO::File ;
262
263           my $input = new IO::File "<file1.txt"
264               or die "Cannot open 'file1.txt': $!\n" ;
265           my $buffer ;
266           zip $input => \$buffer
267               or die "zip failed: $ZipError\n";
268
269       To create a zip file, "output.zip", that contains the compressed
270       contents of the files "alpha.txt" and "beta.txt"
271
272           use strict ;
273           use warnings ;
274           use IO::Compress::Zip qw(zip $ZipError) ;
275
276           zip [ 'alpha.txt', 'beta.txt' ] => 'output.zip'
277               or die "zip failed: $ZipError\n";
278
279       Alternatively, rather than having to explicitly name each of the files
280       that you want to compress, you could use a fileglob to select all the
281       "txt" files in the current directory, as follows
282
283           use strict ;
284           use warnings ;
285           use IO::Compress::Zip qw(zip $ZipError) ;
286
287           my @files = <*.txt>;
288           zip \@files => 'output.zip'
289               or die "zip failed: $ZipError\n";
290
291       or more succinctly
292
293           zip [ <*.txt> ] => 'output.zip'
294               or die "zip failed: $ZipError\n";
295

OO Interface

297   Constructor
298       The format of the constructor for "IO::Compress::Zip" is shown below
299
300           my $z = new IO::Compress::Zip $output [,OPTS]
301               or die "IO::Compress::Zip failed: $ZipError\n";
302
303       It returns an "IO::Compress::Zip" object on success and undef on
304       failure.  The variable $ZipError will contain an error message on
305       failure.
306
307       If you are running Perl 5.005 or better the object, $z, returned from
308       IO::Compress::Zip can be used exactly like an IO::File filehandle.
309       This means that all normal output file operations can be carried out
310       with $z.  For example, to write to a compressed file/buffer you can use
311       either of these forms
312
313           $z->print("hello world\n");
314           print $z "hello world\n";
315
316       The mandatory parameter $output is used to control the destination of
317       the compressed data. This parameter can take one of these forms.
318
319       A filename
320            If the $output parameter is a simple scalar, it is assumed to be a
321            filename. This file will be opened for writing and the compressed
322            data will be written to it.
323
324       A filehandle
325            If the $output parameter is a filehandle, the compressed data will
326            be written to it.  The string '-' can be used as an alias for
327            standard output.
328
329       A scalar reference
330            If $output is a scalar reference, the compressed data will be
331            stored in $$output.
332
333       If the $output parameter is any other type, "IO::Compress::Zip"::new
334       will return undef.
335
336   Constructor Options
337       "OPTS" is any combination of the following options:
338
339       "AutoClose => 0|1"
340            This option is only valid when the $output parameter is a
341            filehandle. If specified, and the value is true, it will result in
342            the $output being closed once either the "close" method is called
343            or the "IO::Compress::Zip" object is destroyed.
344
345            This parameter defaults to 0.
346
347       "Append => 0|1"
348            Opens $output in append mode.
349
350            The behaviour of this option is dependent on the type of $output.
351
352            ·    A Buffer
353
354                 If $output is a buffer and "Append" is enabled, all
355                 compressed data will be append to the end of $output.
356                 Otherwise $output will be cleared before any data is written
357                 to it.
358
359            ·    A Filename
360
361                 If $output is a filename and "Append" is enabled, the file
362                 will be opened in append mode. Otherwise the contents of the
363                 file, if any, will be truncated before any compressed data is
364                 written to it.
365
366            ·    A Filehandle
367
368                 If $output is a filehandle, the file pointer will be
369                 positioned to the end of the file via a call to "seek" before
370                 any compressed data is written to it.  Otherwise the file
371                 pointer will not be moved.
372
373            This parameter defaults to 0.
374
375       "Name => $string"
376            Stores the contents of $string in the zip filename header field.
377
378            If "Name" is not specified and the $input parameter is a filename,
379            the value of $input will be used for the zip filename header
380            field.
381
382            If "Name" is not specified and the $input parameter is not a
383            filename, no zip filename field will be created.
384
385            Note that both the "CanonicalName" and "FilterName" options can
386            modify the value used for the zip filename header field.
387
388       "CanonicalName => 0|1"
389            This option controls whether the filename field in the zip header
390            is normalized into Unix format before being written to the zip
391            file.
392
393            It is recommended that you enable this option unless you really
394            need to create a non-standard Zip file.
395
396            This is what APPNOTE.TXT has to say on what should be stored in
397            the zip filename header field.
398
399                The name of the file, with optional relative path.
400                The path stored should not contain a drive or
401                device letter, or a leading slash.  All slashes
402                should be forward slashes '/' as opposed to
403                backwards slashes '\' for compatibility with Amiga
404                and UNIX file systems etc.
405
406            This option defaults to false.
407
408       "FilterName => sub { ... }"
409            This option allow the filename field in the zip header to be
410            modified before it is written to the zip file.
411
412            This option takes a parameter that must be a reference to a sub.
413            On entry to the sub the $_ variable will contain the name to be
414            filtered. If no filename is available $_ will contain an empty
415            string.
416
417            The value of $_ when the sub returns will be  stored in the
418            filename header field.
419
420            Note that if "CanonicalName" is enabled, a normalized filename
421            will be passed to the sub.
422
423            If you use "FilterName" to modify the filename, it is your
424            responsibility to keep the filename in Unix format.
425
426            Although this option can be used with the OO interface, it is of
427            most use with the one-shot interface. For example, the code below
428            shows how "FilterName" can be used to remove the path component
429            from a series of filenames before they are stored in $zipfile.
430
431                sub compressTxtFiles
432                {
433                    my $zipfile = shift ;
434                    my $dir     = shift ;
435
436                    zip [ <$dir/*.txt> ] => $zipfile,
437                        FilterName => sub { s[^$dir/][] } ;
438                }
439
440       "Time => $number"
441            Sets the last modified time field in the zip header to $number.
442
443            This field defaults to the time the "IO::Compress::Zip" object was
444            created if this option is not specified and the $input parameter
445            is not a filename.
446
447       "ExtAttr => $attr"
448            This option controls the "external file attributes" field in the
449            central header of the zip file. This is a 4 byte field.
450
451            If you are running a Unix derivative this value defaults to
452
453                0100644 << 16
454
455            This should allow read/write access to any files that are
456            extracted from the zip file/buffer`.
457
458            For all other systems it defaults to 0.
459
460       "exTime => [$atime, $mtime, $ctime]"
461            This option expects an array reference with exactly three
462            elements: $atime, "mtime" and $ctime. These correspond to the last
463            access time, last modification time and creation time
464            respectively.
465
466            It uses these values to set the extended timestamp field (ID is
467            "UT") in the local zip header using the three values, $atime,
468            $mtime, $ctime. In addition it sets the extended timestamp field
469            in the central zip header using $mtime.
470
471            If any of the three values is "undef" that time value will not be
472            used.  So, for example, to set only the $mtime you would use this
473
474                exTime => [undef, $mtime, undef]
475
476            If the "Minimal" option is set to true, this option will be
477            ignored.
478
479            By default no extended time field is created.
480
481       "exUnix2 => [$uid, $gid]"
482            This option expects an array reference with exactly two elements:
483            $uid and $gid. These values correspond to the numeric User ID
484            (UID) and Group ID (GID) of the owner of the files respectively.
485
486            When the "exUnix2" option is present it will trigger the creation
487            of a Unix2 extra field (ID is "Ux") in the local zip header. This
488            will be populated with $uid and $gid. An empty Unix2 extra field
489            will also be created in the central zip header.
490
491            Note - The UID & GID are stored as 16-bit integers in the "Ux"
492            field. Use "exUnixN" if your UID or GID are 32-bit.
493
494            If the "Minimal" option is set to true, this option will be
495            ignored.
496
497            By default no Unix2 extra field is created.
498
499       "exUnixN => [$uid, $gid]"
500            This option expects an array reference with exactly two elements:
501            $uid and $gid. These values correspond to the numeric User ID
502            (UID) and Group ID (GID) of the owner of the files respectively.
503
504            When the "exUnixN" option is present it will trigger the creation
505            of a UnixN extra field (ID is "ux") in both the local and central
506            zip headers.  This will be populated with $uid and $gid.  The UID
507            & GID are stored as 32-bit integers.
508
509            If the "Minimal" option is set to true, this option will be
510            ignored.
511
512            By default no UnixN extra field is created.
513
514       "Comment => $comment"
515            Stores the contents of $comment in the Central File Header of the
516            zip file.
517
518            By default, no comment field is written to the zip file.
519
520       "ZipComment => $comment"
521            Stores the contents of $comment in the End of Central Directory
522            record of the zip file.
523
524            By default, no comment field is written to the zip file.
525
526       "Method => $method"
527            Controls which compression method is used. At present four
528            compression methods are supported, namely Store (no compression at
529            all), Deflate, Bzip2 and Lzma.
530
531            The symbols, ZIP_CM_STORE, ZIP_CM_DEFLATE, ZIP_CM_BZIP2 and
532            ZIP_CM_LZMA are used to select the compression method.
533
534            These constants are not imported by "IO::Compress::Zip" by
535            default.
536
537                use IO::Compress::Zip qw(:zip_method);
538                use IO::Compress::Zip qw(:constants);
539                use IO::Compress::Zip qw(:all);
540
541            Note that to create Bzip2 content, the module
542            "IO::Compress::Bzip2" must be installed. A fatal error will be
543            thrown if you attempt to create Bzip2 content when
544            "IO::Compress::Bzip2" is not available.
545
546            Note that to create Lzma content, the module "IO::Compress::Lzma"
547            must be installed. A fatal error will be thrown if you attempt to
548            create Lzma content when "IO::Compress::Lzma" is not available.
549
550            The default method is ZIP_CM_DEFLATE.
551
552       "Stream => 0|1"
553            This option controls whether the zip file/buffer output is created
554            in streaming mode.
555
556            Note that when outputting to a file with streaming mode disabled
557            ("Stream" is 0), the output file must be seekable.
558
559            The default is 1.
560
561       "Zip64 => 0|1"
562            Create a Zip64 zip file/buffer. This option is used if you want to
563            store files larger than 4 Gig or store more than 64K files in a
564            single zip archive.
565
566            "Zip64" will be automatically set, as needed, if working with the
567            one-shot interface when the input is either a filename or a scalar
568            reference.
569
570            If you intend to manipulate the Zip64 zip files created with this
571            module using an external zip/unzip, make sure that it supports
572            Zip64.
573
574            In particular, if you are using Info-Zip you need to have zip
575            version 3.x or better to update a Zip64 archive and unzip version
576            6.x to read a zip64 archive.
577
578            The default is 0.
579
580       "TextFlag => 0|1"
581            This parameter controls the setting of a bit in the zip central
582            header. It is used to signal that the data stored in the zip
583            file/buffer is probably text.
584
585            In one-shot mode this flag will be set to true if the Perl "-T"
586            operator thinks the file contains text.
587
588            The default is 0.
589
590       "ExtraFieldLocal => $data"
591       "ExtraFieldCentral => $data"
592            The "ExtraFieldLocal" option is used to store additional metadata
593            in the local header for the zip file/buffer. The
594            "ExtraFieldCentral" does the same for the matching central header.
595
596            An extra field consists of zero or more subfields. Each subfield
597            consists of a two byte header followed by the subfield data.
598
599            The list of subfields can be supplied in any of the following
600            formats
601
602                ExtraFieldLocal => [$id1, $data1,
603                                    $id2, $data2,
604                                     ...
605                                   ]
606
607                ExtraFieldLocal => [ [$id1 => $data1],
608                                     [$id2 => $data2],
609                                     ...
610                                   ]
611
612                ExtraFieldLocal => { $id1 => $data1,
613                                     $id2 => $data2,
614                                     ...
615                                   }
616
617            Where $id1, $id2 are two byte subfield ID's.
618
619            If you use the hash syntax, you have no control over the order in
620            which the ExtraSubFields are stored, plus you cannot have
621            SubFields with duplicate ID.
622
623            Alternatively the list of subfields can by supplied as a scalar,
624            thus
625
626                ExtraField => $rawdata
627
628            In this case "IO::Compress::Zip" will check that $rawdata consists
629            of zero or more conformant sub-fields.
630
631            The Extended Time field (ID "UT"), set using the "exTime" option,
632            and the Unix2 extra field (ID "Ux), set using the "exUnix2"
633            option, are examples of extra fields.
634
635            If the "Minimal" option is set to true, this option will be
636            ignored.
637
638            The maximum size of an extra field 65535 bytes.
639
640       "Minimal => 1|0"
641            If specified, this option will disable the creation of all extra
642            fields in the zip local and central headers. So the "exTime",
643            "exUnix2", "exUnixN", "ExtraFieldLocal" and "ExtraFieldCentral"
644            options will be ignored.
645
646            This parameter defaults to 0.
647
648       "BlockSize100K => number"
649            Specify the number of 100K blocks bzip2 uses during compression.
650
651            Valid values are from 1 to 9, where 9 is best compression.
652
653            This option is only valid if the "Method" is ZIP_CM_BZIP2. It is
654            ignored otherwise.
655
656            The default is 1.
657
658       "WorkFactor => number"
659            Specifies how much effort bzip2 should take before resorting to a
660            slower fallback compression algorithm.
661
662            Valid values range from 0 to 250, where 0 means use the default
663            value 30.
664
665            This option is only valid if the "Method" is ZIP_CM_BZIP2. It is
666            ignored otherwise.
667
668            The default is 0.
669
670       "Preset => number"
671            Used to choose the LZMA compression preset.
672
673            Valid values are 0-9 and "LZMA_PRESET_DEFAULT".
674
675            0 is the fastest compression with the lowest memory usage and the
676            lowest compression.
677
678            9 is the slowest compression with the highest memory usage but
679            with the best compression.
680
681            This option is only valid if the "Method" is ZIP_CM_LZMA. It is
682            ignored otherwise.
683
684            Defaults to "LZMA_PRESET_DEFAULT" (6).
685
686       "Extreme => 0|1"
687            Makes LZMA compression a lot slower, but a small compression gain.
688
689            This option is only valid if the "Method" is ZIP_CM_LZMA. It is
690            ignored otherwise.
691
692            Defaults to 0.
693
694       -Level
695            Defines the compression level used by zlib. The value should
696            either be a number between 0 and 9 (0 means no compression and 9
697            is maximum compression), or one of the symbolic constants defined
698            below.
699
700               Z_NO_COMPRESSION
701               Z_BEST_SPEED
702               Z_BEST_COMPRESSION
703               Z_DEFAULT_COMPRESSION
704
705            The default is Z_DEFAULT_COMPRESSION.
706
707            Note, these constants are not imported by "IO::Compress::Zip" by
708            default.
709
710                use IO::Compress::Zip qw(:strategy);
711                use IO::Compress::Zip qw(:constants);
712                use IO::Compress::Zip qw(:all);
713
714       -Strategy
715            Defines the strategy used to tune the compression. Use one of the
716            symbolic constants defined below.
717
718               Z_FILTERED
719               Z_HUFFMAN_ONLY
720               Z_RLE
721               Z_FIXED
722               Z_DEFAULT_STRATEGY
723
724            The default is Z_DEFAULT_STRATEGY.
725
726       "Strict => 0|1"
727            This is a placeholder option.
728
729   Examples
730       TODO
731

Methods

733   print
734       Usage is
735
736           $z->print($data)
737           print $z $data
738
739       Compresses and outputs the contents of the $data parameter. This has
740       the same behaviour as the "print" built-in.
741
742       Returns true if successful.
743
744   printf
745       Usage is
746
747           $z->printf($format, $data)
748           printf $z $format, $data
749
750       Compresses and outputs the contents of the $data parameter.
751
752       Returns true if successful.
753
754   syswrite
755       Usage is
756
757           $z->syswrite $data
758           $z->syswrite $data, $length
759           $z->syswrite $data, $length, $offset
760
761       Compresses and outputs the contents of the $data parameter.
762
763       Returns the number of uncompressed bytes written, or "undef" if
764       unsuccessful.
765
766   write
767       Usage is
768
769           $z->write $data
770           $z->write $data, $length
771           $z->write $data, $length, $offset
772
773       Compresses and outputs the contents of the $data parameter.
774
775       Returns the number of uncompressed bytes written, or "undef" if
776       unsuccessful.
777
778   flush
779       Usage is
780
781           $z->flush;
782           $z->flush($flush_type);
783
784       Flushes any pending compressed data to the output file/buffer.
785
786       This method takes an optional parameter, $flush_type, that controls how
787       the flushing will be carried out. By default the $flush_type used is
788       "Z_FINISH". Other valid values for $flush_type are "Z_NO_FLUSH",
789       "Z_SYNC_FLUSH", "Z_FULL_FLUSH" and "Z_BLOCK". It is strongly
790       recommended that you only set the "flush_type" parameter if you fully
791       understand the implications of what it does - overuse of "flush" can
792       seriously degrade the level of compression achieved. See the "zlib"
793       documentation for details.
794
795       Returns true on success.
796
797   tell
798       Usage is
799
800           $z->tell()
801           tell $z
802
803       Returns the uncompressed file offset.
804
805   eof
806       Usage is
807
808           $z->eof();
809           eof($z);
810
811       Returns true if the "close" method has been called.
812
813   seek
814           $z->seek($position, $whence);
815           seek($z, $position, $whence);
816
817       Provides a sub-set of the "seek" functionality, with the restriction
818       that it is only legal to seek forward in the output file/buffer.  It is
819       a fatal error to attempt to seek backward.
820
821       Empty parts of the file/buffer will have NULL (0x00) bytes written to
822       them.
823
824       The $whence parameter takes one the usual values, namely SEEK_SET,
825       SEEK_CUR or SEEK_END.
826
827       Returns 1 on success, 0 on failure.
828
829   binmode
830       Usage is
831
832           $z->binmode
833           binmode $z ;
834
835       This is a noop provided for completeness.
836
837   opened
838           $z->opened()
839
840       Returns true if the object currently refers to a opened file/buffer.
841
842   autoflush
843           my $prev = $z->autoflush()
844           my $prev = $z->autoflush(EXPR)
845
846       If the $z object is associated with a file or a filehandle, this method
847       returns the current autoflush setting for the underlying filehandle. If
848       "EXPR" is present, and is non-zero, it will enable flushing after every
849       write/print operation.
850
851       If $z is associated with a buffer, this method has no effect and always
852       returns "undef".
853
854       Note that the special variable $| cannot be used to set or retrieve the
855       autoflush setting.
856
857   input_line_number
858           $z->input_line_number()
859           $z->input_line_number(EXPR)
860
861       This method always returns "undef" when compressing.
862
863   fileno
864           $z->fileno()
865           fileno($z)
866
867       If the $z object is associated with a file or a filehandle, "fileno"
868       will return the underlying file descriptor. Once the "close" method is
869       called "fileno" will return "undef".
870
871       If the $z object is associated with a buffer, this method will return
872       "undef".
873
874   close
875           $z->close() ;
876           close $z ;
877
878       Flushes any pending compressed data and then closes the output
879       file/buffer.
880
881       For most versions of Perl this method will be automatically invoked if
882       the IO::Compress::Zip object is destroyed (either explicitly or by the
883       variable with the reference to the object going out of scope). The
884       exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In these
885       cases, the "close" method will be called automatically, but not until
886       global destruction of all live objects when the program is terminating.
887
888       Therefore, if you want your scripts to be able to run on all versions
889       of Perl, you should call "close" explicitly and not rely on automatic
890       closing.
891
892       Returns true on success, otherwise 0.
893
894       If the "AutoClose" option has been enabled when the IO::Compress::Zip
895       object was created, and the object is associated with a file, the
896       underlying file will also be closed.
897
898   newStream([OPTS])
899       Usage is
900
901           $z->newStream( [OPTS] )
902
903       Closes the current compressed data stream and starts a new one.
904
905       OPTS consists of any of the options that are available when creating
906       the $z object.
907
908       See the "Constructor Options" section for more details.
909
910   deflateParams
911       Usage is
912
913           $z->deflateParams
914
915       TODO
916

Importing

918       A number of symbolic constants are required by some methods in
919       "IO::Compress::Zip". None are imported by default.
920
921       :all Imports "zip", $ZipError and all symbolic constants that can be
922            used by "IO::Compress::Zip". Same as doing this
923
924                use IO::Compress::Zip qw(zip $ZipError :constants) ;
925
926       :constants
927            Import all symbolic constants. Same as doing this
928
929                use IO::Compress::Zip qw(:flush :level :strategy :zip_method) ;
930
931       :flush
932            These symbolic constants are used by the "flush" method.
933
934                Z_NO_FLUSH
935                Z_PARTIAL_FLUSH
936                Z_SYNC_FLUSH
937                Z_FULL_FLUSH
938                Z_FINISH
939                Z_BLOCK
940
941       :level
942            These symbolic constants are used by the "Level" option in the
943            constructor.
944
945                Z_NO_COMPRESSION
946                Z_BEST_SPEED
947                Z_BEST_COMPRESSION
948                Z_DEFAULT_COMPRESSION
949
950       :strategy
951            These symbolic constants are used by the "Strategy" option in the
952            constructor.
953
954                Z_FILTERED
955                Z_HUFFMAN_ONLY
956                Z_RLE
957                Z_FIXED
958                Z_DEFAULT_STRATEGY
959
960       :zip_method
961            These symbolic constants are used by the "Method" option in the
962            constructor.
963
964                ZIP_CM_STORE
965                ZIP_CM_DEFLATE
966                ZIP_CM_BZIP2
967

EXAMPLES

969   Apache::GZip Revisited
970       See IO::Compress::FAQ
971
972   Working with Net::FTP
973       See IO::Compress::FAQ
974

SEE ALSO

976       Compress::Zlib, IO::Compress::Gzip, IO::Uncompress::Gunzip,
977       IO::Compress::Deflate, IO::Uncompress::Inflate,
978       IO::Compress::RawDeflate, IO::Uncompress::RawInflate,
979       IO::Compress::Bzip2, IO::Uncompress::Bunzip2, IO::Compress::Lzma,
980       IO::Uncompress::UnLzma, IO::Compress::Xz, IO::Uncompress::UnXz,
981       IO::Compress::Lzop, IO::Uncompress::UnLzop, IO::Compress::Lzf,
982       IO::Uncompress::UnLzf, IO::Uncompress::AnyInflate,
983       IO::Uncompress::AnyUncompress
984
985       IO::Compress::FAQ
986
987       File::GlobMapper, Archive::Zip, Archive::Tar, IO::Zlib
988
989       For RFC 1950, 1951 and 1952 see
990       <http://www.faqs.org/rfcs/rfc1950.html>,
991       <http://www.faqs.org/rfcs/rfc1951.html> and
992       <http://www.faqs.org/rfcs/rfc1952.html>
993
994       The zlib compression library was written by Jean-loup Gailly
995       "gzip@prep.ai.mit.edu" and Mark Adler "madler@alumni.caltech.edu".
996
997       The primary site for the zlib compression library is
998       <http://www.zlib.org>.
999
1000       The primary site for gzip is <http://www.gzip.org>.
1001

AUTHOR

1003       This module was written by Paul Marquess, "pmqs@cpan.org".
1004

MODIFICATION HISTORY

1006       See the Changes file.
1007
1009       Copyright (c) 2005-2018 Paul Marquess. All rights reserved.
1010
1011       This program is free software; you can redistribute it and/or modify it
1012       under the same terms as Perl itself.
1013
1014
1015
1016perl v5.28.0                      2018-04-05              IO::Compress::Zip(3)
Impressum