line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2019 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
|
|
847
|
use vars '$VERSION'; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
609
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.008'; |
12
|
|
|
|
|
|
|
|
13
|
14
|
|
|
14
|
|
218
|
use base 'Mail::Box'; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
3217
|
|
14
|
|
|
|
|
|
|
|
15
|
14
|
|
|
14
|
|
87
|
use strict; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
392
|
|
16
|
14
|
|
|
14
|
|
79
|
use warnings; |
|
14
|
|
|
|
|
20
|
|
|
14
|
|
|
|
|
369
|
|
17
|
14
|
|
|
14
|
|
3886
|
use filetest 'access'; |
|
14
|
|
|
|
|
99
|
|
|
14
|
|
|
|
|
65
|
|
18
|
|
|
|
|
|
|
|
19
|
14
|
|
|
14
|
|
5321
|
use Mail::Box::Dir::Message; |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
442
|
|
20
|
|
|
|
|
|
|
|
21
|
14
|
|
|
14
|
|
77
|
use Mail::Message::Body::Lines; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
254
|
|
22
|
14
|
|
|
14
|
|
54
|
use Mail::Message::Body::File; |
|
14
|
|
|
|
|
60
|
|
|
14
|
|
|
|
|
254
|
|
23
|
14
|
|
|
14
|
|
2544
|
use Mail::Message::Body::Delayed; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
295
|
|
24
|
14
|
|
|
14
|
|
66
|
use Mail::Message::Body::Multipart; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
268
|
|
25
|
|
|
|
|
|
|
|
26
|
14
|
|
|
14
|
|
63
|
use Mail::Message::Head; |
|
14
|
|
|
|
|
21
|
|
|
14
|
|
|
|
|
225
|
|
27
|
14
|
|
|
14
|
|
5302
|
use Mail::Message::Head::Delayed; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
342
|
|
28
|
|
|
|
|
|
|
|
29
|
14
|
|
|
14
|
|
76
|
use Carp; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
606
|
|
30
|
14
|
|
|
14
|
|
64
|
use File::Copy; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
493
|
|
31
|
14
|
|
|
14
|
|
59
|
use File::Spec; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
255
|
|
32
|
14
|
|
|
14
|
|
59
|
use File::Basename; |
|
14
|
|
|
|
|
21
|
|
|
14
|
|
|
|
|
6401
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub init($) |
36
|
35
|
|
|
35
|
0
|
71
|
{ my ($self, $args) = @_; |
37
|
|
|
|
|
|
|
|
38
|
35
|
|
50
|
104
|
|
245
|
$args->{body_type} ||= sub {'Mail::Message::Body::Lines'}; |
|
104
|
|
|
|
|
271
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return undef |
41
|
35
|
50
|
|
|
|
136
|
unless $self->SUPER::init($args); |
42
|
|
|
|
|
|
|
|
43
|
35
|
|
|
|
|
73
|
my $class = ref $self; |
44
|
|
|
|
|
|
|
my $directory = $self->{MBD_directory} |
45
|
35
|
|
33
|
|
|
181
|
= $args->{directory} || $self->directory; |
46
|
|
|
|
|
|
|
|
47
|
35
|
100
|
33
|
|
|
584
|
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
|
|
|
|
|
133
|
for($args->{lock_file}) |
57
|
35
|
0
|
|
|
|
145
|
{ $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
|
|
|
89
|
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
|
|
|
|
|
188
|
$self; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#------------------------------------------- |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub organization() { 'DIRECTORY' } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#------------------------------------------- |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub directory() |
82
|
153
|
|
|
153
|
1
|
241
|
{ my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$self->{MBD_directory} |
85
|
153
|
|
66
|
|
|
524
|
||= $self->folderToDirectory($self->name, $self->folderdir); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#------------------------------------------- |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub nameOfSubFolder($;$) |
91
|
70
|
|
|
70
|
1
|
110
|
{ my ($thing, $name) = (shift, shift); |
92
|
70
|
50
|
|
|
|
146
|
my $parent = @_ ? shift : ref $thing ? $thing->directory : undef; |
|
|
100
|
|
|
|
|
|
93
|
70
|
50
|
|
|
|
221
|
defined $parent ? "$parent/$name" : $name; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#------------------------------------------- |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub folderToDirectory($$) |
100
|
91
|
|
|
91
|
1
|
183
|
{ my ($class, $name, $folderdir) = @_; |
101
|
91
|
100
|
|
|
|
297
|
my $dir = ( $name =~ m#^=\/?(.*)# ? "$folderdir/$1" : $name); |
102
|
91
|
|
|
|
|
179
|
$dir =~ s!/$!!; |
103
|
91
|
|
|
|
|
272
|
$dir; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
#------------------------------------------- |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
0
|
1
|
|
sub readMessageFilenames() {shift->notImplemented} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
#------------------------------------------- |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |