+ $cb->(undef, $fh, $self->can('input_mbox_cb'), $self, @args);
+ }
+}
+
+sub input_path_url {
+ my ($self, $input, @args) = @_;
+ my $lei = $self->{lei};
+ my $ifmt = lc($lei->{opt}->{'in-format'} // '');
+ # TODO auto-detect?
+ if ($input =~ m!\Aimaps?://!i) {
+ $lei->{net}->imap_each($input, $self->can('input_imap_cb') //
+ $self->can('input_net_cb'),
+ $self, @args);
+ return;
+ } elsif ($input =~ m!\A(?:nntps?|s?news)://!i) {
+ $lei->{net}->nntp_each($input, $self->can('input_nntp_cb') //
+ $self->can('input_net_cb'),
+ $self, @args);
+ return;
+ }
+ if ($input =~ s!\A([a-z0-9]+):!!i) {
+ $ifmt = lc($1);
+ } elsif ($input =~ /\.(?:patch|eml)\z/i) {
+ $ifmt = 'eml';
+ }
+ my $devfd = $lei->path_to_fd($input) // return;
+ if ($devfd >= 0) {
+ $self->input_fh($ifmt, $lei->{$devfd}, $input, @args);
+ } elsif (-f $input && $ifmt eq 'eml') {
+ open my $fh, '<', $input or
+ return $lei->fail("open($input): $!");
+ $self->input_fh($ifmt, $fh, $input, @args);
+ } elsif (-f _) {
+ my $m = $lei->{opt}->{'lock'} //
+ PublicInbox::MboxLock->defaults;
+ my $mbl = PublicInbox::MboxLock->acq($input, 0, $m);
+ my $zsfx = PublicInbox::MboxReader::zsfx($input);
+ if ($zsfx) {
+ my $in = delete $mbl->{fh};
+ $mbl->{fh} =
+ PublicInbox::MboxReader::zsfxcat($in, $zsfx, $lei);
+ }
+ local $PublicInbox::DS::in_loop = 0 if $zsfx; # dwaitpid
+ $self->input_fh($ifmt, $mbl->{fh}, $input, @args);
+ } elsif (-d _ && (-d "$input/cur" || -d "$input/new")) {
+ return $lei->fail(<<EOM) if $ifmt && $ifmt ne 'maildir';
+$input appears to a be a maildir, not $ifmt
+EOM
+ PublicInbox::MdirReader->new->maildir_each_eml($input,
+ $self->can('input_maildir_cb'),
+ $self, @args);
+ } else {
+ $lei->fail("$input unsupported (TODO)");