⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 archive::tar.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 3 页
字号:
of the warnings, instead of the regular \f(CW\*(C`carp\*(C'\fR. This is the samemessage you would get by doing:.PP.Vb 1\&    $tar\->error(1);.Ve.PPDefaults to \f(CW0\fR..ie n .Sh "$Archive::Tar::WARN".el .Sh "\f(CW$Archive::Tar::WARN\fP".IX Subsection "$Archive::Tar::WARN"Set this variable to \f(CW0\fR if you do not want any warnings printed.Personally I recommend against doing this, but people asked for theoption. Also, be advised that this is of course not threadsafe..PPDefaults to \f(CW1\fR..ie n .Sh "$Archive::Tar::error".el .Sh "\f(CW$Archive::Tar::error\fP".IX Subsection "$Archive::Tar::error"Holds the last reported error. Kept for historical reasons, but itsuse is very much discouraged. Use the \f(CW\*(C`error()\*(C'\fR method instead:.PP.Vb 1\&    warn $tar\->error unless $tar\->extract;.Ve.ie n .Sh "$Archive::Tar::INSECURE_EXTRACT_MODE".el .Sh "\f(CW$Archive::Tar::INSECURE_EXTRACT_MODE\fP".IX Subsection "$Archive::Tar::INSECURE_EXTRACT_MODE"This variable indicates whether \f(CW\*(C`Archive::Tar\*(C'\fR should allowfiles to be extracted outside their current working directory..PPAllowing this could have security implications, as a malicioustar archive could alter or replace any file the extracting userhas permissions to. Therefor, the default is to not allow insecure extractions..PPIf you trust the archive, or have other reasons to allow the archive to write files outside your current working directory, set this variable to \f(CW\*(C`true\*(C'\fR..PPNote that this is a backwards incompatible change from version\&\f(CW1.36\fR and before..ie n .Sh "$Archive::Tar::HAS_PERLIO".el .Sh "\f(CW$Archive::Tar::HAS_PERLIO\fP".IX Subsection "$Archive::Tar::HAS_PERLIO"This variable holds a boolean indicating if we currently have \&\f(CW\*(C`perlio\*(C'\fR support loaded. This will be enabled for any perlgreater than \f(CW5.8\fR compiled with \f(CW\*(C`perlio\*(C'\fR..PPIf you feel strongly about disabling it, set this variable to\&\f(CW\*(C`false\*(C'\fR. Note that you will then need \f(CW\*(C`IO::String\*(C'\fR installedto support writing stringified archives..PPDon't change this variable unless you \fBreally\fR know what you'redoing..ie n .Sh "$Archive::Tar::HAS_IO_STRING".el .Sh "\f(CW$Archive::Tar::HAS_IO_STRING\fP".IX Subsection "$Archive::Tar::HAS_IO_STRING"This variable holds a boolean indicating if we currently have \&\f(CW\*(C`IO::String\*(C'\fR support loaded. This will be enabled for any perlthat has a loadable \f(CW\*(C`IO::String\*(C'\fR module..PPIf you feel strongly about disabling it, set this variable to\&\f(CW\*(C`false\*(C'\fR. Note that you will then need \f(CW\*(C`perlio\*(C'\fR support fromyour perl to be able to  write stringified archives..PPDon't change this variable unless you \fBreally\fR know what you'redoing..SH "FAQ".IX Header "FAQ".IP "What's the minimum perl version required to run Archive::Tar?" 4.IX Item "What's the minimum perl version required to run Archive::Tar?"You will need perl version 5.005_03 or newer..IP "Isn't Archive::Tar slow?" 4.IX Item "Isn't Archive::Tar slow?"Yes it is. It's pure perl, so it's a lot slower then your \f(CW\*(C`/bin/tar\*(C'\fRHowever, it's very portable. If speed is an issue, consider using\&\f(CW\*(C`/bin/tar\*(C'\fR instead..IP "Isn't Archive::Tar heavier on memory than /bin/tar?" 4.IX Item "Isn't Archive::Tar heavier on memory than /bin/tar?"Yes it is, see previous answer. Since \f(CW\*(C`Compress::Zlib\*(C'\fR and therefore\&\f(CW\*(C`IO::Zlib\*(C'\fR doesn't support \f(CW\*(C`seek\*(C'\fR on their filehandles, there is littlechoice but to read the archive into memory.This is ok if you want to do in-memory manipulation of the archive.If you just want to extract, use the \f(CW\*(C`extract_archive\*(C'\fR class methodinstead. It will optimize and write to disk immediately..IP "Can't you lazy-load data instead?" 4.IX Item "Can't you lazy-load data instead?"No, not easily. See previous question..IP "How much memory will an X kb tar file need?" 4.IX Item "How much memory will an X kb tar file need?"Probably more than X kb, since it will all be read into memory. Ifthis is a problem, and you don't need to do in memory manipulationof the archive, consider using \f(CW\*(C`/bin/tar\*(C'\fR instead..IP "What do you do with unsupported filetypes in an archive?" 4.IX Item "What do you do with unsupported filetypes in an archive?"\&\f(CW\*(C`Unix\*(C'\fR has a few filetypes that aren't supported on other platforms,like \f(CW\*(C`Win32\*(C'\fR. If we encounter a \f(CW\*(C`hardlink\*(C'\fR or \f(CW\*(C`symlink\*(C'\fR we'll justtry to make a copy of the original file, rather than throwing an error..SpThis does require you to read the entire archive in to memory first,since otherwise we wouldn't know what data to fill the copy with.(This means that you cannot use the class methods on archives thathave incompatible filetypes and still expect things to work)..SpFor other filetypes, like \f(CW\*(C`chardevs\*(C'\fR and \f(CW\*(C`blockdevs\*(C'\fR we'll warn thatthe extraction of this particular item didn't work..IP "I'm using WinZip, or some other non-POSIX client, and files are not being extracted properly!" 4.IX Item "I'm using WinZip, or some other non-POSIX client, and files are not being extracted properly!"By default, \f(CW\*(C`Archive::Tar\*(C'\fR is in a completely POSIX-compatiblemode, which uses the POSIX-specification of \f(CW\*(C`tar\*(C'\fR to store files.For paths greather than 100 characters, this is done using the\&\f(CW\*(C`POSIX header prefix\*(C'\fR. Non-POSIX-compatible clients may not supportthis part of the specification, and may only support the \f(CW\*(C`GNU ExtendedHeader\*(C'\fR functionality. To facilitate those clients, you can set the\&\f(CW$Archive::Tar::DO_NOT_USE_PREFIX\fR variable to \f(CW\*(C`true\*(C'\fR. See the \&\f(CW\*(C`GLOBAL VARIABLES\*(C'\fR section for details on this variable..SpNote that \s-1GNU\s0 tar earlier than version 1.14 does not cope well withthe \f(CW\*(C`POSIX header prefix\*(C'\fR. If you use such a version, consider settingthe \f(CW$Archive::Tar::DO_NOT_USE_PREFIX\fR variable to \f(CW\*(C`true\*(C'\fR..IP "How do I extract only files that have property X from an archive?" 4.IX Item "How do I extract only files that have property X from an archive?"Sometimes, you might not wish to extract a complete archive, justthe files that are relevant to you, based on some criteria..SpYou can do this by filtering a list of \f(CW\*(C`Archive::Tar::File\*(C'\fR objectsbased on your criteria. For example, to extract only files that havethe string \f(CW\*(C`foo\*(C'\fR in their title, you would use:.Sp.Vb 3\&    $tar\->extract( \&        grep { $_\->full_path =~ /foo/ } $tar\->get_files\&    );.Ve.SpThis way, you can filter on any attribute of the files in the archive.Consult the \f(CW\*(C`Archive::Tar::File\*(C'\fR documentation on how to use theseobjects..IP "How do I access .tar.Z files?" 4.IX Item "How do I access .tar.Z files?"The \f(CW\*(C`Archive::Tar\*(C'\fR module can optionally use \f(CW\*(C`Compress::Zlib\*(C'\fR (viathe \f(CW\*(C`IO::Zlib\*(C'\fR module) to access tar files that have been compressedwith \f(CW\*(C`gzip\*(C'\fR. Unfortunately tar files compressed with the Unix \f(CW\*(C`compress\*(C'\fRutility cannot be read by \f(CW\*(C`Compress::Zlib\*(C'\fR and so cannot be directlyaccesses by \f(CW\*(C`Archive::Tar\*(C'\fR..SpIf the \f(CW\*(C`uncompress\*(C'\fR or \f(CW\*(C`gunzip\*(C'\fR programs are available, you can useone of these workarounds to read \f(CW\*(C`.tar.Z\*(C'\fR files from \f(CW\*(C`Archive::Tar\*(C'\fR.SpFirstly with \f(CW\*(C`uncompress\*(C'\fR.Sp.Vb 1\&    use Archive::Tar;\&\&    open F, "uncompress \-c $filename |";\&    my $tar = Archive::Tar\->new(*F);\&    ....Ve.Spand this with \f(CW\*(C`gunzip\*(C'\fR.Sp.Vb 1\&    use Archive::Tar;\&\&    open F, "gunzip \-c $filename |";\&    my $tar = Archive::Tar\->new(*F);\&    ....Ve.SpSimilarly, if the \f(CW\*(C`compress\*(C'\fR program is available, you can use this towrite a \f(CW\*(C`.tar.Z\*(C'\fR file.Sp.Vb 2\&    use Archive::Tar;\&    use IO::File;\&\&    my $fh = new IO::File "| compress \-c >$filename";\&    my $tar = Archive::Tar\->new();\&    ...\&    $tar\->write($fh);\&    $fh\->close ;.Ve.IP "How do I handle Unicode strings?" 4.IX Item "How do I handle Unicode strings?"\&\f(CW\*(C`Archive::Tar\*(C'\fR uses byte semantics for any files it reads from or writesto disk. This is not a problem if you only deal with files and neverlook at their content or work solely with byte strings. But if you useUnicode strings with character semantics, some additional steps needto be taken..SpFor example, if you add a Unicode string like.Sp.Vb 2\&    # Problem\&    $tar\->add_data(\*(Aqfile.txt\*(Aq, "Euro: \ex{20AC}");.Ve.Spthen there will be a problem later when the tarfile gets written outto disk via \f(CW\*(C`$tar\-\*(C'\fR\fIwrite()\fR>:.Sp.Vb 1\&    Wide character in print at .../Archive/Tar.pm line 1014..Ve.SpThe data was added as a Unicode string and when writing it out to disk,the \f(CW\*(C`:utf8\*(C'\fR line discipline wasn't set by \f(CW\*(C`Archive::Tar\*(C'\fR, so Perltried to convert the string to \s-1ISO\-8859\s0 and failed. The written filenow contains garbage..SpFor this reason, Unicode strings need to be converted to UTF\-8\-encodedbytestrings before they are handed off to \f(CW\*(C`add_data()\*(C'\fR:.Sp.Vb 3\&    use Encode;\&    my $data = "Accented character: \ex{20AC}";\&    $data = encode(\*(Aqutf8\*(Aq, $data);\&\&    $tar\->add_data(\*(Aqfile.txt\*(Aq, $data);.Ve.SpA opposite problem occurs if you extract a UTF8\-encoded file from a tarball. Using \f(CW\*(C`get_content()\*(C'\fR on the \f(CW\*(C`Archive::Tar::File\*(C'\fR objectwill return its content as a bytestring, not as a Unicode string..SpIf you want it to be a Unicode string (because you want charactersemantics with operations like regular expression matching), you needto decode the UTF8\-encoded content and have Perl convert it into a Unicode string:.Sp.Vb 2\&    use Encode;\&    my $data = $tar\->get_content();\&    \&    # Make it a Unicode string\&    $data = decode(\*(Aqutf8\*(Aq, $data);.Ve.SpThere is no easy way to provide this functionality in \f(CW\*(C`Archive::Tar\*(C'\fR, because a tarball can contain many files, and each of which could beencoded in a different way..SH "TODO".IX Header "TODO".IP "Check if passed in handles are open for read/write" 4.IX Item "Check if passed in handles are open for read/write"Currently I don't know of any portable pure perl way to do this.Suggestions welcome..IP "Allow archives to be passed in as string" 4.IX Item "Allow archives to be passed in as string"Currently, we only allow opened filehandles or filenames, butnot strings. The internals would need some reworking to facilitatestringified archives..IP "Facilitate processing an opened filehandle of a compressed archive" 4.IX Item "Facilitate processing an opened filehandle of a compressed archive"Currently, we only support this if the filehandle is an IO::Zlib object.Environments, like apache, will present you with an opened filehandleto an uploaded file, which might be a compressed archive..SH "SEE ALSO".IX Header "SEE ALSO".IP "The \s-1GNU\s0 tar specification" 4.IX Item "The GNU tar specification"\&\f(CW\*(C`http://www.gnu.org/software/tar/manual/tar.html\*(C'\fR.IP "The \s-1PAX\s0 format specication" 4.IX Item "The PAX format specication"The specifcation which tar derives from; \f(CW\*(C` http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html\*(C'\fR.ie n .IP "A comparison of \s-1GNU\s0 and \s-1POSIX\s0 tar standards; ""http://www.delorie.com/gnu/docs/tar/tar_114.html""" 4.el .IP "A comparison of \s-1GNU\s0 and \s-1POSIX\s0 tar standards; \f(CWhttp://www.delorie.com/gnu/docs/tar/tar_114.html\fR" 4.IX Item "A comparison of GNU and POSIX tar standards; http://www.delorie.com/gnu/docs/tar/tar_114.html".PD 0.IP "\s-1GNU\s0 tar intends to switch to \s-1POSIX\s0 compatibility" 4.IX Item "GNU tar intends to switch to POSIX compatibility".PD\&\s-1GNU\s0 Tar authors have expressed their intention to become completelyPOSIX-compatible; \f(CW\*(C`http://www.gnu.org/software/tar/manual/html_node/Formats.html\*(C'\fR.IP "A Comparison between various tar implementations" 4.IX Item "A Comparison between various tar implementations"Lists known issues and incompatibilities; \f(CW\*(C`http://gd.tuwien.ac.at/utils/archivers/star/README.otherbugs\*(C'\fR.SH "AUTHOR".IX Header "AUTHOR"This module by Jos Boumans <kane@cpan.org>..PPPlease reports bugs to <bug\-archive\-tar@rt.cpan.org>..SH "ACKNOWLEDGEMENTS".IX Header "ACKNOWLEDGEMENTS"Thanks to Sean Burke, Chris Nandor, Chip Salzenberg, Tim Heaney andespecially Andrew Savige for their help and suggestions..SH "COPYRIGHT".IX Header "COPYRIGHT"This module is copyright (c) 2002 \- 2007 Jos Boumans <kane@cpan.org>. All rights reserved..PPThis library is free software; you may redistribute and/or modify it under the same terms as Perl itself.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -