Subject: | Extracting files with Archive::Tar::Streamed |
It would be very useful if it was possible to extract a file from the
Archive::Tar::File object returned by the next() method. Unfortunately
this is more complicated than simply:
open OUT, ">$obj->name" or die;
print OUT $obj->get_content;
close OUT;
For example, the above may fail if the parent directory does not yet
exist, or if the Arcihve::Tar::File object represents a symlink, or a
block device, etc. The extract() method of Archive::Tar handles these
cases already, so one workaround is:
my $extract = new Archive::Tar;
$extract->add_data($name, $file->get_content, {
name => $file->name,
size => $file->size,
mtime => $file->mtime,
mode => $file->mode,
uid => $file->uid,
gid => $file->gid,
linkname => $file->linkname,
uname => $file->uname,
gname => $file->gname,
devmajor => $file->devmajor,
devminor => $file->devminor,
prefix => $file->prefix,
type => $file->type,
});
$extract->extract;
Perhaps a class method could be added to Archive::Tar::Streamed which
would accept a Archive::Tar::File object as an argument, and do something
similar to the above?
Thanks,
-mct