📄 io::uncompress::anyinflate.3
字号:
concatenation of all the uncompressed data from each of the inputfiles/buffers..Sh "Optional Parameters".IX Subsection "Optional Parameters"Unless specified below, the optional parameters for \f(CW\*(C`anyinflate\*(C'\fR,\&\f(CW\*(C`OPTS\*(C'\fR, are the same as those used with the \s-1OO\s0 interface defined in the\&\*(L"Constructor Options\*(R" section below..ie n .IP """AutoClose => 0|1""" 5.el .IP "\f(CWAutoClose => 0|1\fR" 5.IX Item "AutoClose => 0|1"This option applies to any input or output data streams to \&\f(CW\*(C`anyinflate\*(C'\fR that are filehandles..SpIf \f(CW\*(C`AutoClose\*(C'\fR is specified, and the value is true, it will result in allinput and/or output filehandles being closed once \f(CW\*(C`anyinflate\*(C'\fR hascompleted..SpThis parameter defaults to 0..ie n .IP """BinModeOut => 0|1""" 5.el .IP "\f(CWBinModeOut => 0|1\fR" 5.IX Item "BinModeOut => 0|1"When writing to a file or filehandle, set \f(CW\*(C`binmode\*(C'\fR before writing to thefile..SpDefaults to 0..ie n .IP """Append => 0|1""" 5.el .IP "\f(CWAppend => 0|1\fR" 5.IX Item "Append => 0|1"\&\s-1TODO\s0.ie n .IP """MultiStream => 0|1""" 5.el .IP "\f(CWMultiStream => 0|1\fR" 5.IX Item "MultiStream => 0|1"If the input file/buffer contains multiple compressed data streams, thisoption will uncompress the whole lot as a single data stream..SpDefaults to 0..ie n .IP """TrailingData => $scalar""" 5.el .IP "\f(CWTrailingData => $scalar\fR" 5.IX Item "TrailingData => $scalar"Returns the data, if any, that is present immediately after the compresseddata stream once uncompression is complete..SpThis option can be used when there is useful information immediatelyfollowing the compressed data stream, and you don't know the length of thecompressed data stream..SpIf the input is a buffer, \f(CW\*(C`trailingData\*(C'\fR will return everything from theend of the compressed data stream to the end of the buffer..SpIf the input is a filehandle, \f(CW\*(C`trailingData\*(C'\fR will return the data that isleft in the filehandle input buffer once the end of the compressed datastream has been reached. You can then use the filehandle to read the restof the input file..SpDon't bother using \f(CW\*(C`trailingData\*(C'\fR if the input is a filename..SpIf you know the length of the compressed data stream before you startuncompressing, you can avoid having to use \f(CW\*(C`trailingData\*(C'\fR by setting the\&\f(CW\*(C`InputLength\*(C'\fR option..Sh "Examples".IX Subsection "Examples"To read the contents of the file \f(CW\*(C`file1.txt.Compressed\*(C'\fR and write thecompressed data to the file \f(CW\*(C`file1.txt\*(C'\fR..PP.Vb 3\& use strict ;\& use warnings ;\& use IO::Uncompress::AnyInflate qw(anyinflate $AnyInflateError) ;\&\& my $input = "file1.txt.Compressed";\& my $output = "file1.txt";\& anyinflate $input => $output\& or die "anyinflate failed: $AnyInflateError\en";.Ve.PPTo read from an existing Perl filehandle, \f(CW$input\fR, and write theuncompressed data to a buffer, \f(CW$buffer\fR..PP.Vb 4\& use strict ;\& use warnings ;\& use IO::Uncompress::AnyInflate qw(anyinflate $AnyInflateError) ;\& use IO::File ;\&\& my $input = new IO::File "<file1.txt.Compressed"\& or die "Cannot open \*(Aqfile1.txt.Compressed\*(Aq: $!\en" ;\& my $buffer ;\& anyinflate $input => \e$buffer \& or die "anyinflate failed: $AnyInflateError\en";.Ve.PPTo uncompress all files in the directory \*(L"/my/home\*(R" that match \*(L"*.txt.Compressed\*(R" and store the compressed data in the same directory.PP.Vb 3\& use strict ;\& use warnings ;\& use IO::Uncompress::AnyInflate qw(anyinflate $AnyInflateError) ;\&\& anyinflate \*(Aq</my/home/*.txt.Compressed>\*(Aq => \*(Aq</my/home/#1.txt>\*(Aq\& or die "anyinflate failed: $AnyInflateError\en";.Ve.PPand if you want to compress each file one at a time, this will do the trick.PP.Vb 3\& use strict ;\& use warnings ;\& use IO::Uncompress::AnyInflate qw(anyinflate $AnyInflateError) ;\&\& for my $input ( glob "/my/home/*.txt.Compressed" )\& {\& my $output = $input;\& $output =~ s/.Compressed// ;\& anyinflate $input => $output \& or die "Error compressing \*(Aq$input\*(Aq: $AnyInflateError\en";\& }.Ve.SH "OO Interface".IX Header "OO Interface".Sh "Constructor".IX Subsection "Constructor"The format of the constructor for IO::Uncompress::AnyInflate is shown below.PP.Vb 2\& my $z = new IO::Uncompress::AnyInflate $input [OPTS]\& or die "IO::Uncompress::AnyInflate failed: $AnyInflateError\en";.Ve.PPReturns an \f(CW\*(C`IO::Uncompress::AnyInflate\*(C'\fR object on success and undef on failure.The variable \f(CW$AnyInflateError\fR will contain an error message on failure..PPIf you are running Perl 5.005 or better the object, \f(CW$z\fR, returned fromIO::Uncompress::AnyInflate can be used exactly like an IO::File filehandle.This means that all normal input file operations can be carried out with\&\f(CW$z\fR. For example, to read a line from a compressed file/buffer you canuse either of these forms.PP.Vb 2\& $line = $z\->getline();\& $line = <$z>;.Ve.PPThe mandatory parameter \f(CW$input\fR is used to determine the source of thecompressed data. This parameter can take one of three forms..IP "A filename" 5.IX Item "A filename"If the \f(CW$input\fR parameter is a scalar, it is assumed to be a filename. Thisfile will be opened for reading and the compressed data will be read from it..IP "A filehandle" 5.IX Item "A filehandle"If the \f(CW$input\fR parameter is a filehandle, the compressed data will beread from it.The string '\-' can be used as an alias for standard input..IP "A scalar reference" 5.IX Item "A scalar reference"If \f(CW$input\fR is a scalar reference, the compressed data will be read from\&\f(CW$$output\fR..Sh "Constructor Options".IX Subsection "Constructor Options"The option names defined below are case insensitive and can be optionallyprefixed by a '\-'. So all of the following are valid.PP.Vb 4\& \-AutoClose\& \-autoclose\& AUTOCLOSE\& autoclose.Ve.PP\&\s-1OPTS\s0 is a combination of the following options:.ie n .IP """AutoClose => 0|1""" 5.el .IP "\f(CWAutoClose => 0|1\fR" 5.IX Item "AutoClose => 0|1"This option is only valid when the \f(CW$input\fR parameter is a filehandle. Ifspecified, and the value is true, it will result in the file being closed onceeither the \f(CW\*(C`close\*(C'\fR method is called or the IO::Uncompress::AnyInflate object isdestroyed..SpThis parameter defaults to 0..ie n .IP """MultiStream => 0|1""" 5.el .IP "\f(CWMultiStream => 0|1\fR" 5.IX Item "MultiStream => 0|1"Allows multiple concatenated compressed streams to be treated as a singlecompressed stream. Decompression will stop once either the end of thefile/buffer is reached, an error is encountered (premature eof, corruptcompressed data) or the end of a stream is not immediately followed by thestart of another stream..SpThis parameter defaults to 0..ie n .IP """Prime => $string""" 5.el .IP "\f(CWPrime => $string\fR" 5.IX Item "Prime => $string"This option will uncompress the contents of \f(CW$string\fR before processing theinput file/buffer..SpThis option can be useful when the compressed data is embedded in anotherfile/data structure and it is not possible to work out where the compresseddata begins without having to read the first few bytes. If this is thecase, the uncompression can be \fIprimed\fR with these bytes using thisoption..ie n .IP """Transparent => 0|1""" 5.el .IP "\f(CWTransparent => 0|1\fR" 5.IX Item "Transparent => 0|1"If this option is set and the input file/buffer is not compressed data,the module will allow reading of it anyway..SpIn addition, if the input file/buffer does contain compressed data andthere is non-compressed data immediately following it, setting this optionwill make this module treat the whole file/bufffer as a single data stream..SpThis option defaults to 1..ie n .IP """BlockSize => $num""" 5.el .IP "\f(CWBlockSize => $num\fR" 5.IX Item "BlockSize => $num"When reading the compressed input data, IO::Uncompress::AnyInflate will read it inblocks of \f(CW$num\fR bytes..SpThis option defaults to 4096..ie n .IP """InputLength => $size""" 5.el .IP "\f(CWInputLength => $size\fR" 5.IX Item "InputLength => $size"When present this option will limit the number of compressed bytes readfrom the input file/buffer to \f(CW$size\fR. This option can be used in thesituation where there is useful data directly after the compressed datastream and you know beforehand the exact length of the compressed datastream..SpThis option is mostly used when reading from a filehandle, in which casethe file pointer will be left pointing to the first byte directly after thecompressed data stream..SpThis option defaults to off..ie n .IP """Append => 0|1""" 5.el .IP "\f(CWAppend => 0|1\fR" 5.IX Item "Append => 0|1"This option controls what the \f(CW\*(C`read\*(C'\fR method does with uncompressed data..SpIf set to 1, all uncompressed data will be appended to the output parameterof the \f(CW\*(C`read\*(C'\fR method..SpIf set to 0, the contents of the output parameter of the \f(CW\*(C`read\*(C'\fR methodwill be overwritten by the uncompressed data..SpDefaults to 0..ie n .IP """Strict => 0|1""" 5.el .IP "\f(CWStrict => 0|1\fR" 5.IX Item "Strict => 0|1"This option controls whether the extra checks defined below are used whencarrying out the decompression. When Strict is on, the extra tests arecarried out, when Strict is off they are not..SpThe default for this option is off..SpIf the input is an \s-1RFC\s0 1950 data stream, the following will be checked:.RS 5.IP "1." 5The \s-1ADLER32\s0 checksum field must be present..IP "2." 5The value of the \s-1ADLER32\s0 field read must match the adler32 value of theuncompressed data actually contained in the file..RE.RS 5.SpIf the input is a gzip (\s-1RFC\s0 1952) data stream, the following will be checked:.IP "1." 5If the \s-1FHCRC\s0 bit is set in the gzip \s-1FLG\s0 header byte, the \s-1CRC16\s0 bytes in theheader must match the crc16 value of the gzip header actually read..IP "2." 5If the gzip header contains a name field (\s-1FNAME\s0) it consists solely of \s-1ISO\s08859\-1 characters..IP "3." 5If the gzip header contains a comment field (\s-1FCOMMENT\s0) it consists solelyof \s-1ISO\s0 8859\-1 characters plus line-feed..IP "4." 5If the gzip \s-1FEXTRA\s0 header field is present it must conform to the sub-fieldstructure as defined in \s-1RFC\s0 1952..IP "5." 5The \s-1CRC32\s0 and \s-1ISIZE\s0 trailer fields must be present..IP "6." 5The value of the \s-1CRC32\s0 field read must match the crc32 value of theuncompressed data actually contained in the gzip file..IP "7." 5The value of the \s-1ISIZE\s0 fields read must match the length of theuncompressed data actually read from the file..RE.RS 5.RE.ie n .IP """RawInflate => 0|1""" 5.el .IP "\f(CWRawInflate => 0|1\fR" 5.IX Item "RawInflate => 0|1"When auto-detecting the compressed format, try to test for raw-deflate (\s-1RFC\s01951) content using the \f(CW\*(C`IO::Uncompress::RawInflate\*(C'\fR module..SpThe reason this is not default behaviour is because \s-1RFC\s0 1951 content canonly be detected by attempting to uncompress it. This process is errorprone and can result is false positives..SpDefaults to 0..ie n .IP """ParseExtra => 0|1"" If the gzip \s-1FEXTRA\s0 header field is present and this option is set, it will force the module to check that it conforms to the sub-field structure as defined in \s-1RFC\s0 1952." 5.el .IP "\f(CWParseExtra => 0|1\fR If the gzip \s-1FEXTRA\s0 header field is present and this option is set, it will force the module to check that it conforms to the sub-field structure as defined in \s-1RFC\s0 1952." 5.IX Item "ParseExtra => 0|1 If the gzip FEXTRA header field is present and this option is set, it will force the module to check that it conforms to the sub-field structure as defined in RFC 1952."If the \f(CW\*(C`Strict\*(C'\fR is on it will automatically enable this option..SpDefaults to 0..Sh "Examples".IX Subsection "Examples"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -