diff options
Diffstat (limited to 'lib/PublicInbox/MdirReader.pm')
-rw-r--r-- | lib/PublicInbox/MdirReader.pm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/PublicInbox/MdirReader.pm b/lib/PublicInbox/MdirReader.pm new file mode 100644 index 00000000..c6a0e7a8 --- /dev/null +++ b/lib/PublicInbox/MdirReader.pm @@ -0,0 +1,21 @@ +# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> + +# Maildirs for now, MH eventually +package PublicInbox::MdirReader; +use strict; +use v5.10.1; + +sub maildir_each_file ($$;@) { + my ($dir, $cb, @arg) = @_; + $dir .= '/' unless substr($dir, -1) eq '/'; + for my $d (qw(new/ cur/)) { + my $pfx = $dir.$d; + opendir my $dh, $pfx or next; + while (defined(my $fn = readdir($dh))) { + $cb->($pfx.$fn, @arg) if $fn =~ /:2,[A-Za-z]*\z/; + } + } +} + +1; |