简体   繁体   中英

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. Somehow I can't see how to do that.

It appears that when extracting a ZIP file, Archive::Zip does recognize contained symbolic links. But is there a write API?

Perhaps there's something that can be done by creating an Archive::Zip::Member and setting the (internal? external?) attributes? 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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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