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