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