"Fossies" - the Fresh Open Source Software Archive

Member "install-tl-20200916/tlpkg/tlperl/lib/IO/Compress/Deflate.pm" (7 Mar 2020, 23652 Bytes) of package /windows/misc/install-tl.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 package IO::Compress::Deflate ;
    2 
    3 require 5.006 ;
    4 
    5 use strict ;
    6 use warnings;
    7 use bytes;
    8 
    9 require Exporter ;
   10 
   11 use IO::Compress::RawDeflate 2.084 ();
   12 use IO::Compress::Adapter::Deflate 2.084 ;
   13 
   14 use IO::Compress::Zlib::Constants 2.084 ;
   15 use IO::Compress::Base::Common  2.084 qw();
   16 
   17 
   18 our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $DeflateError);
   19 
   20 $VERSION = '2.084';
   21 $DeflateError = '';
   22 
   23 @ISA    = qw(IO::Compress::RawDeflate Exporter);
   24 @EXPORT_OK = qw( $DeflateError deflate ) ;
   25 %EXPORT_TAGS = %IO::Compress::RawDeflate::DEFLATE_CONSTANTS ;
   26 
   27 push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
   28 Exporter::export_ok_tags('all');
   29 
   30 
   31 sub new
   32 {
   33     my $class = shift ;
   34 
   35     my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$DeflateError);
   36     return $obj->_create(undef, @_);
   37 }
   38 
   39 sub deflate
   40 {
   41     my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$DeflateError);
   42     return $obj->_def(@_);
   43 }
   44 
   45 
   46 sub bitmask($$$$)
   47 {
   48     my $into  = shift ;
   49     my $value  = shift ;
   50     my $offset = shift ;
   51     my $mask   = shift ;
   52 
   53     return $into | (($value & $mask) << $offset ) ;
   54 }
   55 
   56 sub mkDeflateHdr($$$;$)
   57 {
   58     my $method = shift ;
   59     my $cinfo  = shift;
   60     my $level  = shift;
   61     my $fdict_adler = shift  ;
   62 
   63     my $cmf = 0;
   64     my $flg = 0;
   65     my $fdict = 0;
   66     $fdict = 1 if defined $fdict_adler;
   67 
   68     $cmf = bitmask($cmf, $method, ZLIB_CMF_CM_OFFSET,    ZLIB_CMF_CM_BITS);
   69     $cmf = bitmask($cmf, $cinfo,  ZLIB_CMF_CINFO_OFFSET, ZLIB_CMF_CINFO_BITS);
   70 
   71     $flg = bitmask($flg, $fdict,  ZLIB_FLG_FDICT_OFFSET, ZLIB_FLG_FDICT_BITS);
   72     $flg = bitmask($flg, $level,  ZLIB_FLG_LEVEL_OFFSET, ZLIB_FLG_LEVEL_BITS);
   73 
   74     my $fcheck = 31 - ($cmf * 256 + $flg) % 31 ;
   75     $flg = bitmask($flg, $fcheck, ZLIB_FLG_FCHECK_OFFSET, ZLIB_FLG_FCHECK_BITS);
   76 
   77     my $hdr =  pack("CC", $cmf, $flg) ;
   78     $hdr .= pack("N", $fdict_adler) if $fdict ;
   79 
   80     return $hdr;
   81 }
   82 
   83 sub mkHeader 
   84 {
   85     my $self = shift ;
   86     my $param = shift ;
   87 
   88     my $level = $param->getValue('level');
   89     my $strategy = $param->getValue('strategy');
   90 
   91     my $lflag ;
   92     $level = 6 
   93         if $level == Z_DEFAULT_COMPRESSION ;
   94 
   95     if (ZLIB_VERNUM >= 0x1210)
   96     {
   97         if ($strategy >= Z_HUFFMAN_ONLY || $level < 2)
   98          {  $lflag = ZLIB_FLG_LEVEL_FASTEST }
   99         elsif ($level < 6)
  100          {  $lflag = ZLIB_FLG_LEVEL_FAST }
  101         elsif ($level == 6)
  102          {  $lflag = ZLIB_FLG_LEVEL_DEFAULT }
  103         else
  104          {  $lflag = ZLIB_FLG_LEVEL_SLOWEST }
  105     }
  106     else
  107     {
  108         $lflag = ($level - 1) >> 1 ;
  109         $lflag = 3 if $lflag > 3 ;
  110     }
  111 
  112      #my $wbits = (MAX_WBITS - 8) << 4 ;
  113     my $wbits = 7;
  114     mkDeflateHdr(ZLIB_CMF_CM_DEFLATED, $wbits, $lflag);
  115 }
  116 
  117 sub ckParams
  118 {
  119     my $self = shift ;
  120     my $got = shift;
  121     
  122     $got->setValue('adler32' => 1);
  123     return 1 ;
  124 }
  125 
  126 
  127 sub mkTrailer
  128 {
  129     my $self = shift ;
  130     return pack("N", *$self->{Compress}->adler32()) ;
  131 }
  132 
  133 sub mkFinalTrailer
  134 {
  135     return '';
  136 }
  137 
  138 #sub newHeader
  139 #{
  140 #    my $self = shift ;
  141 #    return *$self->{Header};
  142 #}
  143 
  144 sub getExtraParams
  145 {
  146     my $self = shift ;
  147     return $self->getZlibParams(),
  148 }
  149 
  150 sub getInverseClass
  151 {
  152     return ('IO::Uncompress::Inflate',
  153                 \$IO::Uncompress::Inflate::InflateError);
  154 }
  155 
  156 sub getFileInfo
  157 {
  158     my $self = shift ;
  159     my $params = shift;
  160     my $file = shift ;
  161     
  162 }
  163 
  164 
  165 
  166 1;
  167 
  168 __END__
  169 
  170 =head1 NAME
  171 
  172 IO::Compress::Deflate - Write RFC 1950 files/buffers
  173 
  174 =head1 SYNOPSIS
  175 
  176     use IO::Compress::Deflate qw(deflate $DeflateError) ;
  177 
  178     my $status = deflate $input => $output [,OPTS]
  179         or die "deflate failed: $DeflateError\n";
  180 
  181     my $z = new IO::Compress::Deflate $output [,OPTS]
  182         or die "deflate failed: $DeflateError\n";
  183 
  184     $z->print($string);
  185     $z->printf($format, $string);
  186     $z->write($string);
  187     $z->syswrite($string [, $length, $offset]);
  188     $z->flush();
  189     $z->tell();
  190     $z->eof();
  191     $z->seek($position, $whence);
  192     $z->binmode();
  193     $z->fileno();
  194     $z->opened();
  195     $z->autoflush();
  196     $z->input_line_number();
  197     $z->newStream( [OPTS] );
  198 
  199     $z->deflateParams();
  200 
  201     $z->close() ;
  202 
  203     $DeflateError ;
  204 
  205     # IO::File mode
  206 
  207     print $z $string;
  208     printf $z $format, $string;
  209     tell $z
  210     eof $z
  211     seek $z, $position, $whence
  212     binmode $z
  213     fileno $z
  214     close $z ;
  215  
  216 
  217 =head1 DESCRIPTION
  218 
  219 This module provides a Perl interface that allows writing compressed
  220 data to files or buffer as defined in RFC 1950.
  221 
  222 For reading RFC 1950 files/buffers, see the companion module
  223 L<IO::Uncompress::Inflate|IO::Uncompress::Inflate>.
  224 
  225 =head1 Functional Interface
  226 
  227 A top-level function, C<deflate>, is provided to carry out
  228 "one-shot" compression between buffers and/or files. For finer
  229 control over the compression process, see the L</"OO Interface">
  230 section.
  231 
  232     use IO::Compress::Deflate qw(deflate $DeflateError) ;
  233 
  234     deflate $input_filename_or_reference => $output_filename_or_reference [,OPTS]
  235         or die "deflate failed: $DeflateError\n";
  236 
  237 The functional interface needs Perl5.005 or better.
  238 
  239 =head2 deflate $input_filename_or_reference => $output_filename_or_reference [, OPTS]
  240 
  241 C<deflate> expects at least two parameters,
  242 C<$input_filename_or_reference> and C<$output_filename_or_reference>.
  243 
  244 =head3 The C<$input_filename_or_reference> parameter
  245 
  246 The parameter, C<$input_filename_or_reference>, is used to define the
  247 source of the uncompressed data.
  248 
  249 It can take one of the following forms:
  250 
  251 =over 5
  252 
  253 =item A filename
  254 
  255 If the <$input_filename_or_reference> parameter is a simple scalar, it is
  256 assumed to be a filename. This file will be opened for reading and the
  257 input data will be read from it.
  258 
  259 =item A filehandle
  260 
  261 If the C<$input_filename_or_reference> parameter is a filehandle, the input
  262 data will be read from it.  The string '-' can be used as an alias for
  263 standard input.
  264 
  265 =item A scalar reference
  266 
  267 If C<$input_filename_or_reference> is a scalar reference, the input data
  268 will be read from C<$$input_filename_or_reference>.
  269 
  270 =item An array reference
  271 
  272 If C<$input_filename_or_reference> is an array reference, each element in
  273 the array must be a filename.
  274 
  275 The input data will be read from each file in turn.
  276 
  277 The complete array will be walked to ensure that it only
  278 contains valid filenames before any data is compressed.
  279 
  280 =item An Input FileGlob string
  281 
  282 If C<$input_filename_or_reference> is a string that is delimited by the
  283 characters "<" and ">" C<deflate> will assume that it is an
  284 I<input fileglob string>. The input is the list of files that match the
  285 fileglob.
  286 
  287 See L<File::GlobMapper|File::GlobMapper> for more details.
  288 
  289 =back
  290 
  291 If the C<$input_filename_or_reference> parameter is any other type,
  292 C<undef> will be returned.
  293 
  294 =head3 The C<$output_filename_or_reference> parameter
  295 
  296 The parameter C<$output_filename_or_reference> is used to control the
  297 destination of the compressed data. This parameter can take one of
  298 these forms.
  299 
  300 =over 5
  301 
  302 =item A filename
  303 
  304 If the C<$output_filename_or_reference> parameter is a simple scalar, it is
  305 assumed to be a filename.  This file will be opened for writing and the
  306 compressed data will be written to it.
  307 
  308 =item A filehandle
  309 
  310 If the C<$output_filename_or_reference> parameter is a filehandle, the
  311 compressed data will be written to it.  The string '-' can be used as
  312 an alias for standard output.
  313 
  314 =item A scalar reference
  315 
  316 If C<$output_filename_or_reference> is a scalar reference, the
  317 compressed data will be stored in C<$$output_filename_or_reference>.
  318 
  319 =item An Array Reference
  320 
  321 If C<$output_filename_or_reference> is an array reference,
  322 the compressed data will be pushed onto the array.
  323 
  324 =item An Output FileGlob
  325 
  326 If C<$output_filename_or_reference> is a string that is delimited by the
  327 characters "<" and ">" C<deflate> will assume that it is an
  328 I<output fileglob string>. The output is the list of files that match the
  329 fileglob.
  330 
  331 When C<$output_filename_or_reference> is an fileglob string,
  332 C<$input_filename_or_reference> must also be a fileglob string. Anything
  333 else is an error.
  334 
  335 See L<File::GlobMapper|File::GlobMapper> for more details.
  336 
  337 =back
  338 
  339 If the C<$output_filename_or_reference> parameter is any other type,
  340 C<undef> will be returned.
  341 
  342 =head2 Notes
  343 
  344 When C<$input_filename_or_reference> maps to multiple files/buffers and
  345 C<$output_filename_or_reference> is a single
  346 file/buffer the input files/buffers will be stored
  347 in C<$output_filename_or_reference> as a concatenated series of compressed data streams.
  348 
  349 =head2 Optional Parameters
  350 
  351 Unless specified below, the optional parameters for C<deflate>,
  352 C<OPTS>, are the same as those used with the OO interface defined in the
  353 L</"Constructor Options"> section below.
  354 
  355 =over 5
  356 
  357 =item C<< AutoClose => 0|1 >>
  358 
  359 This option applies to any input or output data streams to
  360 C<deflate> that are filehandles.
  361 
  362 If C<AutoClose> is specified, and the value is true, it will result in all
  363 input and/or output filehandles being closed once C<deflate> has
  364 completed.
  365 
  366 This parameter defaults to 0.
  367 
  368 =item C<< BinModeIn => 0|1 >>
  369 
  370 This option is now a no-op. All files will be read in binmode.
  371 
  372 =item C<< Append => 0|1 >>
  373 
  374 The behaviour of this option is dependent on the type of output data
  375 stream.
  376 
  377 =over 5
  378 
  379 =item * A Buffer
  380 
  381 If C<Append> is enabled, all compressed data will be append to the end of
  382 the output buffer. Otherwise the output buffer will be cleared before any
  383 compressed data is written to it.
  384 
  385 =item * A Filename
  386 
  387 If C<Append> is enabled, the file will be opened in append mode. Otherwise
  388 the contents of the file, if any, will be truncated before any compressed
  389 data is written to it.
  390 
  391 =item * A Filehandle
  392 
  393 If C<Append> is enabled, the filehandle will be positioned to the end of
  394 the file via a call to C<seek> before any compressed data is
  395 written to it.  Otherwise the file pointer will not be moved.
  396 
  397 =back
  398 
  399 When C<Append> is specified, and set to true, it will I<append> all compressed
  400 data to the output data stream.
  401 
  402 So when the output is a filehandle it will carry out a seek to the eof
  403 before writing any compressed data. If the output is a filename, it will be opened for
  404 appending. If the output is a buffer, all compressed data will be
  405 appended to the existing buffer.
  406 
  407 Conversely when C<Append> is not specified, or it is present and is set to
  408 false, it will operate as follows.
  409 
  410 When the output is a filename, it will truncate the contents of the file
  411 before writing any compressed data. If the output is a filehandle
  412 its position will not be changed. If the output is a buffer, it will be
  413 wiped before any compressed data is output.
  414 
  415 Defaults to 0.
  416 
  417 =back
  418 
  419 =head2 Examples
  420 
  421 To read the contents of the file C<file1.txt> and write the compressed
  422 data to the file C<file1.txt.1950>.
  423 
  424     use strict ;
  425     use warnings ;
  426     use IO::Compress::Deflate qw(deflate $DeflateError) ;
  427 
  428     my $input = "file1.txt";
  429     deflate $input => "$input.1950"
  430         or die "deflate failed: $DeflateError\n";
  431 
  432 To read from an existing Perl filehandle, C<$input>, and write the
  433 compressed data to a buffer, C<$buffer>.
  434 
  435     use strict ;
  436     use warnings ;
  437     use IO::Compress::Deflate qw(deflate $DeflateError) ;
  438     use IO::File ;
  439 
  440     my $input = new IO::File "<file1.txt"
  441         or die "Cannot open 'file1.txt': $!\n" ;
  442     my $buffer ;
  443     deflate $input => \$buffer
  444         or die "deflate failed: $DeflateError\n";
  445 
  446 To compress all files in the directory "/my/home" that match "*.txt"
  447 and store the compressed data in the same directory
  448 
  449     use strict ;
  450     use warnings ;
  451     use IO::Compress::Deflate qw(deflate $DeflateError) ;
  452 
  453     deflate '</my/home/*.txt>' => '<*.1950>'
  454         or die "deflate failed: $DeflateError\n";
  455 
  456 and if you want to compress each file one at a time, this will do the trick
  457 
  458     use strict ;
  459     use warnings ;
  460     use IO::Compress::Deflate qw(deflate $DeflateError) ;
  461 
  462     for my $input ( glob "/my/home/*.txt" )
  463     {
  464         my $output = "$input.1950" ;
  465         deflate $input => $output
  466             or die "Error compressing '$input': $DeflateError\n";
  467     }
  468 
  469 =head1 OO Interface
  470 
  471 =head2 Constructor
  472 
  473 The format of the constructor for C<IO::Compress::Deflate> is shown below
  474 
  475     my $z = new IO::Compress::Deflate $output [,OPTS]
  476         or die "IO::Compress::Deflate failed: $DeflateError\n";
  477 
  478 It returns an C<IO::Compress::Deflate> object on success and undef on failure.
  479 The variable C<$DeflateError> will contain an error message on failure.
  480 
  481 If you are running Perl 5.005 or better the object, C<$z>, returned from
  482 IO::Compress::Deflate can be used exactly like an L<IO::File|IO::File> filehandle.
  483 This means that all normal output file operations can be carried out
  484 with C<$z>.
  485 For example, to write to a compressed file/buffer you can use either of
  486 these forms
  487 
  488     $z->print("hello world\n");
  489     print $z "hello world\n";
  490 
  491 The mandatory parameter C<$output> is used to control the destination
  492 of the compressed data. This parameter can take one of these forms.
  493 
  494 =over 5
  495 
  496 =item A filename
  497 
  498 If the C<$output> parameter is a simple scalar, it is assumed to be a
  499 filename. This file will be opened for writing and the compressed data
  500 will be written to it.
  501 
  502 =item A filehandle
  503 
  504 If the C<$output> parameter is a filehandle, the compressed data will be
  505 written to it.
  506 The string '-' can be used as an alias for standard output.
  507 
  508 =item A scalar reference
  509 
  510 If C<$output> is a scalar reference, the compressed data will be stored
  511 in C<$$output>.
  512 
  513 =back
  514 
  515 If the C<$output> parameter is any other type, C<IO::Compress::Deflate>::new will
  516 return undef.
  517 
  518 =head2 Constructor Options
  519 
  520 C<OPTS> is any combination of the following options:
  521 
  522 =over 5
  523 
  524 =item C<< AutoClose => 0|1 >>
  525 
  526 This option is only valid when the C<$output> parameter is a filehandle. If
  527 specified, and the value is true, it will result in the C<$output> being
  528 closed once either the C<close> method is called or the C<IO::Compress::Deflate>
  529 object is destroyed.
  530 
  531 This parameter defaults to 0.
  532 
  533 =item C<< Append => 0|1 >>
  534 
  535 Opens C<$output> in append mode.
  536 
  537 The behaviour of this option is dependent on the type of C<$output>.
  538 
  539 =over 5
  540 
  541 =item * A Buffer
  542 
  543 If C<$output> is a buffer and C<Append> is enabled, all compressed data
  544 will be append to the end of C<$output>. Otherwise C<$output> will be
  545 cleared before any data is written to it.
  546 
  547 =item * A Filename
  548 
  549 If C<$output> is a filename and C<Append> is enabled, the file will be
  550 opened in append mode. Otherwise the contents of the file, if any, will be
  551 truncated before any compressed data is written to it.
  552 
  553 =item * A Filehandle
  554 
  555 If C<$output> is a filehandle, the file pointer will be positioned to the
  556 end of the file via a call to C<seek> before any compressed data is written
  557 to it.  Otherwise the file pointer will not be moved.
  558 
  559 =back
  560 
  561 This parameter defaults to 0.
  562 
  563 =item C<< Merge => 0|1 >>
  564 
  565 This option is used to compress input data and append it to an existing
  566 compressed data stream in C<$output>. The end result is a single compressed
  567 data stream stored in C<$output>.
  568 
  569 It is a fatal error to attempt to use this option when C<$output> is not an
  570 RFC 1950 data stream.
  571 
  572 There are a number of other limitations with the C<Merge> option:
  573 
  574 =over 5
  575 
  576 =item 1
  577 
  578 This module needs to have been built with zlib 1.2.1 or better to work. A
  579 fatal error will be thrown if C<Merge> is used with an older version of
  580 zlib.
  581 
  582 =item 2
  583 
  584 If C<$output> is a file or a filehandle, it must be seekable.
  585 
  586 =back
  587 
  588 This parameter defaults to 0.
  589 
  590 =item -Level
  591 
  592 Defines the compression level used by zlib. The value should either be
  593 a number between 0 and 9 (0 means no compression and 9 is maximum
  594 compression), or one of the symbolic constants defined below.
  595 
  596    Z_NO_COMPRESSION
  597    Z_BEST_SPEED
  598    Z_BEST_COMPRESSION
  599    Z_DEFAULT_COMPRESSION
  600 
  601 The default is Z_DEFAULT_COMPRESSION.
  602 
  603 Note, these constants are not imported by C<IO::Compress::Deflate> by default.
  604 
  605     use IO::Compress::Deflate qw(:strategy);
  606     use IO::Compress::Deflate qw(:constants);
  607     use IO::Compress::Deflate qw(:all);
  608 
  609 =item -Strategy
  610 
  611 Defines the strategy used to tune the compression. Use one of the symbolic
  612 constants defined below.
  613 
  614    Z_FILTERED
  615    Z_HUFFMAN_ONLY
  616    Z_RLE
  617    Z_FIXED
  618    Z_DEFAULT_STRATEGY
  619 
  620 The default is Z_DEFAULT_STRATEGY.
  621 
  622 =item C<< Strict => 0|1 >>
  623 
  624 This is a placeholder option.
  625 
  626 =back
  627 
  628 =head2 Examples
  629 
  630 TODO
  631 
  632 =head1 Methods
  633 
  634 =head2 print
  635 
  636 Usage is
  637 
  638     $z->print($data)
  639     print $z $data
  640 
  641 Compresses and outputs the contents of the C<$data> parameter. This
  642 has the same behaviour as the C<print> built-in.
  643 
  644 Returns true if successful.
  645 
  646 =head2 printf
  647 
  648 Usage is
  649 
  650     $z->printf($format, $data)
  651     printf $z $format, $data
  652 
  653 Compresses and outputs the contents of the C<$data> parameter.
  654 
  655 Returns true if successful.
  656 
  657 =head2 syswrite
  658 
  659 Usage is
  660 
  661     $z->syswrite $data
  662     $z->syswrite $data, $length
  663     $z->syswrite $data, $length, $offset
  664 
  665 Compresses and outputs the contents of the C<$data> parameter.
  666 
  667 Returns the number of uncompressed bytes written, or C<undef> if
  668 unsuccessful.
  669 
  670 =head2 write
  671 
  672 Usage is
  673 
  674     $z->write $data
  675     $z->write $data, $length
  676     $z->write $data, $length, $offset
  677 
  678 Compresses and outputs the contents of the C<$data> parameter.
  679 
  680 Returns the number of uncompressed bytes written, or C<undef> if
  681 unsuccessful.
  682 
  683 =head2 flush
  684 
  685 Usage is
  686 
  687     $z->flush;
  688     $z->flush($flush_type);
  689 
  690 Flushes any pending compressed data to the output file/buffer.
  691 
  692 This method takes an optional parameter, C<$flush_type>, that controls
  693 how the flushing will be carried out. By default the C<$flush_type>
  694 used is C<Z_FINISH>. Other valid values for C<$flush_type> are
  695 C<Z_NO_FLUSH>, C<Z_SYNC_FLUSH>, C<Z_FULL_FLUSH> and C<Z_BLOCK>. It is
  696 strongly recommended that you only set the C<flush_type> parameter if
  697 you fully understand the implications of what it does - overuse of C<flush>
  698 can seriously degrade the level of compression achieved. See the C<zlib>
  699 documentation for details.
  700 
  701 Returns true on success.
  702 
  703 =head2 tell
  704 
  705 Usage is
  706 
  707     $z->tell()
  708     tell $z
  709 
  710 Returns the uncompressed file offset.
  711 
  712 =head2 eof
  713 
  714 Usage is
  715 
  716     $z->eof();
  717     eof($z);
  718 
  719 Returns true if the C<close> method has been called.
  720 
  721 =head2 seek
  722 
  723     $z->seek($position, $whence);
  724     seek($z, $position, $whence);
  725 
  726 Provides a sub-set of the C<seek> functionality, with the restriction
  727 that it is only legal to seek forward in the output file/buffer.
  728 It is a fatal error to attempt to seek backward.
  729 
  730 Empty parts of the file/buffer will have NULL (0x00) bytes written to them.
  731 
  732 The C<$whence> parameter takes one the usual values, namely SEEK_SET,
  733 SEEK_CUR or SEEK_END.
  734 
  735 Returns 1 on success, 0 on failure.
  736 
  737 =head2 binmode
  738 
  739 Usage is
  740 
  741     $z->binmode
  742     binmode $z ;
  743 
  744 This is a noop provided for completeness.
  745 
  746 =head2 opened
  747 
  748     $z->opened()
  749 
  750 Returns true if the object currently refers to a opened file/buffer.
  751 
  752 =head2 autoflush
  753 
  754     my $prev = $z->autoflush()
  755     my $prev = $z->autoflush(EXPR)
  756 
  757 If the C<$z> object is associated with a file or a filehandle, this method
  758 returns the current autoflush setting for the underlying filehandle. If
  759 C<EXPR> is present, and is non-zero, it will enable flushing after every
  760 write/print operation.
  761 
  762 If C<$z> is associated with a buffer, this method has no effect and always
  763 returns C<undef>.
  764 
  765 B<Note> that the special variable C<$|> B<cannot> be used to set or
  766 retrieve the autoflush setting.
  767 
  768 =head2 input_line_number
  769 
  770     $z->input_line_number()
  771     $z->input_line_number(EXPR)
  772 
  773 This method always returns C<undef> when compressing.
  774 
  775 =head2 fileno
  776 
  777     $z->fileno()
  778     fileno($z)
  779 
  780 If the C<$z> object is associated with a file or a filehandle, C<fileno>
  781 will return the underlying file descriptor. Once the C<close> method is
  782 called C<fileno> will return C<undef>.
  783 
  784 If the C<$z> object is associated with a buffer, this method will return
  785 C<undef>.
  786 
  787 =head2 close
  788 
  789     $z->close() ;
  790     close $z ;
  791 
  792 Flushes any pending compressed data and then closes the output file/buffer.
  793 
  794 For most versions of Perl this method will be automatically invoked if
  795 the IO::Compress::Deflate object is destroyed (either explicitly or by the
  796 variable with the reference to the object going out of scope). The
  797 exceptions are Perl versions 5.005 through 5.00504 and 5.8.0. In
  798 these cases, the C<close> method will be called automatically, but
  799 not until global destruction of all live objects when the program is
  800 terminating.
  801 
  802 Therefore, if you want your scripts to be able to run on all versions
  803 of Perl, you should call C<close> explicitly and not rely on automatic
  804 closing.
  805 
  806 Returns true on success, otherwise 0.
  807 
  808 If the C<AutoClose> option has been enabled when the IO::Compress::Deflate
  809 object was created, and the object is associated with a file, the
  810 underlying file will also be closed.
  811 
  812 =head2 newStream([OPTS])
  813 
  814 Usage is
  815 
  816     $z->newStream( [OPTS] )
  817 
  818 Closes the current compressed data stream and starts a new one.
  819 
  820 OPTS consists of any of the options that are available when creating
  821 the C<$z> object.
  822 
  823 See the L</"Constructor Options"> section for more details.
  824 
  825 =head2 deflateParams
  826 
  827 Usage is
  828 
  829     $z->deflateParams
  830 
  831 TODO
  832 
  833 =head1 Importing
  834 
  835 A number of symbolic constants are required by some methods in
  836 C<IO::Compress::Deflate>. None are imported by default.
  837 
  838 =over 5
  839 
  840 =item :all
  841 
  842 Imports C<deflate>, C<$DeflateError> and all symbolic
  843 constants that can be used by C<IO::Compress::Deflate>. Same as doing this
  844 
  845     use IO::Compress::Deflate qw(deflate $DeflateError :constants) ;
  846 
  847 =item :constants
  848 
  849 Import all symbolic constants. Same as doing this
  850 
  851     use IO::Compress::Deflate qw(:flush :level :strategy) ;
  852 
  853 =item :flush
  854 
  855 These symbolic constants are used by the C<flush> method.
  856 
  857     Z_NO_FLUSH
  858     Z_PARTIAL_FLUSH
  859     Z_SYNC_FLUSH
  860     Z_FULL_FLUSH
  861     Z_FINISH
  862     Z_BLOCK
  863 
  864 =item :level
  865 
  866 These symbolic constants are used by the C<Level> option in the constructor.
  867 
  868     Z_NO_COMPRESSION
  869     Z_BEST_SPEED
  870     Z_BEST_COMPRESSION
  871     Z_DEFAULT_COMPRESSION
  872 
  873 =item :strategy
  874 
  875 These symbolic constants are used by the C<Strategy> option in the constructor.
  876 
  877     Z_FILTERED
  878     Z_HUFFMAN_ONLY
  879     Z_RLE
  880     Z_FIXED
  881     Z_DEFAULT_STRATEGY
  882 
  883 =back
  884 
  885 =head1 EXAMPLES
  886 
  887 =head2 Apache::GZip Revisited
  888 
  889 See L<IO::Compress::FAQ|IO::Compress::FAQ/"Apache::GZip Revisited">
  890 
  891 =head2 Working with Net::FTP
  892 
  893 See L<IO::Compress::FAQ|IO::Compress::FAQ/"Compressed files and Net::FTP">
  894 
  895 =head1 SEE ALSO
  896 
  897 L<Compress::Zlib>, L<IO::Compress::Gzip>, L<IO::Uncompress::Gunzip>, L<IO::Uncompress::Inflate>, L<IO::Compress::RawDeflate>, L<IO::Uncompress::RawInflate>, L<IO::Compress::Bzip2>, L<IO::Uncompress::Bunzip2>, L<IO::Compress::Lzma>, L<IO::Uncompress::UnLzma>, L<IO::Compress::Xz>, L<IO::Uncompress::UnXz>, L<IO::Compress::Lzip>, L<IO::Uncompress::UnLzip>, L<IO::Compress::Lzop>, L<IO::Uncompress::UnLzop>, L<IO::Compress::Lzf>, L<IO::Uncompress::UnLzf>, L<IO::Compress::Zstd>, L<IO::Uncompress::UnZstd>, L<IO::Uncompress::AnyInflate>, L<IO::Uncompress::AnyUncompress>
  898 
  899 L<IO::Compress::FAQ|IO::Compress::FAQ>
  900 
  901 L<File::GlobMapper|File::GlobMapper>, L<Archive::Zip|Archive::Zip>,
  902 L<Archive::Tar|Archive::Tar>,
  903 L<IO::Zlib|IO::Zlib>
  904 
  905 For RFC 1950, 1951 and 1952 see
  906 L<http://www.faqs.org/rfcs/rfc1950.html>,
  907 L<http://www.faqs.org/rfcs/rfc1951.html> and
  908 L<http://www.faqs.org/rfcs/rfc1952.html>
  909 
  910 The I<zlib> compression library was written by Jean-loup Gailly
  911 C<gzip@prep.ai.mit.edu> and Mark Adler C<madler@alumni.caltech.edu>.
  912 
  913 The primary site for the I<zlib> compression library is
  914 L<http://www.zlib.org>.
  915 
  916 The primary site for gzip is L<http://www.gzip.org>.
  917 
  918 =head1 AUTHOR
  919 
  920 This module was written by Paul Marquess, C<pmqs@cpan.org>.
  921 
  922 =head1 MODIFICATION HISTORY
  923 
  924 See the Changes file.
  925 
  926 =head1 COPYRIGHT AND LICENSE
  927 
  928 Copyright (c) 2005-2019 Paul Marquess. All rights reserved.
  929 
  930 This program is free software; you can redistribute it and/or
  931 modify it under the same terms as Perl itself.
  932