开发者

Why does the tarball directory structure disappear when I use Perl's Archive::Tar?

开发者 https://www.devze.com 2022-12-08 07:27 出处:网络
I\'m using a Perl script to modify some files inside a .tar, and the directory structure inside the resulting .tar disappears.

I'm using a Perl script to modify some files inside a .tar, and the directory structure inside the resulting .tar disappears. Eliminating more and more code I've come as far as all that's required to reproduce this is

my $data_tar = Archive::Tar->new('data.tar');
$data_tar->write('modified_data.tar');

Both .tar-files have all the files, however the indication of what directories the files and subdirectories were located in are lost.

I've looked through the docs 开发者_C百科and src for Archive::Tar but I really don't understand what's going on.

I'm using perl 5.10.0 on win32, tar 1.12 and Archive::Tar 1.54. I examined the .tar-files in an editor and the data.tar contains dir/ and dir/file.txt, but in the modified_data.tar they show up as dir and file.txt so my original tar seems ok.

Anyone of you that have seen this before or have any ideas?


C:\Temp> perl -v

This is perl, v5.10.1 built for MSWin32-x86-multi-thread
(with 2 registered patches, see perl -V for more detail)
C:\Temp> perl -MArchive::Tar -e "print $Archive::Tar::VERSION"
1.52

Cannot replicate using data.tar created with:

C:\Temp> tar --version
tar (GNU tar) 1.21

As @~quack notes, the docs state:

Note that GNU tar earlier than version 1.14 does not cope well with the POSIX header prefix. If you use such a version, consider setting the $Archive::Tar::DO_NOT_USE_PREFIX variable to true.


I tried your script but could not reproduce the problem (on FreeBSD using Perl 5.10).

0

精彩评论

暂无评论...
验证码 换一张
取 消