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