Box/Maildir.pm

filter: Statementstmt 63.9% 119 / 186 Branchbran 28.9% 22 / 76 Conditioncond 23.3% 14 / 60 MC/DCmcdc 2.7% 1 / 37 Subroutinesub 69.5% 16 / 23 Podpod 92.8% 13 / 14 totaltotal 46.7% 185 / 396 CC 67 SCAR 39.2
CC
67
Cov
48%
listSubFolders
210.0
folderIsEmpty
90.0
createDirs
42.0
CRAP 50.3
« Box/Net.pm ↑ Summary Box/Locker/Mutt.pm »
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::Maildir;{
13 6 our $VERSION = '4.02';
14 }
15  
16 6 ▶use parent 'Mail::Box::Dir';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 6 ▶use Log::Report 'mail-box', import => [ qw/__x error fault info trace/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 6 ▶use Mail::Box::Maildir::Message;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 6 ▶use File::Copy qw/move/;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 6 ▶use File::Basename qw/basename/;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 6 ▶use Sys::Hostname qw/hostname/;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 6 ▶use File::Remove qw/remove/;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 # Maildir is only supported on UNIX, because the filenames probably
31 # do not work on other platforms. Since MailBox 2.052, the use of
32 # File::Spec to create filenames has been removed: benchmarks showed
33 # that catfile() consumed 20% of the time of a folder open(). And
34 # '/' file separators work on Windows too!
35  
36 #--------------------
37  
38 6 ▶my $default_folder_dir = exists $ENV{HOME} ? "$ENV{HOME}/.maildir" : '.';
Branch: 1 branch
BranchTrueFalseTotal
exists $ENV{'HOME'} ? : 6 0 6
39  
40 sub init($)
41 7 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=6 SCAR=19.4
Pod undocumented
42  
43 7 ▶ ! exists $args->{locker} && (! defined $args->{lock_type} || $args->{lock_type} eq 'NONE')
Branch: 1 branch
BranchTrueFalseTotal
not exists $args->{"locker"} and !defined($args->{"lock_type"}) || $args->{"lock_type"} eq "NONE" or &error(&__x("no locking possible for maildir folders.")) 7 0 7
Condition50%3/6
not exists $args->{"locker"} and !defined($args->{"lock_type"}) || $args->{"lock_type"} eq "NONE"
!ll&&!rl&&r
007
not defined $args->{"lock_type"} or $args->{"lock_type"} eq "NONE"
l!l&&r!l&&!r
520
MC/DC0%0/3
not exists $args->{"locker"} and !defined($args->{"lock_type"}) || $args->{"lock_type"} eq "NONE"
not exists $args->{"locker"} not defined $args->{"lock_type"} $args->{"lock_type"} eq "NONE"
Truth table50%2/4
not(A) and not(B) or C
A= not exists $args->{"locker"}B= not defined $args->{"lock_type"}C= $args->{"lock_type"} eq "NONE"
ABCresult
0XX0
1000
11X1
1011
44 or error __x"no locking possible for maildir folders.";
45  
46 7 $args->{lock_type} = 'NONE';
47 7 ▶ $args->{folderdir} ||= $default_folder_dir;
Condition66%2/3
$args->{"folderdir"} ||= $default_folder_dir
l!l&&r!l&&!r
160
MC/DC0%0/2
$args->{"folderdir"} ||= $default_folder_dir
$args->{"folderdir"} $default_folder_dir
Truth table66%2/3
A ||= B
A= $args->{"folderdir"}B= $default_folder_dir
ABresult
1X1
011
000
48  
49 7 $self->SUPER::init($args);
50  
51 7 ▶ $self->acceptMessages if $args->{accept_new};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"accept_new"} 0 7 7
52 7 $self;
53 }
54  
55  
56 sub create($@)
57 0 ▶{ my ($thingy, $name, %args) = @_;
Subroutine create: not called CC=3 SCAR=24.8
Pod documented
58 0 ▶ my $class = ref $thingy || $thingy;
Condition0%0/3
ref $thingy || $thingy
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $thingy || $thingy
ref $thingy $thingy
Truth table0%0/3
A || B
A= ref $thingyB= $thingy
ABresult
1X1
011
000
59 0 ▶ my $folderdir = $args{folderdir} || $default_folder_dir;
Condition0%0/3
$args{'folderdir'} || $default_folder_dir
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'folderdir'} || $default_folder_dir
$args{'folderdir'} $default_folder_dir
Truth table0%0/3
A || B
A= $args{'folderdir'}B= $default_folder_dir
ABresult
1X1
011
000
60 0 my $directory = $class->folderToDirectory($name, $folderdir);
61  
62 0 $class->createDirs($directory);
63 0 trace "created folder Maildir $name.";
64 0 $directory;
65 }
66  
67 sub foundIn($@)
68 5 ▶{ my $class = shift;
Subroutine foundIn: called CC=3 SCAR=11.2
Pod documented
69 5 ▶ my $name = @_ % 2 ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 5 0 5
70 5 my %args = @_;
71 5 ▶ my $folderdir = $args{folderdir} || $default_folder_dir;
Condition66%2/3
$args{'folderdir'} || $default_folder_dir
l!l&&r!l&&!r
230
MC/DC0%0/2
$args{'folderdir'} || $default_folder_dir
$args{'folderdir'} $default_folder_dir
Truth table66%2/3
A || B
A= $args{'folderdir'}B= $default_folder_dir
ABresult
1X1
011
000
72 5 my $directory = $class->folderToDirectory($name, $folderdir);
73  
74 5 -d "$directory/cur";
75 }
76  
77 sub type() { 'maildir' }
78  
79 sub listSubFolders(@)
80 0 ▶{ my ($class, %args) = @_;
Subroutine listSubFolders: not called CC=14 SCAR=53.5
Pod documented
81 0 my $dir;
82  
83 0 ▶ if(ref $class)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $class) { } 0 0 0
84 0 { $dir = $class->directory;
85 0 $class = ref $class;
86 }
87 else
88 0 ▶ { my $folder = $args{folder} || '=';
Condition0%0/2
$args{'folder'} || '='
l!l
00
MC/DC0%0/1
$args{'folder'} || '='
$args{'folder'}
Truth table0%0/2
A
A= $args{'folder'}
Aresult
11
00
89 0 ▶ my $folderdir = $args{folderdir} || $default_folder_dir;
Condition0%0/3
$args{'folderdir'} || $default_folder_dir
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'folderdir'} || $default_folder_dir
$args{'folderdir'} $default_folder_dir
Truth table0%0/3
A || B
A= $args{'folderdir'}B= $default_folder_dir
ABresult
1X1
011
000
90 0 $dir = $class->folderToDirectory($folder, $folderdir);
91 }
92  
93 0 ▶ $args{skip_empty} ||= 0;
Condition0%0/2
$args{"skip_empty"} ||= 0
l!l
00
MC/DC0%0/1
$args{"skip_empty"} ||= 0
$args{"skip_empty"}
Truth table0%0/2
A
A= $args{"skip_empty"}
Aresult
11
00
94 0 ▶ $args{check} ||= 0;
Condition0%0/2
$args{"check"} ||= 0
l!l
00
MC/DC0%0/1
$args{"check"} ||= 0
$args{"check"}
Truth table0%0/2
A
A= $args{"check"}
Aresult
11
00
95  
96 # Read the directories from the directory, to find all folders
97 # stored here. Some directories have to be removed because they
98 # are created by all kinds of programs, but are no folders.
99  
100 0 ▶ -d $dir && opendir my $dh, $dir
Branch: 1 branch
BranchTrueFalseTotal
-d $dir and opendir my $dh, $dir or return () 0 0 0
Condition0%0/3
-d $dir and opendir my $dh, $dir
!ll&&!rl&&r
000
MC/DC0%0/2
-d $dir and opendir my $dh, $dir
-d $dir opendir my $dh, $dir
Truth table0%0/3
A and B
A= -d $dirB= opendir my $dh, $dir
ABresult
0X0
100
111
101 or return ();
102  
103 0 my @dirs;
104 0 ▶ while(my $d = readdir $dh)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $d = readdir $dh)) 0 0 0
105 0 ▶ { next if $d =~ m/^(new|tmp|cur|\.\.?)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $d =~ /^(new|tmp|cur|\.\.?)$/ 0 0 0
106  
107 0 my $dir = "$dir/$d";
108 0 ▶ push @dirs, $d if -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
if -d $dir 0 0 0
109 }
110  
111 0 closedir $dh;
112  
113 # Skip empty folders.
114  
115 @dirs = grep !$class->folderIsEmpty("$dir/$_"), @dirs
116 0 ▶ if $args{skip_empty};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"skip_empty"} 0 0 0
117  
118 # Check if the files we want to return are really folders.
119  
120 0 ▶ @dirs = map { m/(.*)/ && $1 } @dirs; # untaint
Condition0%0/3
/(.*)/ && $1
!ll&&!rl&&r
000
MC/DC0%0/2
/(.*)/ && $1
/(.*)/ $1
Truth table0%0/3
A && B
A= /(.*)/B= $1
ABresult
0X0
100
111
121 0 ▶ $args{check} or return @dirs;
Branch: 1 branch
BranchTrueFalseTotal
$args{"check"} or return @dirs 0 0 0
122  
123 0 grep $class->foundIn("$dir/$_"), @dirs;
124 }
125  
126 sub openSubFolder($@)
127 0 ▶{ my ($self, $name) = (shift, shift);
Subroutine openSubFolder: not called CC=1 SCAR=6.9
Pod documented
128 0 $self->createDirs($self->nameOfSubFolder($name));
129 0 $self->SUPER::openSubFolder($name, @_);
130 }
131  
132 sub topFolderWithMessages() { 1 }
133  
134 6 my $uniq = rand 1000;
135  
136  
137 sub coerce($)
138 2 ▶{ my ($self, $message) = (shift, shift);
Subroutine coerce: called CC=4 SCAR=14.1
Pod documented
139  
140 2 my $is_native = $message->isa('Mail::Box::Maildir::Message');
141 2 my $coerced = $self->SUPER::coerce($message, @_);
142  
143 2 ▶ my $basename = $is_native ? basename($message->filename)
Branch: 1 branch
BranchTrueFalseTotal
$is_native ? : 0 2 2
Condition50%1/2
$message->timestamp || time
l!l
20
MC/DC0%0/1
$message->timestamp || time
$message->timestamp
Truth table50%1/2
A
A= $message->timestamp
Aresult
11
00
144 : ($message->timestamp || time) .'.'. hostname .'.'. $uniq++;
145  
146 2 my $dir = $self->directory;
147 2 $coerced->create("$dir/tmp/$basename");
148 2 my $new = $coerced->create("$dir/new/$basename");
149  
150 2 trace "Added Maildir message in $new";
151 2 ▶ $coerced->labelsToFilename unless $is_native;
Branch: 1 branch
BranchTrueFalseTotal
unless $is_native 2 0 2
152 2 $coerced;
153 }
154  
155 #--------------------
156  
157 sub createDirs($)
158 0 ▶{ my ($thing, $dir) = @_;
Subroutine createDirs: not called CC=6 SCAR=37.4
Pod documented
159  
160 0 ▶ -d $dir || mkdir $dir
Branch: 1 branch
BranchTrueFalseTotal
-d $dir or mkdir $dir or &fault(&__x("cannot create Maildir folder directory {dir}", "dir", $dir)) 0 0 0
Condition0%0/3
-d $dir or mkdir $dir
l!l&&r!l&&!r
000
MC/DC0%0/2
-d $dir or mkdir $dir
-d $dir mkdir $dir
Truth table0%0/3
A or B
A= -d $dirB= mkdir $dir
ABresult
1X1
011
000
161 or fault __x"cannot create Maildir folder directory {dir}", dir => $dir;
162  
163 0 foreach my $sub (qw/tmp new cur/)
164 0 { my $subdir = "$dir/$sub";
165 0 ▶ -d $subdir || mkdir $subdir
Branch: 1 branch
BranchTrueFalseTotal
-d $subdir or mkdir $subdir or &fault(&__x("cannot create Maildir folder subdir {dir}", "dir", $subdir)) 0 0 0
Condition0%0/3
-d $subdir or mkdir $subdir
l!l&&r!l&&!r
000
MC/DC0%0/2
-d $subdir or mkdir $subdir
-d $subdir mkdir $subdir
Truth table0%0/3
A or B
A= -d $subdirB= mkdir $subdir
ABresult
1X1
011
000
166 or fault __x"cannot create Maildir folder subdir {dir}", dir => $subdir;
167 }
168  
169 0 $thing;
170 }
171  
172  
173 sub folderIsEmpty($)
174 0 ▶{ my ($self, $dir) = @_;
Subroutine folderIsEmpty: not called CC=9 SCAR=45.0
Pod documented
175 0 ▶ return 1 unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 0 0
176  
177 0 foreach my $sub (qw/tmp new cur/)
178 0 { my $subdir = "$dir/$sub";
179 0 ▶ -d $subdir or next;
Branch: 1 branch
BranchTrueFalseTotal
-d $subdir or next 0 0 0
180  
181 0 ▶ opendir my $dh, $subdir or return 0;
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $subdir or return 0 0 0 0
182 0 my $first = readdir $dh;
183 0 closedir $dh;
184  
185 0 ▶ return 0 if defined $first;
Branch: 1 branch
BranchTrueFalseTotal
if defined $first 0 0 0
186 }
187  
188 0 ▶ opendir my $dh, $dir or return 1;
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $dir or return 1 0 0 0
189 0 ▶ while(my $entry = readdir $dh)
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $entry = readdir $dh)) 0 0 0
190 0 ▶ { next if $entry =~ m/^(?:tmp|cur|new|bulletin(?:time|lock)|seriallock|\..?)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $entry =~ /^(?:tmp|cur|new|bulletin(?:time|lock)|seriallock|\..?)$/ 0 0 0
191 0 closedir $dh;
192 0 return 0;
193 }
194  
195 0 closedir $dh;
196 0 1;
197 }
198  
199 sub delete(@)
200 0 ▶{ my $self = shift;
Subroutine delete: not called CC=1 SCAR=6.9
Pod documented
201  
202 # Subfolders are not nested in the directory structure
203 0 remove \1, $self->directory;
204 }
205  
206 sub readMessageFilenames
207 14 ▶{ my ($self, $dirname) = @_;
Subroutine readMessageFilenames: called CC=8 SCAR=25.4
Pod documented
208  
209 14 ▶ opendir my $dh, $dirname or return ();
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $dirname or return () 14 0 14
210  
211 14 my @files;
212 14 ▶ if(${^TAINT})
Branch: 1 branch
BranchTrueFalseTotal
if (${^TAINT}) { } 0 14 14
213 { # unsorted list of untainted filenames.
214 0 ▶ @files = map +(m/^([0-9][\w.:,=\-]+)$/ && -f "$dirname/$1" ? $1 : ()), readdir $dh;
Branch: 1 branch
BranchTrueFalseTotal
/^([0-9][\w.:,=\-]+)$/ && -f "$dirname/$1" ? : 0 0 0
Condition0%0/3
/^([0-9][\w.:,=\-]+)$/ and -f "$dirname/$1"
!ll&&!rl&&r
000
MC/DC0%0/2
/^([0-9][\w.:,=\-]+)$/ and -f "$dirname/$1"
/^([0-9][\w.:,=\-]+)$/ -f "$dirname/$1"
Truth table0%0/3
A and B
A= /^([0-9][\w.:,=\-]+)$/B= -f "$dirname/$1"
ABresult
0X0
100
111
215 }
216 else
217 { # not running tainted
218 14 ▶ @files = grep m/^([0-9][\w.:,=\-]+)$/ && -f "$dirname/$1", readdir $dh;
Condition66%2/3
/^([0-9][\w.:,=\-]+)$/ && -f "$dirname/$1"
!ll&&!rl&&r
280303
MC/DC50%1/2
/^([0-9][\w.:,=\-]+)$/ && -f "$dirname/$1"
/^([0-9][\w.:,=\-]+)$/ -f "$dirname/$1"
Truth table66%2/3
A && B
A= /^([0-9][\w.:,=\-]+)$/B= -f "$dirname/$1"
ABresult
0X0
100
111
219 }
220 14 closedir $dh;
221  
222 # Sort the names. Solve the Y2K (actually the 1 billion seconds
223 # since 1970 bug) which hunts Maildir. The timestamp, which is
224 # the start of the filename will have some 0's in front, so each
225 # timestamp has the same length.
226  
227 14 my %unified;
228 m/^(\d+)/ and $unified{ ('0' x (10-length($1))).$_ } = $_
229 14 ▶ for @files;
Branch: 1 branch
BranchTrueFalseTotal
/^(\d+)/ and $unified{0 x (10 - length($1)) . $_} = $_ 303 0 303
230  
231 14 map "$dirname/$unified{$_}", sort keys %unified;
232 }
233  
234 sub readMessages(@)
235 7 ▶{ my ($self, %args) = @_;
Subroutine readMessages: called CC=4 SCAR=13.9
Pod documented
236  
237 7 my $directory = $self->directory;
238 7 ▶ -d $directory or return;
Branch: 1 branch
BranchTrueFalseTotal
-d $directory or return 7 0 7
239  
240 #
241 # Read all messages
242 #
243  
244 7 my $curdir = "$directory/cur";
245 7 my @cur = map +[$_, 1], $self->readMessageFilenames($curdir);
246  
247 7 my $newdir = "$directory/new";
248 7 my @new = map +[$_, 0], $self->readMessageFilenames($newdir);
249  
250 7 foreach (@cur, @new)
251 303 { my ($filename, $accepted) = @$_;
252 my $message = $args{message_type}->new(
253 head => $args{head_delayed_type}->new,
254 303 filename => $filename,
255 folder => $self,
256 fix_header=> $self->fixHeaders,
257 labels => [ accepted => $accepted ],
258 );
259  
260 303 my $body = $args{body_delayed_type}->new(message => $message);
261 303 ▶ $message->storeBody($body) if $body;
Branch: 1 branch
BranchTrueFalseTotal
if $body 303 0 303
262 303 $self->storeMessage($message);
263 }
264  
265 7 $self;
266 }
267  
268  
269 sub acceptMessages($)
270 0 ▶{ my ($self, %args) = @_;
Subroutine acceptMessages: not called CC=2 SCAR=17.9
Pod documented
271 0 my @accept = $self->messages('!accepted');
272 0 $_->accept foreach @accept;
273 0 @accept;
274 }
275  
276  
277 sub writeMessages($)
278 5 ▶{ my ($self, $args) = @_;
Subroutine writeMessages: called CC=9 SCAR=24.3
Pod documented
279  
280 # Write each message. Two things complicate life:
281 # 1 - we may have a huge folder, which should not be on disk twice
282 # 2 - we may have to replace a message, but it is unacceptable
283 # to remove the original before we are sure that the new version
284 # is on disk.
285  
286 5 my $writer = 0;
287  
288 5 my $directory = $self->directory;
289 5 my @messages = @{$args->{messages}};
290  
291 5 my $tmpdir = "$directory/tmp";
292 5 ▶ -d $tmpdir || mkdir $tmpdir
Branch: 1 branch
BranchTrueFalseTotal
-d $tmpdir or mkdir $tmpdir or &fault(&__x("cannot create directory {dir}", "dir", $tmpdir)) 5 0 5
Condition33%1/3
-d $tmpdir or mkdir $tmpdir
l!l&&r!l&&!r
500
MC/DC0%0/2
-d $tmpdir or mkdir $tmpdir
-d $tmpdir mkdir $tmpdir
Truth table33%1/3
A or B
A= -d $tmpdirB= mkdir $tmpdir
ABresult
1X1
011
000
293 or fault __x"cannot create directory {dir}", dir => $tmpdir;
294  
295 5 foreach my $message (@messages)
296 192 ▶ { $message->isModified or next;
Branch: 1 branch
BranchTrueFalseTotal
$message->isModified or next 1 191 192
297  
298 1 my $filename = $message->filename;
299 1 my $basename = basename $filename;
300  
301 1 my $newtmp = "$directory/tmp/$basename";
302 1 ▶ open my $new, '>:raw', $newtmp
Branch: 1 branch
BranchTrueFalseTotal
open my $new, ">:raw", $newtmp or &fault(&__x("cannot create file {file}", "file", $newtmp)) 1 0 1
303 or fault __x"cannot create file {file}", file => $newtmp;
304  
305 1 $message->write($new);
306 1 close $new;
307  
308 1 unlink $filename;
309 1 ▶ move $newtmp, $filename
Branch: 1 branch
BranchTrueFalseTotal
move($newtmp, $filename) or &fault(&__x("cannot rename {from} to {to}", "from", $newtmp, "to", $filename)) 1 0 1
310 or fault __x"cannot rename {from} to {to}", from => $newtmp, to => $filename;
311 }
312  
313 # Remove an empty folder. This is done last, because the code before
314 # in this method will have cleared the contents of the directory.
315  
316 5 ▶ if(!@messages && $self->removeEmpty)
Branch: 1 branch
BranchTrueFalseTotal
if (not @messages and $self->removeEmpty) 0 5 5
Condition33%1/3
not @messages and $self->removeEmpty
!ll&&!rl&&r
500
MC/DC0%0/2
not @messages and $self->removeEmpty
not @messages $self->removeEmpty
Truth table33%1/3
not(A) and B
A= not @messagesB= $self->removeEmpty
ABresult
0X0
100
111
317 { # If something is still in the directory, this will fail, but I
318 # don't mind.
319 0 rmdir "$directory/cur";
320 0 rmdir "$directory/tmp";
321 0 rmdir "$directory/new";
322 0 rmdir $directory;
323 }
324  
325 5 $self;
326 }
327  
328  
329 sub appendMessages(@)
330 1 ▶{ my $class = shift;
Subroutine appendMessages: called CC=10 SCAR=25.3
Pod documented
331 1 my %args = @_;
332  
333 my @messages
334 = exists $args{message} ? $args{message}
335 1 ▶ : exists $args{messages} ? @{$args{messages}}
Branch: 2 branches
BranchTrueFalseTotal
exists $args{'message'} ? : 0 1 1
exists $args{'messages'} ? : 1 0 1
336 : return ();
337  
338 1 my $self = $class->new(@_, access => 'a');
339 1 my $directory= $self->directory;
340 1 ▶ -d $directory or return;
Branch: 1 branch
BranchTrueFalseTotal
-d $directory or return 1 0 1
341  
342 1 my $tmpdir = "$directory/tmp";
343 1 ▶ -d $tmpdir || mkdir $tmpdir
Branch: 1 branch
BranchTrueFalseTotal
-d $tmpdir or mkdir $tmpdir or &fault(&__x("cannot create directory {dir}", "dir", $tmpdir)) 1 0 1
Condition33%1/3
-d $tmpdir or mkdir $tmpdir
l!l&&r!l&&!r
100
MC/DC0%0/2
-d $tmpdir or mkdir $tmpdir
-d $tmpdir mkdir $tmpdir
Truth table33%1/3
A or B
A= -d $tmpdirB= mkdir $tmpdir
ABresult
1X1
011
000
344 or fault __x"cannot create directory {dir}", dir => $tmpdir;
345  
346 1 ▶ my $msgtype = $args{message_type} || 'Mail::Box::Maildir::Message';
Condition50%1/2
$args{'message_type'} || 'Mail::Box::Maildir::Message'
l!l
01
MC/DC0%0/1
$args{'message_type'} || 'Mail::Box::Maildir::Message'
$args{'message_type'}
Truth table50%1/2
A
A= $args{'message_type'}
Aresult
11
00
347  
348 1 foreach my $message (@messages)
349 1 { my $is_native = $message->isa($msgtype);
350 1 my ($basename, $coerced);
351  
352 1 ▶ if($is_native)
Branch: 1 branch
BranchTrueFalseTotal
if ($is_native) { } 1 0 1
353 1 { $coerced = $message;
354 1 $basename = basename $message->filename;
355 }
356 else
357 0 { $coerced = $self->SUPER::coerce($message);
358 0 ▶ $basename = ($message->timestamp||time).'.'. hostname.'.'.$uniq++;
Condition0%0/2
$message->timestamp || time
l!l
00
MC/DC0%0/1
$message->timestamp || time
$message->timestamp
Truth table0%0/2
A
A= $message->timestamp
Aresult
11
00
359 }
360  
361 1 my $dir = $self->directory;
362 1 $coerced->create("$dir/tmp/$basename");
363 1 my $new = $coerced->create("$dir/new/$basename");
364 1 trace "Appended Maildir message in $new";
365 }
366  
367 1 $self->close;
368 1 @messages;
369 }
370  
371 #--------------------
372  
373 6 1;
« Box/Net.pm ↑ Summary Box/Locker/Mutt.pm »