Acme-Archive-Mbox
view release on metacpan or search on metacpan
bin/mboxextract view on Meta::CPAN
die "Absolute path, refusing to extract: $name\n" if (File::Spec->file_name_is_absolute($name));
my (undef, $dirs, $filename) = File::Spec->splitpath($name);
my @parts = File::Spec->splitdir($dirs);
push @parts, $filename;
die "Directory traversal attempted: $name\n" unless (File::Spec->no_upwards(@parts) == @parts);
mkpath(File::Spec->catdir($rootdir, $dirs));
my $writename = File::Spec->catfile($rootdir, $dirs, $filename);
write_file($writename, {binmode => ':raw'}, $file->contents );
chmod $file->mode, $writename or warn "$0: chmod $writename: $!\n";
if ($> == 0) {
chown $file->uid, $file->gid, $writename or warn "$0: chown $writename: $!\n";
}
}
=head1 NAME
mboxextract - extract mbox archive
lib/Acme/Archive/Mbox.pm view on Meta::CPAN
to be used in the archive.
=cut
sub add_file {
my $self = shift;
my $name = shift;
my $altname = shift || $name;
my %attr;
my $contents = read_file($name, err_mode => 'carp', binmode => ':raw');
return unless $contents;
my (undef, undef, $mode, undef, $uid, $gid, undef, undef, undef, $mtime) = stat $name;
$attr{mode} = $mode & 0777;
$attr{uid} = $uid;
$attr{gid} = $gid;
$attr{mtime} = $mtime;
my $file = Acme::Archive::Mbox::File->new($altname, $contents, %attr);
push @{$self->{files}}, $file if $file;
( run in 0.300 second using v1.01-cache-2.11-cpan-87723dcf8b7 )