1 package IO::Compress::Zip ;
7 use IO::Compress::Base::Common qw(:Status createSelfTiedObject);
8 use IO::Compress::RawDeflate;
9 use IO::Compress::Adapter::Deflate;
10 use IO::Compress::Adapter::Identity;
12 use Compress::Raw::Zlib qw(crc32) ;
15 eval { require IO::Compress::Adapter::Bzip2;
16 import IO::Compress::Adapter::Bzip2;
17 require IO::Compress::Bzip2;
18 import IO::Compress::Bzip2;
25 our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $ZipError);
27 $VERSION = '2.000_11';
30 @ISA = qw(Exporter IO::Compress::RawDeflate);
31 @EXPORT_OK = qw( $ZipError zip ) ;
32 %EXPORT_TAGS = %IO::Compress::RawDeflate::DEFLATE_CONSTANTS ;
33 push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
35 $EXPORT_TAGS{zip_method} = [qw( ZIP_CM_STORE ZIP_CM_DEFLATE ZIP_CM_BZIP2 )];
36 push @{ $EXPORT_TAGS{all} }, @{ $EXPORT_TAGS{zip_method} };
38 Exporter::export_ok_tags('all');
40 use constant ZIP_CM_STORE => 0 ;
41 use constant ZIP_CM_DEFLATE => 8 ;
42 use constant ZIP_CM_BZIP2 => 12 ;
44 use constant ZIP_LOCAL_HDR_SIG => 0x04034b50;
45 use constant ZIP_DATA_HDR_SIG => 0x08074b50;
46 use constant ZIP_CENTRAL_HDR_SIG => 0x02014b50;
47 use constant ZIP_END_CENTRAL_HDR_SIG => 0x06054b50;
50 our (%ZIP_CM_MIN_VERSIONS);
51 %ZIP_CM_MIN_VERSIONS = (
53 ZIP_CM_DEFLATE() => 20,
61 my $obj = createSelfTiedObject($class, \$ZipError);
62 $obj->_create(undef, @_);
67 my $obj = createSelfTiedObject(undef, \$ZipError);
68 return $obj->_def(@_);
77 my ($obj, $errstr, $errno) ;
79 if (*$self->{ZipData}{Method} == ZIP_CM_STORE) {
80 ($obj, $errstr, $errno) = IO::Compress::Adapter::Identity::mkCompObject(
82 $got->value('Strategy')
85 elsif (*$self->{ZipData}{Method} == ZIP_CM_DEFLATE) {
86 ($obj, $errstr, $errno) = IO::Compress::Adapter::Deflate::mkCompObject(
88 $got->value('Adler32'),
90 $got->value('Strategy')
93 elsif (*$self->{ZipData}{Method} == ZIP_CM_BZIP2) {
94 ($obj, $errstr, $errno) = IO::Compress::Adapter::Bzip2::mkCompObject(
95 $got->value('BlockSize100K'),
96 $got->value('WorkFactor'),
97 $got->value('Verbosity')
99 *$self->{ZipData}{CRC32} = crc32(undef);
102 return $self->saveErrorString(undef, $errstr, $errno)
105 if (! defined *$self->{ZipData}{StartOffset}) {
106 *$self->{ZipData}{StartOffset} = *$self->{ZipData}{Offset} = 0;
116 *$self->{Compress}->reset();
117 *$self->{ZipData}{CRC32} = Compress::Raw::Zlib::crc32('');
122 sub filterUncompressed
126 if (*$self->{ZipData}{Method} == ZIP_CM_DEFLATE) {
127 *$self->{ZipData}{CRC32} = *$self->{Compress}->crc32();
130 *$self->{ZipData}{CRC32} = crc32(${$_[0]}, *$self->{ZipData}{CRC32});
141 $filename = $param->value('Name') || '';
144 $comment = $param->value('Comment') || '';
148 my $time = _unixToDosTime($param->value('Time'));
149 *$self->{ZipData}{StartOffset} = *$self->{ZipData}{Offset} ;
151 my $strm = *$self->{ZipData}{Stream} ? 8 : 0 ;
152 # bzip2 is 12, deflate is 8
153 my $method = *$self->{ZipData}{Method} ;
157 my $extract = $param->value('OS_Code') << 8 +
158 $ZIP_CM_MIN_VERSIONS{$method};
160 $hdr .= pack "V", ZIP_LOCAL_HDR_SIG ; # signature
161 $hdr .= pack 'v', $extract ; # extract Version & OS
162 $hdr .= pack 'v', $strm ; # general purpose flag (set streaming mode)
163 $hdr .= pack 'v', $method ; # compression method (deflate)
164 $hdr .= pack 'V', $time ; # last mod date/time
165 $hdr .= pack 'V', 0 ; # crc32 - 0 when streaming
166 $hdr .= pack 'V', 0 ; # compressed length - 0 when streaming
167 $hdr .= pack 'V', 0 ; # uncompressed length - 0 when streaming
168 $hdr .= pack 'v', length $filename ; # filename length
169 $hdr .= pack 'v', 0 ; # extra length
176 $ctl .= pack "V", ZIP_CENTRAL_HDR_SIG ; # signature
177 $ctl .= pack 'v', $extract ; # version made by
178 $ctl .= pack 'v', $extract ; # extract Version
179 $ctl .= pack 'v', $strm ; # general purpose flag (streaming mode)
180 $ctl .= pack 'v', $method ; # compression method (deflate)
181 $ctl .= pack 'V', $time ; # last mod date/time
182 $ctl .= pack 'V', 0 ; # crc32
183 $ctl .= pack 'V', 0 ; # compressed length
184 $ctl .= pack 'V', 0 ; # uncompressed length
185 $ctl .= pack 'v', length $filename ; # filename length
186 $ctl .= pack 'v', 0 ; # extra length
187 $ctl .= pack 'v', length $comment ; # file comment length
188 $ctl .= pack 'v', 0 ; # disk number start
189 $ctl .= pack 'v', 0 ; # internal file attributes
190 $ctl .= pack 'V', 0 ; # external file attributes
191 $ctl .= pack 'V', *$self->{ZipData}{Offset} ; # offset to local header
197 *$self->{ZipData}{Offset} += length $hdr ;
199 *$self->{ZipData}{CentralHeader} = $ctl;
209 if (*$self->{ZipData}{Method} == ZIP_CM_DEFLATE) {
210 $crc32 = *$self->{Compress}->crc32();
213 $crc32 = *$self->{ZipData}{CRC32};
216 my $compressedBytes = *$self->{Compress}->compressedBytes();
217 my $uncompressedBytes = *$self->{Compress}->uncompressedBytes();
220 $data .= pack "V", $crc32 ; # CRC32
221 $data .= pack "V", $compressedBytes ; # Compressed Size
222 $data .= pack "V", $uncompressedBytes; # Uncompressed Size
226 if (*$self->{ZipData}{Stream}) {
227 $hdr = pack "V", ZIP_DATA_HDR_SIG ; # signature
231 $self->writeAt(*$self->{ZipData}{StartOffset} + 14, $data)
235 my $ctl = *$self->{ZipData}{CentralHeader} ;
236 substr($ctl, 16, 12) = $data ;
237 #substr($ctl, 16, 4) = pack "V", $crc32 ; # CRC32
238 #substr($ctl, 20, 4) = pack "V", $compressedBytes ; # Compressed Size
239 #substr($ctl, 24, 4) = pack "V", $uncompressedBytes ; # Uncompressed Size
241 *$self->{ZipData}{Offset} += length($hdr) + $compressedBytes;
242 push @{ *$self->{ZipData}{CentralDir} }, $ctl ;
252 $comment = *$self->{ZipData}{ZipComment} ;
254 my $entries = @{ *$self->{ZipData}{CentralDir} };
255 my $cd = join '', @{ *$self->{ZipData}{CentralDir} };
258 $ecd .= pack "V", ZIP_END_CENTRAL_HDR_SIG ; # signature
259 $ecd .= pack 'v', 0 ; # number of disk
260 $ecd .= pack 'v', 0 ; # number if disk with central dir
261 $ecd .= pack 'v', $entries ; # entries in central dir on this disk
262 $ecd .= pack 'v', $entries ; # entries in central dir
263 $ecd .= pack 'V', length $cd ; # size of central dir
264 $ecd .= pack 'V', *$self->{ZipData}{Offset} ; # offset to start central dir
265 $ecd .= pack 'v', length $comment ; # zipfile comment length
276 $got->value('CRC32' => 1);
278 if (! $got->parsed('Time') ) {
279 # Modification time defaults to now.
280 $got->value('Time' => time) ;
283 *$self->{ZipData}{Stream} = $got->value('Stream');
284 #*$self->{ZipData}{Store} = $got->value('Store');
286 my $method = $got->value('Method');
287 #if ($method != 0 && $method != 8 && $method != 12) {
288 return $self->saveErrorString(undef, "Unknown Method '$method'")
289 if ! defined $ZIP_CM_MIN_VERSIONS{$method};
291 return $self->saveErrorString(undef, "Bzip2 not available")
292 if $method == ZIP_CM_BZIP2 and
293 ! defined $IO::Compress::Adapter::Bzip2::VERSION;
295 *$self->{ZipData}{Method} = $method;
297 *$self->{ZipData}{ZipComment} = $got->value('ZipComment') ;
300 if defined $IO::Compress::Bzip2::VERSION
301 and ! IO::Compress::Bzip2::ckParams($self, $got);
310 # return $self->mkHeader(*$self->{Got});
317 use IO::Compress::Base::Common qw(:Parse);
318 use Compress::Raw::Zlib qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY);
322 @Bzip2 = IO::Compress::Bzip2::getExtraParams($self)
323 if defined $IO::Compress::Bzip2::VERSION;
327 $self->getZlibParams(),
329 'Stream' => [1, 1, Parse_boolean, 1],
330 #'Store' => [0, 1, Parse_boolean, 0],
331 'Method' => [0, 1, Parse_unsigned, ZIP_CM_DEFLATE],
333 # # Zip header fields
334 # 'Minimal' => [0, 1, Parse_boolean, 0],
335 'Comment' => [0, 1, Parse_any, ''],
336 'ZipComment'=> [0, 1, Parse_any, ''],
337 'Name' => [0, 1, Parse_any, ''],
338 'Time' => [0, 1, Parse_any, undef],
339 'OS_Code' => [0, 1, Parse_unsigned, $Compress::Raw::Zlib::gzip_os_code],
341 # 'TextFlag' => [0, 1, Parse_boolean, 0],
342 # 'ExtraField'=> [0, 1, Parse_string, ''],
350 return ('IO::Uncompress::Unzip',
351 \$IO::Uncompress::Unzip::UnzipError);
358 my $filename = shift ;
360 my $defaultTime = (stat($filename))[9] ;
362 $params->value('Name' => $filename)
363 if ! $params->parsed('Name') ;
365 $params->value('Time' => $defaultTime)
366 if ! $params->parsed('Time') ;
372 sub _unixToDosTime # Archive::Zip::Member
375 # TODO - add something to cope with unix time < 1980
376 my ( $sec, $min, $hour, $mday, $mon, $year ) = localtime($time_t);
378 $dt += ( $sec >> 1 );
379 $dt += ( $min << 5 );
380 $dt += ( $hour << 11 );
381 $dt += ( $mday << 16 );
382 $dt += ( ( $mon + 1 ) << 21 );
383 $dt += ( ( $year - 80 ) << 25 );
395 IO::Compress::Zip - Write zip files/buffers
401 use IO::Compress::Zip qw(zip $ZipError) ;
404 my $status = zip $input => $output [,OPTS]
405 or die "zip failed: $ZipError\n";
407 my $z = new IO::Compress::Zip $output [,OPTS]
408 or die "zip failed: $ZipError\n";
411 $z->printf($format, $string);
413 $z->syswrite($string [, $length, $offset]);
417 $z->seek($position, $whence);
422 $z->input_line_number();
423 $z->newStream( [OPTS] );
434 printf $z $format, $string;
437 seek $z, $position, $whence
447 B<WARNING -- This is a Beta release>.
451 =item * DO NOT use in production code.
453 =item * The documentation is incomplete in places.
455 =item * Parts of the interface defined here are tentative.
457 =item * Please report any problems you find.
464 This module provides a Perl interface that allows writing zip
465 compressed data to files or buffer.
473 Note that IO::Compress::Zip is not intended to be a replacement for the module
476 The primary aim of this module is not as an archiver, but to provide
477 streaming write access to zip file files and buffers.
481 For reading zip files/buffers, see the companion module
482 L<IO::Uncompress::Unzip|IO::Uncompress::Unzip>.
485 =head1 Functional Interface
487 A top-level function, C<zip>, is provided to carry out
488 "one-shot" compression between buffers and/or files. For finer
489 control over the compression process, see the L</"OO Interface">
492 use IO::Compress::Zip qw(zip $ZipError) ;
494 zip $input => $output [,OPTS]
495 or die "zip failed: $ZipError\n";
499 The functional interface needs Perl5.005 or better.
502 =head2 zip $input => $output [, OPTS]
505 C<zip> expects at least two parameters, C<$input> and C<$output>.
507 =head3 The C<$input> parameter
509 The parameter, C<$input>, is used to define the source of
510 the uncompressed data.
512 It can take one of the following forms:
518 If the C<$input> parameter is a simple scalar, it is assumed to be a
519 filename. This file will be opened for reading and the input data
520 will be read from it.
524 If the C<$input> parameter is a filehandle, the input data will be
526 The string '-' can be used as an alias for standard input.
528 =item A scalar reference
530 If C<$input> is a scalar reference, the input data will be read
533 =item An array reference
535 If C<$input> is an array reference, each element in the array must be a
538 The input data will be read from each file in turn.
540 The complete array will be walked to ensure that it only
541 contains valid filenames before any data is compressed.
545 =item An Input FileGlob string
547 If C<$input> is a string that is delimited by the characters "<" and ">"
548 C<zip> will assume that it is an I<input fileglob string>. The
549 input is the list of files that match the fileglob.
551 If the fileglob does not match any files ...
553 See L<File::GlobMapper|File::GlobMapper> for more details.
558 If the C<$input> parameter is any other type, C<undef> will be returned.
561 In addition, if C<$input> is a simple filename, the default values for
562 the C<Name> and C<Time> options will be sourced from that file.
564 If you do not want to use these defaults they can be overridden by
565 explicitly setting the C<Name> and C<Time> options or by setting the
566 C<Minimal> parameter.
570 =head3 The C<$output> parameter
572 The parameter C<$output> is used to control the destination of the
573 compressed data. This parameter can take one of these forms.
579 If the C<$output> parameter is a simple scalar, it is assumed to be a
580 filename. This file will be opened for writing and the compressed
581 data will be written to it.
585 If the C<$output> parameter is a filehandle, the compressed data
586 will be written to it.
587 The string '-' can be used as an alias for standard output.
590 =item A scalar reference
592 If C<$output> is a scalar reference, the compressed data will be
593 stored in C<$$output>.
597 =item An Array Reference
599 If C<$output> is an array reference, the compressed data will be
600 pushed onto the array.
602 =item An Output FileGlob
604 If C<$output> is a string that is delimited by the characters "<" and ">"
605 C<zip> will assume that it is an I<output fileglob string>. The
606 output is the list of files that match the fileglob.
608 When C<$output> is an fileglob string, C<$input> must also be a fileglob
609 string. Anything else is an error.
613 If the C<$output> parameter is any other type, C<undef> will be returned.
619 When C<$input> maps to multiple files/buffers and C<$output> is a single
620 file/buffer the compressed input files/buffers will all be stored
621 in C<$output> as a single compressed stream.
625 =head2 Optional Parameters
627 Unless specified below, the optional parameters for C<zip>,
628 C<OPTS>, are the same as those used with the OO interface defined in the
629 L</"Constructor Options"> section below.
633 =item AutoClose =E<gt> 0|1
635 This option applies to any input or output data streams to
636 C<zip> that are filehandles.
638 If C<AutoClose> is specified, and the value is true, it will result in all
639 input and/or output filehandles being closed once C<zip> has
642 This parameter defaults to 0.
646 =item BinModeIn =E<gt> 0|1
648 When reading from a file or filehandle, set C<binmode> before reading.
656 =item -Append =E<gt> 0|1
667 To read the contents of the file C<file1.txt> and write the compressed
668 data to the file C<file1.txt.zip>.
672 use IO::Compress::Zip qw(zip $ZipError) ;
674 my $input = "file1.txt";
675 zip $input => "$input.zip"
676 or die "zip failed: $ZipError\n";
679 To read from an existing Perl filehandle, C<$input>, and write the
680 compressed data to a buffer, C<$buffer>.
684 use IO::Compress::Zip qw(zip $ZipError) ;
687 my $input = new IO::File "<file1.txt"
688 or die "Cannot open 'file1.txt': $!\n" ;
690 zip $input => \$buffer
691 or die "zip failed: $ZipError\n";
693 To compress all files in the directory "/my/home" that match "*.txt"
694 and store the compressed data in the same directory
698 use IO::Compress::Zip qw(zip $ZipError) ;
700 zip '</my/home/*.txt>' => '<*.zip>'
701 or die "zip failed: $ZipError\n";
703 and if you want to compress each file one at a time, this will do the trick
707 use IO::Compress::Zip qw(zip $ZipError) ;
709 for my $input ( glob "/my/home/*.txt" )
711 my $output = "$input.zip" ;
712 zip $input => $output
713 or die "Error compressing '$input': $ZipError\n";
721 The format of the constructor for C<IO::Compress::Zip> is shown below
723 my $z = new IO::Compress::Zip $output [,OPTS]
724 or die "IO::Compress::Zip failed: $ZipError\n";
726 It returns an C<IO::Compress::Zip> object on success and undef on failure.
727 The variable C<$ZipError> will contain an error message on failure.
729 If you are running Perl 5.005 or better the object, C<$z>, returned from
730 IO::Compress::Zip can be used exactly like an L<IO::File|IO::File> filehandle.
731 This means that all normal output file operations can be carried out
733 For example, to write to a compressed file/buffer you can use either of
736 $z->print("hello world\n");
737 print $z "hello world\n";
739 The mandatory parameter C<$output> is used to control the destination
740 of the compressed data. This parameter can take one of these forms.
746 If the C<$output> parameter is a simple scalar, it is assumed to be a
747 filename. This file will be opened for writing and the compressed data
748 will be written to it.
752 If the C<$output> parameter is a filehandle, the compressed data will be
754 The string '-' can be used as an alias for standard output.
757 =item A scalar reference
759 If C<$output> is a scalar reference, the compressed data will be stored
764 If the C<$output> parameter is any other type, C<IO::Compress::Zip>::new will
767 =head2 Constructor Options
769 C<OPTS> is any combination of the following options:
773 =item AutoClose =E<gt> 0|1
775 This option is only valid when the C<$output> parameter is a filehandle. If
776 specified, and the value is true, it will result in the C<$output> being
777 closed once either the C<close> method is called or the C<IO::Compress::Zip>
780 This parameter defaults to 0.
782 =item Append =E<gt> 0|1
784 Opens C<$output> in append mode.
786 The behaviour of this option is dependent on the type of C<$output>.
792 If C<$output> is a buffer and C<Append> is enabled, all compressed data
793 will be append to the end if C<$output>. Otherwise C<$output> will be
794 cleared before any data is written to it.
798 If C<$output> is a filename and C<Append> is enabled, the file will be
799 opened in append mode. Otherwise the contents of the file, if any, will be
800 truncated before any compressed data is written to it.
804 If C<$output> is a filehandle, the file pointer will be positioned to the
805 end of the file via a call to C<seek> before any compressed data is written
806 to it. Otherwise the file pointer will not be moved.
810 This parameter defaults to 0.
814 =item -Name =E<gt> $string
816 Stores the contents of C<$string> in the zip filename header field. If
817 C<Name> is not specified, no zip filename field will be created.
819 =item -Time =E<gt> $number
821 Sets the last modified time field in the zip header to $number.
823 This field defaults to the time the C<IO::Compress::Zip> object was created
824 if this option is not specified.
826 =item Method =E<gt> $method
828 Controls which compression method is used. At present three compression
829 methods are supported, namely Store (no compression at all), Deflate and
832 The symbols, ZIP_CM_STORE, ZIP_CM_DEFLATE and ZIP_CM_BZIP2 are used to
833 select the compression method.
835 These constants are not imported by C<IO::Compress::Zip> by default.
837 use IO::Compress::Zip qw(:zip_method);
838 use IO::Compress::Zip qw(:constants);
839 use IO::Compress::Zip qw(:all);
841 Note that to create Bzip2 content, the module C<IO::Compress::Bzip2> must
842 be installed. A fatal error will be thrown if you attempt to create Bzip2
843 content when C<IO::Compress::Bzip2> is not available.
845 The default method is ZIP_CM_DEFLATE.
847 =item -Stream =E<gt> 0|1
849 This option controls whether the zip file/buffer output is created in
854 =item BlockSize100K =E<gt> number
856 Specify the number of 100K blocks bzip2 uses during compression.
858 Valid values are from 1 to 9, where 9 is best compression.
860 This option is only valid if the C<Method> is ZIP_CM_BZIP2. It is ignored
865 =item WorkFactor =E<gt> number
867 Specifies how much effort bzip2 should take before resorting to a slower
868 fallback compression algorithm.
870 Valid values range from 0 to 250, where 0 means use the default value 30.
872 This option is only valid if the C<Method> is ZIP_CM_BZIP2. It is ignored
882 Defines the compression level used by zlib. The value should either be
883 a number between 0 and 9 (0 means no compression and 9 is maximum
884 compression), or one of the symbolic constants defined below.
889 Z_DEFAULT_COMPRESSION
891 The default is Z_DEFAULT_COMPRESSION.
893 Note, these constants are not imported by C<IO::Compress::Zip> by default.
895 use IO::Compress::Zip qw(:strategy);
896 use IO::Compress::Zip qw(:constants);
897 use IO::Compress::Zip qw(:all);
901 Defines the strategy used to tune the compression. Use one of the symbolic
902 constants defined below.
910 The default is Z_DEFAULT_STRATEGY.
917 =item -Strict =E<gt> 0|1
921 This is a placeholder option.
940 Compresses and outputs the contents of the C<$data> parameter. This
941 has the same behaviour as the C<print> built-in.
943 Returns true if successful.
949 $z->printf($format, $data)
950 printf $z $format, $data
952 Compresses and outputs the contents of the C<$data> parameter.
954 Returns true if successful.
961 $z->syswrite $data, $length
962 $z->syswrite $data, $length, $offset
964 Compresses and outputs the contents of the C<$data> parameter.
966 Returns the number of uncompressed bytes written, or C<undef> if
974 $z->write $data, $length
975 $z->write $data, $length, $offset
977 Compresses and outputs the contents of the C<$data> parameter.
979 Returns the number of uncompressed bytes written, or C<undef> if
988 $z->flush($flush_type);
991 Flushes any pending compressed data to the output file/buffer.
994 This method takes an optional parameter, C<$flush_type>, that controls
995 how the flushing will be carried out. By default the C<$flush_type>
996 used is C<Z_FINISH>. Other valid values for C<$flush_type> are
997 C<Z_NO_FLUSH>, C<Z_SYNC_FLUSH>, C<Z_FULL_FLUSH> and C<Z_BLOCK>. It is
998 strongly recommended that you only set the C<flush_type> parameter if
999 you fully understand the implications of what it does - overuse of C<flush>
1000 can seriously degrade the level of compression achieved. See the C<zlib>
1001 documentation for details.
1004 Returns true on success.
1014 Returns the uncompressed file offset.
1025 Returns true if the C<close> method has been called.
1031 $z->seek($position, $whence);
1032 seek($z, $position, $whence);
1037 Provides a sub-set of the C<seek> functionality, with the restriction
1038 that it is only legal to seek forward in the output file/buffer.
1039 It is a fatal error to attempt to seek backward.
1041 Empty parts of the file/buffer will have NULL (0x00) bytes written to them.
1045 The C<$whence> parameter takes one the usual values, namely SEEK_SET,
1046 SEEK_CUR or SEEK_END.
1048 Returns 1 on success, 0 on failure.
1057 This is a noop provided for completeness.
1063 Returns true if the object currently refers to a opened file/buffer.
1067 my $prev = $z->autoflush()
1068 my $prev = $z->autoflush(EXPR)
1070 If the C<$z> object is associated with a file or a filehandle, this method
1071 returns the current autoflush setting for the underlying filehandle. If
1072 C<EXPR> is present, and is non-zero, it will enable flushing after every
1073 write/print operation.
1075 If C<$z> is associated with a buffer, this method has no effect and always
1078 B<Note> that the special variable C<$|> B<cannot> be used to set or
1079 retrieve the autoflush setting.
1081 =head2 input_line_number
1083 $z->input_line_number()
1084 $z->input_line_number(EXPR)
1087 This method always returns C<undef> when compressing.
1096 If the C<$z> object is associated with a file or a filehandle, this method
1097 will return the underlying file descriptor.
1099 If the C<$z> object is is associated with a buffer, this method will
1109 Flushes any pending compressed data and then closes the output file/buffer.
1113 For most versions of Perl this method will be automatically invoked if
1114 the IO::Compress::Zip object is destroyed (either explicitly or by the
1115 variable with the reference to the object going out of scope). The
1116 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
1117 these cases, the C<close> method will be called automatically, but
1118 not until global destruction of all live objects when the program is
1121 Therefore, if you want your scripts to be able to run on all versions
1122 of Perl, you should call C<close> explicitly and not rely on automatic
1125 Returns true on success, otherwise 0.
1127 If the C<AutoClose> option has been enabled when the IO::Compress::Zip
1128 object was created, and the object is associated with a file, the
1129 underlying file will also be closed.
1134 =head2 newStream([OPTS])
1138 $z->newStream( [OPTS] )
1140 Closes the current compressed data stream and starts a new one.
1142 OPTS consists of the following sub-set of the the options that are
1143 available when creating the C<$z> object,
1156 =head2 deflateParams
1168 A number of symbolic constants are required by some methods in
1169 C<IO::Compress::Zip>. None are imported by default.
1178 Imports C<zip>, C<$ZipError> and all symbolic
1179 constants that can be used by C<IO::Compress::Zip>. Same as doing this
1181 use IO::Compress::Zip qw(zip $ZipError :constants) ;
1185 Import all symbolic constants. Same as doing this
1188 use IO::Compress::Zip qw(:flush :level :strategy :zip_method) ;
1193 These symbolic constants are used by the C<flush> method.
1204 These symbolic constants are used by the C<Level> option in the constructor.
1209 Z_DEFAULT_COMPRESSION
1214 These symbolic constants are used by the C<Strategy> option in the constructor.
1225 These symbolic constants are used by the C<Method> option in the
1250 L<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Compress::Deflate>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>
1252 L<Compress::Zlib::FAQ|Compress::Zlib::FAQ>
1254 L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
1255 L<Archive::Tar|Archive::Tar>,
1256 L<IO::Zlib|IO::Zlib>
1259 For RFC 1950, 1951 and 1952 see
1260 F<http://www.faqs.org/rfcs/rfc1950.html>,
1261 F<http://www.faqs.org/rfcs/rfc1951.html> and
1262 F<http://www.faqs.org/rfcs/rfc1952.html>
1264 The I<zlib> compression library was written by Jean-loup Gailly
1265 F<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.
1267 The primary site for the I<zlib> compression library is
1268 F<http://www.zlib.org>.
1270 The primary site for gzip is F<http://www.gzip.org>.
1277 This module was written by Paul Marquess, F<pmqs@cpan.org>.
1281 =head1 MODIFICATION HISTORY
1283 See the Changes file.
1285 =head1 COPYRIGHT AND LICENSE
1287 Copyright (c) 2005-2006 Paul Marquess. All rights reserved.
1289 This program is free software; you can redistribute it and/or
1290 modify it under the same terms as Perl itself.