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