| 1 | # This code is part of Perl distribution Mail-Box version 4.02. | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # The POD got stripped from this file by OODoc version 3.06. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # For contributors see file ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2001-2026 by Mark Overmeer. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | package Mail::Box::Dir;{ | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 14 | our $VERSION = '4.02'; | |||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 14 | ▶ | use parent 'Mail::Box'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 14 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 14 | ▶ | use Log::Report 'mail-box', import => [ qw/__x error warning/ ]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 14 | ▶ | use Mail::Box::Dir::Message (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 14 | ▶ | use Mail::Message::Body::Lines (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 14 | ▶ | use Mail::Message::Body::File (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 14 | ▶ | use Mail::Message::Body::Delayed (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 14 | ▶ | use Mail::Message::Body::Multipart (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 14 | ▶ | use Mail::Message::Head (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 14 | ▶ | use Mail::Message::Head::Delayed (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 14 | ▶ | use File::Spec::Functions qw/rel2abs/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | sub init($) | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 35 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=10 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 35 | ▶ | $args->{body_type} //= sub { 'Mail::Message::Body::Lines' }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.6
Condition33%1/3
$args->{"body_type"} //= sub {
"Mail::Message::Body::Lines";
}
MC/DC0%0/2
$args->{"body_type"} //= sub {
"Mail::Message::Body::Lines";
}
$args->{"body_type"}
sub {
"Mail::Message::Body::Lines";
}
Truth table33%1/3
A //= B
A= $args->{"body_type"}B= sub {
"Mail::Message::Body::Lines";
}
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 35 | $self->SUPER::init($args); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 35 | my $class = ref $self; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 35 | ▶ | my $directory = $self->{MBD_directory} = $args->{directory} || $self->directory; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args->{'directory'} || $self->directory
MC/DC0%0/2
$args->{'directory'} || $self->directory
$args->{'directory'}
$self->directory
Truth table33%1/3
A || B
A= $args->{'directory'}B= $self->directory
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 35 | ▶ | if(-d $directory) {;} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | ▶ | elsif($args->{create} && $class->create($directory, %$args)) { ;} | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args->{"create"} and $class->create($directory, %$args)
MC/DC0%0/2
$args->{"create"} and $class->create($directory, %$args)
$args->{"create"}
$class->create($directory, %$args)
Truth table33%1/3
A and B
A= $args->{"create"}B= $class->create($directory, %$args)
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | else | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | { error __x"no directory {dir} for folder of type.", dir => $directory, type => $class; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | # About locking | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 35 | ▶ | my $lf = $args->{lock_file} // '.lock'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"lock_file"} // ".lock"
MC/DC0%0/1
$args->{"lock_file"} // ".lock"
$args->{"lock_file"}
Truth table50%1/2
A
A= $args->{"lock_file"}
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 35 | $self->locker->filename(rel2abs $lf, $directory); | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | # Check if we can write to the folder, if we need to. | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 35 | ▶ | if($self->writable && -e $directory && ! -w $directory) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->writable and -e $directory and not -w $directory
$self->writable and -e $directory
MC/DC0%0/3
$self->writable and -e $directory and not -w $directory
$self->writable
-e $directory
not -w $directory
Truth table50%2/4
A and B and not(C)
A= $self->writableB= -e $directoryC= not -w $directory
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | { warning __x"folder directory {dir} is write-protected.", dir => $directory; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $self->access('r'); | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 35 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | sub organization() { 'DIRECTORY' } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | sub directory() | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 153 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
directory: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 153 | ▶ | $self->{MBD_directory} ||= $self->folderToDirectory($self->name, $self->folderdir); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"MBD_directory"} ||= $self->folderToDirectory($self->name, $self->folderdir)
MC/DC0%0/2
$self->{"MBD_directory"} ||= $self->folderToDirectory($self->name, $self->folderdir)
$self->{"MBD_directory"}
$self->folderToDirectory($self->name, $self->folderdir)
Truth table66%2/3
A ||= B
A= $self->{"MBD_directory"}B= $self->folderToDirectory($self->name, $self->folderdir)
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | sub nameOfSubFolder($;$) | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 70 | ▶ | { my ($thing, $name) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nameOfSubFolder: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 70 | ▶ | my $parent = @_ ? shift : ref $thing ? $thing->directory : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 70 | ▶ | defined $parent ? "$parent/$name" : $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | sub folderToDirectory($$) | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 91 | ▶ | { my ($class, $name, $folderdir) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
folderToDirectory: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 91 | ▶ | my $dir = ($name =~ m#^=\/?(.*)# ? "$folderdir/$1" : $name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 91 | $dir =~ s!/$!!r; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | sub storeMessage($) | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 780 | ▶ | { my ($self, $message) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
storeMessage: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 780 | $self->SUPER::storeMessage($message); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 780 | ▶ | my $fn = $message->filename or return $message; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 738 | $self->{MBD_by_fn}{$fn} = $message; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub messageInFile($) { $_[0]->{MBD_by_fn}{$_[1]} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
messageInFile: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub readMessageFilenames() { $_[0]->notImplemented } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readMessageFilenames: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||