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