line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2020 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
|
|
|
|
|
|
# This code is part of distribution Mail-Box. Meta-POD processed with |
6
|
|
|
|
|
|
|
# OODoc into POD and HTML manual-pages. See README.md |
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Mail::Box::Dir; |
10
|
14
|
|
|
14
|
|
1066
|
use vars '$VERSION'; |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
818
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.009'; |
12
|
|
|
|
|
|
|
|
13
|
14
|
|
|
14
|
|
246
|
use base 'Mail::Box'; |
|
14
|
|
|
|
|
37
|
|
|
14
|
|
|
|
|
4087
|
|
14
|
|
|
|
|
|
|
|
15
|
14
|
|
|
14
|
|
105
|
use strict; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
437
|
|
16
|
14
|
|
|
14
|
|
104
|
use warnings; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
480
|
|
17
|
14
|
|
|
14
|
|
4254
|
use filetest 'access'; |
|
14
|
|
|
|
|
126
|
|
|
14
|
|
|
|
|
78
|
|
18
|
|
|
|
|
|
|
|
19
|
14
|
|
|
14
|
|
6542
|
use Mail::Box::Dir::Message; |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
546
|
|
20
|
|
|
|
|
|
|
|
21
|
14
|
|
|
14
|
|
90
|
use Mail::Message::Body::Lines; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
321
|
|
22
|
14
|
|
|
14
|
|
65
|
use Mail::Message::Body::File; |
|
14
|
|
|
|
|
80
|
|
|
14
|
|
|
|
|
313
|
|
23
|
14
|
|
|
14
|
|
3137
|
use Mail::Message::Body::Delayed; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
346
|
|
24
|
14
|
|
|
14
|
|
83
|
use Mail::Message::Body::Multipart; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
333
|
|
25
|
|
|
|
|
|
|
|
26
|
14
|
|
|
14
|
|
79
|
use Mail::Message::Head; |
|
14
|
|
|
|
|
37
|
|
|
14
|
|
|
|
|
309
|
|
27
|
14
|
|
|
14
|
|
6693
|
use Mail::Message::Head::Delayed; |
|
14
|
|
|
|
|
37
|
|
|
14
|
|
|
|
|
423
|
|
28
|
|
|
|
|
|
|
|
29
|
14
|
|
|
14
|
|
87
|
use Carp; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
838
|
|
30
|
14
|
|
|
14
|
|
87
|
use File::Copy; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
569
|
|
31
|
14
|
|
|
14
|
|
79
|
use File::Spec; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
350
|
|
32
|
14
|
|
|
14
|
|
85
|
use File::Basename; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
9970
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub init($) |
36
|
35
|
|
|
35
|
0
|
91
|
{ my ($self, $args) = @_; |
37
|
|
|
|
|
|
|
|
38
|
35
|
|
50
|
104
|
|
336
|
$args->{body_type} ||= sub {'Mail::Message::Body::Lines'}; |
|
104
|
|
|
|
|
290
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return undef |
41
|
35
|
50
|
|
|
|
185
|
unless $self->SUPER::init($args); |
42
|
|
|
|
|
|
|
|
43
|
35
|
|
|
|
|
95
|
my $class = ref $self; |
44
|
|
|
|
|
|
|
my $directory = $self->{MBD_directory} |
45
|
35
|
|
33
|
|
|
220
|
= $args->{directory} || $self->directory; |
46
|
|
|
|
|
|
|
|
47
|
35
|
100
|
33
|
|
|
740
|
if(-d $directory) {;} |
|
|
50
|
|
|
|
|
|
48
|
|
|
|
|
|
|
elsif($args->{create} && $class->create($directory, %$args)) {;} |
49
|
|
|
|
|
|
|
else |
50
|
0
|
|
|
|
|
0
|
{ $self->log(NOTICE => "No directory $directory for folder of $class"); |
51
|
0
|
|
|
|
|
0
|
return undef; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# About locking |
55
|
|
|
|
|
|
|
|
56
|
35
|
|
|
|
|
168
|
for($args->{lock_file}) |
57
|
35
|
0
|
|
|
|
215
|
{ $self->locker->filename |
|
|
50
|
|
|
|
|
|
58
|
|
|
|
|
|
|
( !defined $_ ? File::Spec->catfile($directory, '.lock') # default |
59
|
|
|
|
|
|
|
: File::Spec->file_name_is_absolute($_) ? $_ # absolute |
60
|
|
|
|
|
|
|
: File::Spec->catfile($directory, $_) # relative |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Check if we can write to the folder, if we need to. |
65
|
|
|
|
|
|
|
|
66
|
35
|
50
|
66
|
|
|
118
|
if($self->writable && -e $directory && ! -w $directory) |
|
|
|
66
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
{ $self->log(WARNING=> "Folder directory $directory is write-protected."); |
68
|
0
|
|
|
|
|
0
|
$self->{MB_access} = 'r'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
35
|
|
|
|
|
192
|
$self; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#------------------------------------------- |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub organization() { 'DIRECTORY' } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#------------------------------------------- |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub directory() |
82
|
153
|
|
|
153
|
1
|
265
|
{ my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$self->{MBD_directory} |
85
|
153
|
|
66
|
|
|
620
|
||= $self->folderToDirectory($self->name, $self->folderdir); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#------------------------------------------- |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub nameOfSubFolder($;$) |
91
|
70
|
|
|
70
|
1
|
142
|
{ my ($thing, $name) = (shift, shift); |
92
|
70
|
50
|
|
|
|
177
|
my $parent = @_ ? shift : ref $thing ? $thing->directory : undef; |
|
|
100
|
|
|
|
|
|
93
|
70
|
50
|
|
|
|
271
|
defined $parent ? "$parent/$name" : $name; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#------------------------------------------- |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub folderToDirectory($$) |
100
|
91
|
|
|
91
|
1
|
228
|
{ my ($class, $name, $folderdir) = @_; |
101
|
91
|
100
|
|
|
|
385
|
my $dir = ( $name =~ m#^=\/?(.*)# ? "$folderdir/$1" : $name); |
102
|
91
|
|
|
|
|
228
|
$dir =~ s!/$!!; |
103
|
91
|
|
|
|
|
338
|
$dir; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub storeMessage($) |
107
|
780
|
|
|
780
|
1
|
1313
|
{ my ($self, $message) = @_; |
108
|
780
|
|
|
|
|
2284
|
$self->SUPER::storeMessage($message); |
109
|
780
|
100
|
|
|
|
1724
|
my $fn = $message->filename or return $message; |
110
|
738
|
|
|
|
|
2811
|
$self->{MBD_by_fn}{$fn} = $message; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
0
|
1
|
|
sub messageInFile($) { $_[0]->{MBD_by_fn}{$_[1]} } |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
0
|
1
|
|
sub readMessageFilenames() {shift->notImplemented} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
#------------------------------------------- |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |