2 package IO::Compress::Gzip ;
11 use IO::Compress::RawDeflate 2.021 ;
13 use Compress::Raw::Zlib 2.021 ;
14 use IO::Compress::Base::Common 2.021 qw(:Status :Parse createSelfTiedObject);
15 use IO::Compress::Gzip::Constants 2.021 ;
16 use IO::Compress::Zlib::Extra 2.021 ;
20 if (defined &utf8::downgrade )
21 { *noUTF8 = \&utf8::downgrade }
28 our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $GzipError);
33 @ISA = qw(Exporter IO::Compress::RawDeflate);
34 @EXPORT_OK = qw( $GzipError gzip ) ;
35 %EXPORT_TAGS = %IO::Compress::RawDeflate::DEFLATE_CONSTANTS ;
36 push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
37 Exporter::export_ok_tags('all');
43 my $obj = createSelfTiedObject($class, \$GzipError);
45 $obj->_create(undef, @_);
51 my $obj = createSelfTiedObject(undef, \$GzipError);
52 return $obj->_def(@_);
58 # #return GZIP_MINIMUM_HEADER ;
59 # return $self->mkHeader(*$self->{Got});
68 $self->getZlibParams(),
71 'Minimal' => [0, 1, Parse_boolean, 0],
72 'Comment' => [0, 1, Parse_any, undef],
73 'Name' => [0, 1, Parse_any, undef],
74 'Time' => [0, 1, Parse_any, undef],
75 'TextFlag' => [0, 1, Parse_boolean, 0],
76 'HeaderCRC' => [0, 1, Parse_boolean, 0],
77 'OS_Code' => [0, 1, Parse_unsigned, $Compress::Raw::Zlib::gzip_os_code],
78 'ExtraField'=> [0, 1, Parse_any, undef],
79 'ExtraFlags'=> [0, 1, Parse_any, undef],
90 # gzip always needs crc32
91 $got->value('CRC32' => 1);
94 if $got->value('Merge') ;
96 my $strict = $got->value('Strict') ;
100 if (! $got->parsed('Time') ) {
101 # Modification time defaults to now.
102 $got->value('Time' => time) ;
105 # Check that the Name & Comment don't have embedded NULLs
106 # Also check that they only contain ISO 8859-1 chars.
107 if ($got->parsed('Name') && defined $got->value('Name')) {
108 my $name = $got->value('Name');
110 return $self->saveErrorString(undef, "Null Character found in Name",
112 if $strict && $name =~ /\x00/ ;
114 return $self->saveErrorString(undef, "Non ISO 8859-1 Character found in Name",
116 if $strict && $name =~ /$GZIP_FNAME_INVALID_CHAR_RE/o ;
119 if ($got->parsed('Comment') && defined $got->value('Comment')) {
120 my $comment = $got->value('Comment');
122 return $self->saveErrorString(undef, "Null Character found in Comment",
124 if $strict && $comment =~ /\x00/ ;
126 return $self->saveErrorString(undef, "Non ISO 8859-1 Character found in Comment",
128 if $strict && $comment =~ /$GZIP_FCOMMENT_INVALID_CHAR_RE/o;
131 if ($got->parsed('OS_Code') ) {
132 my $value = $got->value('OS_Code');
134 return $self->saveErrorString(undef, "OS_Code must be between 0 and 255, got '$value'")
135 if $value < 0 || $value > 255 ;
139 # gzip only supports Deflate at present
140 $got->value('Method' => Z_DEFLATED) ;
142 if ( ! $got->parsed('ExtraFlags')) {
143 $got->value('ExtraFlags' => 2)
144 if $got->value('Level') == Z_BEST_SPEED ;
145 $got->value('ExtraFlags' => 4)
146 if $got->value('Level') == Z_BEST_COMPRESSION ;
149 my $data = $got->value('ExtraField') ;
151 my $bad = IO::Compress::Zlib::Extra::parseExtraField($data, $strict, 1) ;
152 return $self->saveErrorString(undef, "Error with ExtraField Parameter: $bad", Z_DATA_ERROR)
155 $got->value('ExtraField', $data) ;
165 return pack("V V", *$self->{Compress}->crc32(),
166 *$self->{UnCompSize}->get32bit());
171 return ('IO::Uncompress::Gunzip',
172 \$IO::Uncompress::Gunzip::GunzipError);
179 my $filename = shift ;
181 my $defaultTime = (stat($filename))[9] ;
183 $params->value('Name' => $filename)
184 if ! $params->parsed('Name') ;
186 $params->value('Time' => $defaultTime)
187 if ! $params->parsed('Time') ;
196 # stort-circuit if a minimal header is requested.
197 return GZIP_MINIMUM_HEADER if $param->value('Minimal') ;
200 my $method = $param->valueOrDefault('Method', GZIP_CM_DEFLATED) ;
203 my $flags = GZIP_FLG_DEFAULT ;
204 $flags |= GZIP_FLG_FTEXT if $param->value('TextFlag') ;
205 $flags |= GZIP_FLG_FHCRC if $param->value('HeaderCRC') ;
206 $flags |= GZIP_FLG_FEXTRA if $param->wantValue('ExtraField') ;
207 $flags |= GZIP_FLG_FNAME if $param->wantValue('Name') ;
208 $flags |= GZIP_FLG_FCOMMENT if $param->wantValue('Comment') ;
211 my $time = $param->valueOrDefault('Time', GZIP_MTIME_DEFAULT) ;
214 my $extra_flags = $param->valueOrDefault('ExtraFlags', GZIP_XFL_DEFAULT);
217 my $os_code = $param->valueOrDefault('OS_Code', GZIP_OS_DEFAULT) ;
220 my $out = pack("C4 V C C",
223 $method, # Compression Method
225 $time, # Modification Time
226 $extra_flags, # Extra Flags
227 $os_code, # Operating System Code
231 if ($flags & GZIP_FLG_FEXTRA) {
232 my $extra = $param->value('ExtraField') ;
233 $out .= pack("v", length $extra) . $extra ;
237 if ($flags & GZIP_FLG_FNAME) {
238 my $name .= $param->value('Name') ;
239 $name =~ s/\x00.*$//;
241 # Terminate the filename with NULL unless it already is
242 $out .= GZIP_NULL_BYTE
244 substr($name, 1, -1) ne GZIP_NULL_BYTE ;
248 if ($flags & GZIP_FLG_FCOMMENT) {
249 my $comment .= $param->value('Comment') ;
250 $comment =~ s/\x00.*$//;
252 # Terminate the comment with NULL unless it already is
253 $out .= GZIP_NULL_BYTE
254 if ! length $comment or
255 substr($comment, 1, -1) ne GZIP_NULL_BYTE;
259 $out .= pack("v", crc32($out) & 0x00FF ) if $param->value('HeaderCRC') ;
277 IO::Compress::Gzip - Write RFC 1952 files/buffers
283 use IO::Compress::Gzip qw(gzip $GzipError) ;
285 my $status = gzip $input => $output [,OPTS]
286 or die "gzip failed: $GzipError\n";
288 my $z = new IO::Compress::Gzip $output [,OPTS]
289 or die "gzip failed: $GzipError\n";
292 $z->printf($format, $string);
294 $z->syswrite($string [, $length, $offset]);
298 $z->seek($position, $whence);
303 $z->input_line_number();
304 $z->newStream( [OPTS] );
315 printf $z $format, $string;
318 seek $z, $position, $whence
326 This module provides a Perl interface that allows writing compressed
327 data to files or buffer as defined in RFC 1952.
329 All the gzip headers defined in RFC 1952 can be created using
332 For reading RFC 1952 files/buffers, see the companion module
333 L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip>.
335 =head1 Functional Interface
337 A top-level function, C<gzip>, is provided to carry out
338 "one-shot" compression between buffers and/or files. For finer
339 control over the compression process, see the L</"OO Interface">
342 use IO::Compress::Gzip qw(gzip $GzipError) ;
344 gzip $input => $output [,OPTS]
345 or die "gzip failed: $GzipError\n";
347 The functional interface needs Perl5.005 or better.
349 =head2 gzip $input => $output [, OPTS]
351 C<gzip> expects at least two parameters, C<$input> and C<$output>.
353 =head3 The C<$input> parameter
355 The parameter, C<$input>, is used to define the source of
356 the uncompressed data.
358 It can take one of the following forms:
364 If the C<$input> parameter is a simple scalar, it is assumed to be a
365 filename. This file will be opened for reading and the input data
366 will be read from it.
370 If the C<$input> parameter is a filehandle, the input data will be
372 The string '-' can be used as an alias for standard input.
374 =item A scalar reference
376 If C<$input> is a scalar reference, the input data will be read
379 =item An array reference
381 If C<$input> is an array reference, each element in the array must be a
384 The input data will be read from each file in turn.
386 The complete array will be walked to ensure that it only
387 contains valid filenames before any data is compressed.
389 =item An Input FileGlob string
391 If C<$input> is a string that is delimited by the characters "<" and ">"
392 C<gzip> will assume that it is an I<input fileglob string>. The
393 input is the list of files that match the fileglob.
395 If the fileglob does not match any files ...
397 See L<File::GlobMapper|File::GlobMapper> for more details.
401 If the C<$input> parameter is any other type, C<undef> will be returned.
403 In addition, if C<$input> is a simple filename, the default values for
404 the C<Name> and C<Time> options will be sourced from that file.
406 If you do not want to use these defaults they can be overridden by
407 explicitly setting the C<Name> and C<Time> options or by setting the
408 C<Minimal> parameter.
410 =head3 The C<$output> parameter
412 The parameter C<$output> is used to control the destination of the
413 compressed data. This parameter can take one of these forms.
419 If the C<$output> parameter is a simple scalar, it is assumed to be a
420 filename. This file will be opened for writing and the compressed
421 data will be written to it.
425 If the C<$output> parameter is a filehandle, the compressed data
426 will be written to it.
427 The string '-' can be used as an alias for standard output.
429 =item A scalar reference
431 If C<$output> is a scalar reference, the compressed data will be
432 stored in C<$$output>.
434 =item An Array Reference
436 If C<$output> is an array reference, the compressed data will be
437 pushed onto the array.
439 =item An Output FileGlob
441 If C<$output> is a string that is delimited by the characters "<" and ">"
442 C<gzip> will assume that it is an I<output fileglob string>. The
443 output is the list of files that match the fileglob.
445 When C<$output> is an fileglob string, C<$input> must also be a fileglob
446 string. Anything else is an error.
450 If the C<$output> parameter is any other type, C<undef> will be returned.
454 When C<$input> maps to multiple files/buffers and C<$output> is a single
455 file/buffer the input files/buffers will be stored
456 in C<$output> as a concatenated series of compressed data streams.
458 =head2 Optional Parameters
460 Unless specified below, the optional parameters for C<gzip>,
461 C<OPTS>, are the same as those used with the OO interface defined in the
462 L</"Constructor Options"> section below.
466 =item C<< AutoClose => 0|1 >>
468 This option applies to any input or output data streams to
469 C<gzip> that are filehandles.
471 If C<AutoClose> is specified, and the value is true, it will result in all
472 input and/or output filehandles being closed once C<gzip> has
475 This parameter defaults to 0.
477 =item C<< BinModeIn => 0|1 >>
479 When reading from a file or filehandle, set C<binmode> before reading.
483 =item C<< Append => 0|1 >>
491 To read the contents of the file C<file1.txt> and write the compressed
492 data to the file C<file1.txt.gz>.
496 use IO::Compress::Gzip qw(gzip $GzipError) ;
498 my $input = "file1.txt";
499 gzip $input => "$input.gz"
500 or die "gzip failed: $GzipError\n";
502 To read from an existing Perl filehandle, C<$input>, and write the
503 compressed data to a buffer, C<$buffer>.
507 use IO::Compress::Gzip qw(gzip $GzipError) ;
510 my $input = new IO::File "<file1.txt"
511 or die "Cannot open 'file1.txt': $!\n" ;
513 gzip $input => \$buffer
514 or die "gzip failed: $GzipError\n";
516 To compress all files in the directory "/my/home" that match "*.txt"
517 and store the compressed data in the same directory
521 use IO::Compress::Gzip qw(gzip $GzipError) ;
523 gzip '</my/home/*.txt>' => '<*.gz>'
524 or die "gzip failed: $GzipError\n";
526 and if you want to compress each file one at a time, this will do the trick
530 use IO::Compress::Gzip qw(gzip $GzipError) ;
532 for my $input ( glob "/my/home/*.txt" )
534 my $output = "$input.gz" ;
535 gzip $input => $output
536 or die "Error compressing '$input': $GzipError\n";
543 The format of the constructor for C<IO::Compress::Gzip> is shown below
545 my $z = new IO::Compress::Gzip $output [,OPTS]
546 or die "IO::Compress::Gzip failed: $GzipError\n";
548 It returns an C<IO::Compress::Gzip> object on success and undef on failure.
549 The variable C<$GzipError> will contain an error message on failure.
551 If you are running Perl 5.005 or better the object, C<$z>, returned from
552 IO::Compress::Gzip can be used exactly like an L<IO::File|IO::File> filehandle.
553 This means that all normal output file operations can be carried out
555 For example, to write to a compressed file/buffer you can use either of
558 $z->print("hello world\n");
559 print $z "hello world\n";
561 The mandatory parameter C<$output> is used to control the destination
562 of the compressed data. This parameter can take one of these forms.
568 If the C<$output> parameter is a simple scalar, it is assumed to be a
569 filename. This file will be opened for writing and the compressed data
570 will be written to it.
574 If the C<$output> parameter is a filehandle, the compressed data will be
576 The string '-' can be used as an alias for standard output.
578 =item A scalar reference
580 If C<$output> is a scalar reference, the compressed data will be stored
585 If the C<$output> parameter is any other type, C<IO::Compress::Gzip>::new will
588 =head2 Constructor Options
590 C<OPTS> is any combination of the following options:
594 =item C<< AutoClose => 0|1 >>
596 This option is only valid when the C<$output> parameter is a filehandle. If
597 specified, and the value is true, it will result in the C<$output> being
598 closed once either the C<close> method is called or the C<IO::Compress::Gzip>
601 This parameter defaults to 0.
603 =item C<< Append => 0|1 >>
605 Opens C<$output> in append mode.
607 The behaviour of this option is dependent on the type of C<$output>.
613 If C<$output> is a buffer and C<Append> is enabled, all compressed data
614 will be append to the end if C<$output>. Otherwise C<$output> will be
615 cleared before any data is written to it.
619 If C<$output> is a filename and C<Append> is enabled, the file will be
620 opened in append mode. Otherwise the contents of the file, if any, will be
621 truncated before any compressed data is written to it.
625 If C<$output> is a filehandle, the file pointer will be positioned to the
626 end of the file via a call to C<seek> before any compressed data is written
627 to it. Otherwise the file pointer will not be moved.
631 This parameter defaults to 0.
633 =item C<< Merge => 0|1 >>
635 This option is used to compress input data and append it to an existing
636 compressed data stream in C<$output>. The end result is a single compressed
637 data stream stored in C<$output>.
639 It is a fatal error to attempt to use this option when C<$output> is not an
640 RFC 1952 data stream.
642 There are a number of other limitations with the C<Merge> option:
648 This module needs to have been built with zlib 1.2.1 or better to work. A
649 fatal error will be thrown if C<Merge> is used with an older version of
654 If C<$output> is a file or a filehandle, it must be seekable.
658 This parameter defaults to 0.
662 Defines the compression level used by zlib. The value should either be
663 a number between 0 and 9 (0 means no compression and 9 is maximum
664 compression), or one of the symbolic constants defined below.
669 Z_DEFAULT_COMPRESSION
671 The default is Z_DEFAULT_COMPRESSION.
673 Note, these constants are not imported by C<IO::Compress::Gzip> by default.
675 use IO::Compress::Gzip qw(:strategy);
676 use IO::Compress::Gzip qw(:constants);
677 use IO::Compress::Gzip qw(:all);
681 Defines the strategy used to tune the compression. Use one of the symbolic
682 constants defined below.
690 The default is Z_DEFAULT_STRATEGY.
692 =item C<< Minimal => 0|1 >>
694 If specified, this option will force the creation of the smallest possible
695 compliant gzip header (which is exactly 10 bytes long) as defined in
698 See the section titled "Compliance" in RFC 1952 for a definition
699 of the values used for the fields in the gzip header.
701 All other parameters that control the content of the gzip header will
702 be ignored if this parameter is set to 1.
704 This parameter defaults to 0.
706 =item C<< Comment => $comment >>
708 Stores the contents of C<$comment> in the COMMENT field in
710 By default, no comment field is written to the gzip file.
712 If the C<-Strict> option is enabled, the comment can only consist of ISO
713 8859-1 characters plus line feed.
715 If the C<-Strict> option is disabled, the comment field can contain any
716 character except NULL. If any null characters are present, the field
717 will be truncated at the first NULL.
719 =item C<< Name => $string >>
721 Stores the contents of C<$string> in the gzip NAME header field. If
722 C<Name> is not specified, no gzip NAME field will be created.
724 If the C<-Strict> option is enabled, C<$string> can only consist of ISO
727 If C<-Strict> is disabled, then C<$string> can contain any character
728 except NULL. If any null characters are present, the field will be
729 truncated at the first NULL.
731 =item C<< Time => $number >>
733 Sets the MTIME field in the gzip header to $number.
735 This field defaults to the time the C<IO::Compress::Gzip> object was created
736 if this option is not specified.
738 =item C<< TextFlag => 0|1 >>
740 This parameter controls the setting of the FLG.FTEXT bit in the gzip
741 header. It is used to signal that the data stored in the gzip file/buffer
746 =item C<< HeaderCRC => 0|1 >>
748 When true this parameter will set the FLG.FHCRC bit to 1 in the gzip header
749 and set the CRC16 header field to the CRC of the complete gzip header
750 except the CRC16 field itself.
752 B<Note> that gzip files created with the C<HeaderCRC> flag set to 1 cannot
753 be read by most, if not all, of the the standard gunzip utilities, most
754 notably gzip version 1.2.4. You should therefore avoid using this option if
755 you want to maximize the portability of your gzip files.
757 This parameter defaults to 0.
759 =item C<< OS_Code => $value >>
761 Stores C<$value> in the gzip OS header field. A number between 0 and 255 is
764 If not specified, this parameter defaults to the OS code of the Operating
765 System this module was built on. The value 3 is used as a catch-all for all
766 Unix variants and unknown Operating Systems.
768 =item C<< ExtraField => $data >>
770 This parameter allows additional metadata to be stored in the ExtraField in
771 the gzip header. An RFC 1952 compliant ExtraField consists of zero or more
772 subfields. Each subfield consists of a two byte header followed by the
775 The list of subfields can be supplied in any of the following formats
777 -ExtraField => [$id1, $data1,
781 -ExtraField => [ [$id1 => $data1],
785 -ExtraField => { $id1 => $data1,
790 Where C<$id1>, C<$id2> are two byte subfield ID's. The second byte of
791 the ID cannot be 0, unless the C<Strict> option has been disabled.
793 If you use the hash syntax, you have no control over the order in which
794 the ExtraSubFields are stored, plus you cannot have SubFields with
797 Alternatively the list of subfields can by supplied as a scalar, thus
799 -ExtraField => $rawdata
801 If you use the raw format, and the C<Strict> option is enabled,
802 C<IO::Compress::Gzip> will check that C<$rawdata> consists of zero or more
803 conformant sub-fields. When C<Strict> is disabled, C<$rawdata> can
804 consist of any arbitrary byte stream.
806 The maximum size of the Extra Field 65535 bytes.
808 =item C<< ExtraFlags => $value >>
810 Sets the XFL byte in the gzip header to C<$value>.
812 If this option is not present, the value stored in XFL field will be
813 determined by the setting of the C<Level> option.
815 If C<< Level => Z_BEST_SPEED >> has been specified then XFL is set to 2.
816 If C<< Level => Z_BEST_COMPRESSION >> has been specified then XFL is set to 4.
817 Otherwise XFL is set to 0.
819 =item C<< Strict => 0|1 >>
821 C<Strict> will optionally police the values supplied with other options
822 to ensure they are compliant with RFC1952.
824 This option is enabled by default.
826 If C<Strict> is enabled the following behaviour will be policed:
832 The value supplied with the C<Name> option can only contain ISO 8859-1
837 The value supplied with the C<Comment> option can only contain ISO 8859-1
838 characters plus line-feed.
842 The values supplied with the C<-Name> and C<-Comment> options cannot
843 contain multiple embedded nulls.
847 If an C<ExtraField> option is specified and it is a simple scalar,
848 it must conform to the sub-field structure as defined in RFC 1952.
852 If an C<ExtraField> option is specified the second byte of the ID will be
853 checked in each subfield to ensure that it does not contain the reserved
858 When C<Strict> is disabled the following behaviour will be policed:
864 The value supplied with C<-Name> option can contain
865 any character except NULL.
869 The value supplied with C<-Comment> option can contain any character
874 The values supplied with the C<-Name> and C<-Comment> options can contain
875 multiple embedded nulls. The string written to the gzip header will
876 consist of the characters up to, but not including, the first embedded
881 If an C<ExtraField> option is specified and it is a simple scalar, the
882 structure will not be checked. The only error is if the length is too big.
886 The ID header in an C<ExtraField> sub-field can consist of any two bytes.
905 Compresses and outputs the contents of the C<$data> parameter. This
906 has the same behaviour as the C<print> built-in.
908 Returns true if successful.
914 $z->printf($format, $data)
915 printf $z $format, $data
917 Compresses and outputs the contents of the C<$data> parameter.
919 Returns true if successful.
926 $z->syswrite $data, $length
927 $z->syswrite $data, $length, $offset
929 Compresses and outputs the contents of the C<$data> parameter.
931 Returns the number of uncompressed bytes written, or C<undef> if
939 $z->write $data, $length
940 $z->write $data, $length, $offset
942 Compresses and outputs the contents of the C<$data> parameter.
944 Returns the number of uncompressed bytes written, or C<undef> if
952 $z->flush($flush_type);
954 Flushes any pending compressed data to the output file/buffer.
956 This method takes an optional parameter, C<$flush_type>, that controls
957 how the flushing will be carried out. By default the C<$flush_type>
958 used is C<Z_FINISH>. Other valid values for C<$flush_type> are
959 C<Z_NO_FLUSH>, C<Z_SYNC_FLUSH>, C<Z_FULL_FLUSH> and C<Z_BLOCK>. It is
960 strongly recommended that you only set the C<flush_type> parameter if
961 you fully understand the implications of what it does - overuse of C<flush>
962 can seriously degrade the level of compression achieved. See the C<zlib>
963 documentation for details.
965 Returns true on success.
974 Returns the uncompressed file offset.
983 Returns true if the C<close> method has been called.
987 $z->seek($position, $whence);
988 seek($z, $position, $whence);
990 Provides a sub-set of the C<seek> functionality, with the restriction
991 that it is only legal to seek forward in the output file/buffer.
992 It is a fatal error to attempt to seek backward.
994 Empty parts of the file/buffer will have NULL (0x00) bytes written to them.
996 The C<$whence> parameter takes one the usual values, namely SEEK_SET,
997 SEEK_CUR or SEEK_END.
999 Returns 1 on success, 0 on failure.
1008 This is a noop provided for completeness.
1014 Returns true if the object currently refers to a opened file/buffer.
1018 my $prev = $z->autoflush()
1019 my $prev = $z->autoflush(EXPR)
1021 If the C<$z> object is associated with a file or a filehandle, this method
1022 returns the current autoflush setting for the underlying filehandle. If
1023 C<EXPR> is present, and is non-zero, it will enable flushing after every
1024 write/print operation.
1026 If C<$z> is associated with a buffer, this method has no effect and always
1029 B<Note> that the special variable C<$|> B<cannot> be used to set or
1030 retrieve the autoflush setting.
1032 =head2 input_line_number
1034 $z->input_line_number()
1035 $z->input_line_number(EXPR)
1037 This method always returns C<undef> when compressing.
1044 If the C<$z> object is associated with a file or a filehandle, C<fileno>
1045 will return the underlying file descriptor. Once the C<close> method is
1046 called C<fileno> will return C<undef>.
1048 If the C<$z> object is is associated with a buffer, this method will return
1056 Flushes any pending compressed data and then closes the output file/buffer.
1058 For most versions of Perl this method will be automatically invoked if
1059 the IO::Compress::Gzip object is destroyed (either explicitly or by the
1060 variable with the reference to the object going out of scope). The
1061 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
1062 these cases, the C<close> method will be called automatically, but
1063 not until global destruction of all live objects when the program is
1066 Therefore, if you want your scripts to be able to run on all versions
1067 of Perl, you should call C<close> explicitly and not rely on automatic
1070 Returns true on success, otherwise 0.
1072 If the C<AutoClose> option has been enabled when the IO::Compress::Gzip
1073 object was created, and the object is associated with a file, the
1074 underlying file will also be closed.
1076 =head2 newStream([OPTS])
1080 $z->newStream( [OPTS] )
1082 Closes the current compressed data stream and starts a new one.
1084 OPTS consists of any of the the options that are available when creating
1087 See the L</"Constructor Options"> section for more details.
1089 =head2 deflateParams
1099 A number of symbolic constants are required by some methods in
1100 C<IO::Compress::Gzip>. None are imported by default.
1106 Imports C<gzip>, C<$GzipError> and all symbolic
1107 constants that can be used by C<IO::Compress::Gzip>. Same as doing this
1109 use IO::Compress::Gzip qw(gzip $GzipError :constants) ;
1113 Import all symbolic constants. Same as doing this
1115 use IO::Compress::Gzip qw(:flush :level :strategy) ;
1119 These symbolic constants are used by the C<flush> method.
1130 These symbolic constants are used by the C<Level> option in the constructor.
1135 Z_DEFAULT_COMPRESSION
1139 These symbolic constants are used by the C<Strategy> option in the constructor.
1154 =head2 Apache::GZip Revisited
1156 See L<IO::Compress::FAQ|IO::Compress::FAQ/"Apache::GZip Revisited">
1160 =head2 Working with Net::FTP
1162 See L<IO::Compress::FAQ|IO::Compress::FAQ/"Compressed files and Net::FTP">
1166 L<Compress::Zlib>, 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::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>
1168 L<Compress::Zlib::FAQ|Compress::Zlib::FAQ>
1170 L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
1171 L<Archive::Tar|Archive::Tar>,
1172 L<IO::Zlib|IO::Zlib>
1174 For RFC 1950, 1951 and 1952 see
1175 F<http://www.faqs.org/rfcs/rfc1950.html>,
1176 F<http://www.faqs.org/rfcs/rfc1951.html> and
1177 F<http://www.faqs.org/rfcs/rfc1952.html>
1179 The I<zlib> compression library was written by Jean-loup Gailly
1180 F<gzip@prep.ai.mit.edu> and Mark Adler F<madler@alumni.caltech.edu>.
1182 The primary site for the I<zlib> compression library is
1183 F<http://www.zlib.org>.
1185 The primary site for gzip is F<http://www.gzip.org>.
1189 This module was written by Paul Marquess, F<pmqs@cpan.org>.
1191 =head1 MODIFICATION HISTORY
1193 See the Changes file.
1195 =head1 COPYRIGHT AND LICENSE
1197 Copyright (c) 2005-2009 Paul Marquess. All rights reserved.
1199 This program is free software; you can redistribute it and/or
1200 modify it under the same terms as Perl itself.