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