简体   繁体   English

如何使用Perl将符号链接存储在ZIP文件中?

[英]How do I store symbolic links in a ZIP file using Perl?

I'm using Archive::Zip , and I'd like to add symbolic links to an archive that I'm creating. 我正在使用Archive::Zip ,我想将符号链接添加到正在创建的存档中。 Somehow I can't see how to do that. 我莫名其妙地看不到该怎么做。

It appears that when extracting a ZIP file, Archive::Zip does recognize contained symbolic links. 似乎在解压缩ZIP文件时, Archive::Zip确实识别出包含的符号链接。 But is there a write API? 但是有写API吗?

Perhaps there's something that can be done by creating an Archive::Zip::Member and setting the (internal? external?) attributes? 也许可以通过创建Archive::Zip::Member并设置(内部?外部?)属性来完成某些工作? If so, I don't understand how. 如果是这样,我不知道如何。

Poking around the source code, it seems the trick is to create a member object, and set the right attributes, like this: 仔细查看源代码,似乎诀窍是创建一个成员对象,并设置正确的属性,如下所示:

my $zip = Archive::Zip->new();
my $member = $zip->addString( 'plain-file', 'symlink-pointing-to-plain-file' );
$member->{'externalFileAttributes'} = 0xA1FF0000;

I got this from the code that adds files and detects that it is a symlink. 我是从添加文件并检测到它是符号链接的代码中得到的。 Let's hope there aren't any edge cases... 我们希望没有任何极端情况...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM