← Index
NYTProf Performance Profile   « block view • line view • sub view »
For ddd2.pl
  Run on Tue May 25 16:52:24 2010
Reported on Tue May 25 16:57:05 2010

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