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