| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | package Email::Folder::Ezmlm; | ||
| 4 | # ABSTRACT: reads raw RFC822 mails from an ezmlm archive | ||
| 5 | $Email::Folder::Ezmlm::VERSION = '0.859'; | ||
| 6 | use Carp; | ||
| 7 | use Email::Folder::Maildir; | ||
| 8 | use parent 'Email::Folder::Maildir'; | ||
| 9 | |||
| 10 | # we're a little complicit, just redefining an internal method, but | ||
| 11 | # that's fine, we maintain both piles :) | ||
| 12 | |||
| 13 | sub _what_is_there { | ||
| 14 | my $self = shift; | ||
| 15 | my $dir = $self->{_file}; | ||
| 16 | |||
| 17 | croak "$dir does not exist" unless (-e $dir); | ||
| 18 | croak "$dir is not an ezmlm archive" unless (-d $dir); | ||
| 19 | croak "$dir is not an ezmlm archive" unless (-e "$dir/archive" && -d "$dir/archive"); | ||
| 20 | |||
| 21 | my $num; | ||
| 22 | if (my $fh = IO::File->new("$dir/num")) { | ||
| 23 | ($num) = (<$fh> =~ m/^(\d+)/); | ||
| 24 | } | ||
| 25 | |||
| 26 | $self->{_messages} = [ map { | ||
| 27 | sprintf '%s/archive/%d/%02d', $dir, int $_ / 100, $_ % 100 | ||
| 28 | } 1..$num ]; | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; | ||
| 32 | |||
| 33 | __END__ |