Acme-Archive-Mbox
view release on metacpan or search on metacpan
Acme-Archive-Mbox
Store and retrieve files to/from an mbox (suitable for viewing with a
mail client, eg mutt).
Mbox format is one message per file, with metadata in the headers and
file contents in an attachment. Included script[s] create and extract
mbox archives, like tar.
INSTALLATION
To install this module, run the following commands:
perl Makefile.PL
make
make test
make install
lib/Acme/Archive/Mbox.pm view on Meta::CPAN
=cut
our $VERSION = '0.01';
=head1 SYNOPSIS
Uses Mbox as an archive format, like tar or zip but silly. Creates an mbox
with one message per file or directory. File contents are stored as an
attachment, metadata goes in mail headers.
use Acme::Archive::Mbox;
my $archive = Acme::Archive::Mbox->new();
$archive->add_file('filename');
$archive->add_data('file/name', $contents);
$archive->write('foo.mbox');
...
lib/Acme/Archive/Mbox.pm view on Meta::CPAN
=cut
sub write {
my $self = shift;
my $mboxname = shift;
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open($mboxname, type => 'mbox', create => 1, access => 'rw') or die "Could not create $mboxname";
for my $file (@{$self->{files}}) {
my $attach = Mail::Message::Body->new( mime_type => 'application/octet-stream',
data => $file->contents,
);
my $message = Mail::Message->build( From => '"Acme::Archive::Mbox" <AAM@example.com>',
To => '"Anyone, really" <anyone@example.com>',
Subject => $file->name,
'X-AAM-uid' => $file->uid,
'X-AAM-gid' => $file->gid,
'X-AAM-mode' => $file->mode,
'X-AAM-mtime' => $file->mtime,
data => 'attached',
attach => $attach, );
$folder->addMessage($message);
}
$folder->write();
$mgr->close($folder);
}
=head2 read (filename)
Read archive from a file.
( run in 0.385 second using v1.01-cache-2.11-cpan-88abd93f124 )