| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Toader::Directory; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
23
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
159
|
|
|
4
|
4
|
|
|
4
|
|
23
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
92
|
|
|
5
|
4
|
|
|
4
|
|
22
|
use base 'Error::Helper'; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
303
|
|
|
6
|
4
|
|
|
4
|
|
25
|
use Toader::pathHelper; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
120
|
|
|
7
|
4
|
|
|
4
|
|
2251
|
use Email::MIME; |
|
|
4
|
|
|
|
|
71752
|
|
|
|
4
|
|
|
|
|
13140
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Toader::Directory - This the index file for a Toader directory. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.1.0 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
For information on the storage and rendering of entries, |
|
24
|
|
|
|
|
|
|
please see 'Documentation/Directory.pod'. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 new |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This initializes the object. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
One argument is required and it is a L object. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $foo = Toader::Directory->new($toader); |
|
35
|
|
|
|
|
|
|
if ($foo->error){ |
|
36
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new{ |
|
42
|
0
|
|
|
0
|
1
|
|
my $toader=$_[1]; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $self={ |
|
45
|
|
|
|
|
|
|
error=>undef, |
|
46
|
|
|
|
|
|
|
errorString=>'', |
|
47
|
|
|
|
|
|
|
perror=>undef, |
|
48
|
|
|
|
|
|
|
dir=>undef, |
|
49
|
|
|
|
|
|
|
errorExtra=>{ |
|
50
|
|
|
|
|
|
|
flags=>{ |
|
51
|
|
|
|
|
|
|
1=>'openIndexFailed', |
|
52
|
|
|
|
|
|
|
2=>'noAtoaderDir', |
|
53
|
|
|
|
|
|
|
3=>'noTitleSpecified', |
|
54
|
|
|
|
|
|
|
4=>'noDirSet', |
|
55
|
|
|
|
|
|
|
5=>'noLongerAtoaderDir', |
|
56
|
|
|
|
|
|
|
6=>'indexOpenForWritingFailed', |
|
57
|
|
|
|
|
|
|
7=>'openDirFailed', |
|
58
|
|
|
|
|
|
|
8=>'noSummarySpecified', |
|
59
|
|
|
|
|
|
|
9=>'notAtoaderObj', |
|
60
|
|
|
|
|
|
|
10=>'getVCSerrored', |
|
61
|
|
|
|
|
|
|
11=>'VCSusableErrored', |
|
62
|
|
|
|
|
|
|
12=>'underVCSerrored', |
|
63
|
|
|
|
|
|
|
13=>'VCSaddErrored', |
|
64
|
|
|
|
|
|
|
14=>'noToaderObj', |
|
65
|
|
|
|
|
|
|
}, |
|
66
|
|
|
|
|
|
|
}, |
|
67
|
|
|
|
|
|
|
VCSusable=>0, |
|
68
|
|
|
|
|
|
|
}; |
|
69
|
0
|
|
|
|
|
|
bless $self; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#if we have a Toader object, reel it in |
|
72
|
0
|
0
|
|
|
|
|
if ( ! defined( $toader ) ){ |
|
73
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
74
|
0
|
|
|
|
|
|
$self->{error}=14; |
|
75
|
0
|
|
|
|
|
|
$self->{errorString}='No Toader object specified'; |
|
76
|
0
|
|
|
|
|
|
$self->warn; |
|
77
|
0
|
|
|
|
|
|
return $self; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
|
80
|
0
|
0
|
|
|
|
|
if ( ref( $toader ) ne "Toader" ){ |
|
81
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
82
|
0
|
|
|
|
|
|
$self->{error}=9; |
|
83
|
0
|
|
|
|
|
|
$self->{errorString}='The object specified is a "'.ref($toader).'"'; |
|
84
|
0
|
|
|
|
|
|
$self->warn; |
|
85
|
0
|
|
|
|
|
|
return $self; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
0
|
|
|
|
|
|
$self->{toader}=$toader; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#gets the Toader::VCS object |
|
90
|
0
|
|
|
|
|
|
$self->{vcs}=$self->{toader}->getVCS; |
|
91
|
0
|
0
|
|
|
|
|
if ( $toader->error ){ |
|
92
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
93
|
0
|
|
|
|
|
|
$self->{error}=10; |
|
94
|
|
|
|
|
|
|
$self->{errorString}='Toader->getVCS errored. error="'. |
|
95
|
0
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
|
96
|
0
|
|
|
|
|
|
$self->warn; |
|
97
|
0
|
|
|
|
|
|
return $self; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#checks if VCS is usable |
|
101
|
0
|
|
|
|
|
|
$self->{VCSusable}=$self->{vcs}->usable; |
|
102
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
|
103
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
104
|
0
|
|
|
|
|
|
$self->{error}=11; |
|
105
|
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->usable errored. error="'. |
|
106
|
0
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
|
107
|
0
|
|
|
|
|
|
$self->warn; |
|
108
|
0
|
|
|
|
|
|
return $self; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return $self; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 as_string |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This returns the directory as a string. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $mimeString=$foo->as_string; |
|
119
|
|
|
|
|
|
|
if($foo->error) |
|
120
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub as_string{ |
|
126
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
129
|
0
|
|
|
|
|
|
return undef; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
return $self->{mime}->as_string; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 bodyGet |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This gets body. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $body=$foo->bodyGet; |
|
140
|
|
|
|
|
|
|
if($foo->error){ |
|
141
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub bodyGet{ |
|
147
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
150
|
0
|
|
|
|
|
|
return undef; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
my @parts=$self->{mime}->subparts; |
|
154
|
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
my $int=0; |
|
156
|
0
|
|
|
|
|
|
while ( defined( $parts[$int] ) ){ |
|
157
|
0
|
0
|
|
|
|
|
if ( ! defined( $parts[$int]->filename ) ){ |
|
158
|
0
|
|
|
|
|
|
return $parts[$int]->body; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
$int++; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
return $self->{mime}->body; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 bodySet |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This sets the body. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
One argument is required and it is the body. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$foo->bodySet($body); |
|
174
|
|
|
|
|
|
|
if($foo->error){ |
|
175
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub bodySet{ |
|
181
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
182
|
0
|
|
|
|
|
|
my $body=$_[1]; |
|
183
|
|
|
|
|
|
|
|
|
184
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
185
|
0
|
|
|
|
|
|
return undef; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
0
|
0
|
|
|
|
|
if (!defined($body)) { |
|
189
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
190
|
0
|
|
|
|
|
|
$self->{errorString}='No body defined'; |
|
191
|
0
|
|
|
|
|
|
$self->warn; |
|
192
|
0
|
|
|
|
|
|
return undef; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
my @parts=$self->{mime}->subparts; |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
0
|
|
|
|
|
if ( defined( $parts[1] ) ){ |
|
199
|
0
|
|
|
|
|
|
my $int=0; |
|
200
|
0
|
|
|
|
|
|
while ( defined( $parts[$int] ) ){ |
|
201
|
0
|
0
|
|
|
|
|
if ( ! defined( $parts[$int]->filename ) ){ |
|
202
|
0
|
|
|
|
|
|
$parts[$int]->body_set($body); |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
|
$int++; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
$self->{mime}->parts_set( \@parts ); |
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
return 1; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
$self->{mime}->body_set($body); |
|
214
|
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
return 1; |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head2 dirGet |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
This gets L directory this entry is associated with. |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
This will only error if a permanent error is set. |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
my $dir=$foo->dirGet; |
|
225
|
|
|
|
|
|
|
if($foo->error){ |
|
226
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=cut |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub dirGet{ |
|
232
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
233
|
|
|
|
|
|
|
|
|
234
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
235
|
0
|
|
|
|
|
|
$self->warn; |
|
236
|
0
|
|
|
|
|
|
return undef; |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
return $self->{dir}; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head2 dirSet |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This sets L directory this entry is associated with. |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
One argument is taken and it is the L directory to set it to. |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
$foo->dirSet($toaderDirectory); |
|
249
|
|
|
|
|
|
|
if($foo->error){ |
|
250
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
251
|
|
|
|
|
|
|
} |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=cut |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub dirSet{ |
|
256
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
257
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
|
258
|
|
|
|
|
|
|
|
|
259
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
260
|
0
|
|
|
|
|
|
return undef; |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
#checks if the directory is Toader directory or not |
|
264
|
0
|
|
|
|
|
|
my $isatd=Toader::isaToaderDir->new; |
|
265
|
0
|
|
|
|
|
|
my $returned=$isatd->isaToaderDir($dir); |
|
266
|
0
|
0
|
|
|
|
|
if (! $returned ) { |
|
267
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
268
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not a Toader directory'; |
|
269
|
0
|
|
|
|
|
|
$self->warn; |
|
270
|
0
|
|
|
|
|
|
return undef; |
|
271
|
|
|
|
|
|
|
} |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
#clean it up and save it for later |
|
274
|
0
|
|
|
|
|
|
$self->{pathHelper}=Toader::pathHelper->new( $dir ); |
|
275
|
0
|
|
|
|
|
|
$self->{dir}=$self->{pathHelper}->cleanup( $dir ); |
|
276
|
0
|
|
|
|
|
|
$self->{indexfile}=$dir.'/.toader/index'; |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
#cleans up the naming |
|
279
|
0
|
|
|
|
|
|
my $pathHelper=Toader::pathHelper->new($dir); |
|
280
|
0
|
|
|
|
|
|
$dir=$pathHelper->cleanup($dir); |
|
281
|
0
|
|
|
|
|
|
$self->{indexfile}=$pathHelper->cleanup( $dir ).'/.toader/index'; |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
#removes the old mime object |
|
284
|
0
|
0
|
|
|
|
|
if (defined($self->{mime})) { |
|
285
|
0
|
|
|
|
|
|
delete($self->{mime}); |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
0
|
0
|
|
|
|
|
if ( ! -f $self->{indexfile}) { |
|
289
|
0
|
|
|
|
|
|
$self->{mime}=Email::MIME->create( |
|
290
|
|
|
|
|
|
|
header=>[ |
|
291
|
|
|
|
|
|
|
renderer=>'html', |
|
292
|
|
|
|
|
|
|
summary=>'', |
|
293
|
|
|
|
|
|
|
], |
|
294
|
|
|
|
|
|
|
body=>'', |
|
295
|
|
|
|
|
|
|
); |
|
296
|
|
|
|
|
|
|
}else { |
|
297
|
|
|
|
|
|
|
#read the index file |
|
298
|
0
|
|
|
|
|
|
my $fh; |
|
299
|
0
|
0
|
|
|
|
|
if ( ! open( $fh, '<', $self->{indexfile} ) ) { |
|
300
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
301
|
0
|
|
|
|
|
|
$self->{errorString}="unable to open '".$self->{indexfile}."'"; |
|
302
|
0
|
|
|
|
|
|
$self->warn; |
|
303
|
0
|
|
|
|
|
|
return $self; |
|
304
|
|
|
|
|
|
|
} |
|
305
|
0
|
|
|
|
|
|
my $file=join('',<$fh>); |
|
306
|
0
|
|
|
|
|
|
close $fh; |
|
307
|
|
|
|
|
|
|
|
|
308
|
0
|
|
|
|
|
|
$self->{mime}=Email::MIME->new($file); |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
} |
|
311
|
|
|
|
|
|
|
|
|
312
|
0
|
|
|
|
|
|
return 1; |
|
313
|
|
|
|
|
|
|
} |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=head2 listSubToaderDirs |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
This lists the sub L directories in the current L directory, ignoring items |
|
318
|
|
|
|
|
|
|
starting with a '.'. |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
The returned value is a array containing a list of relative directory names. |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
This method requires dirSet to have been used previously. |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
my @subToaderDirs=$foo->listSubToaderDirs; |
|
325
|
|
|
|
|
|
|
if($foo->error){ |
|
326
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
327
|
|
|
|
|
|
|
} |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=cut |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub listSubToaderDirs{ |
|
332
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
333
|
|
|
|
|
|
|
|
|
334
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
335
|
0
|
|
|
|
|
|
return undef; |
|
336
|
|
|
|
|
|
|
} |
|
337
|
|
|
|
|
|
|
|
|
338
|
0
|
0
|
|
|
|
|
if ( ! defined( $self->{dir} ) ){ |
|
339
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
340
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been specified yet'; |
|
341
|
0
|
|
|
|
|
|
$self->warn; |
|
342
|
0
|
|
|
|
|
|
return undef; |
|
343
|
|
|
|
|
|
|
} |
|
344
|
|
|
|
|
|
|
|
|
345
|
0
|
|
|
|
|
|
my $dh; |
|
346
|
0
|
0
|
|
|
|
|
if ( ! opendir( $dh, $self->{dir} ) ){ |
|
347
|
0
|
|
|
|
|
|
$self->{error}=7; |
|
348
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to open the directory, "'.$self->{dir}.'",'; |
|
349
|
0
|
|
|
|
|
|
$self->warn; |
|
350
|
0
|
|
|
|
|
|
return undef; |
|
351
|
|
|
|
|
|
|
} |
|
352
|
0
|
|
|
|
|
|
my @dirEntries=readdir( $dh ); |
|
353
|
0
|
|
|
|
|
|
closedir( $dh ); |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
#find the various sub directories |
|
356
|
0
|
|
|
|
|
|
my $isatd=Toader::isaToaderDir->new; |
|
357
|
0
|
|
|
|
|
|
my @subdirs; |
|
358
|
0
|
|
|
|
|
|
my $int=0; |
|
359
|
0
|
|
|
|
|
|
while ( defined( $dirEntries[$int] ) ){ |
|
360
|
0
|
|
|
|
|
|
my $add=1; |
|
361
|
|
|
|
|
|
|
|
|
362
|
0
|
0
|
|
|
|
|
if ( ! -d $self->{dir}.'/'.$dirEntries[$int] ){ |
|
363
|
0
|
|
|
|
|
|
$add=0; |
|
364
|
|
|
|
|
|
|
} |
|
365
|
|
|
|
|
|
|
|
|
366
|
0
|
0
|
|
|
|
|
if ( $dirEntries[$int] =~ /^\./ ){ |
|
367
|
0
|
|
|
|
|
|
$add=0; |
|
368
|
|
|
|
|
|
|
} |
|
369
|
|
|
|
|
|
|
|
|
370
|
0
|
0
|
|
|
|
|
if ( $add ){ |
|
371
|
0
|
|
|
|
|
|
my $returned=$isatd->isaToaderDir( $self->{dir}.'/'.$dirEntries[$int] ); |
|
372
|
0
|
0
|
|
|
|
|
if ( $returned ){ |
|
373
|
0
|
|
|
|
|
|
push( @subdirs, $dirEntries[$int] ); |
|
374
|
|
|
|
|
|
|
} |
|
375
|
|
|
|
|
|
|
} |
|
376
|
|
|
|
|
|
|
|
|
377
|
0
|
|
|
|
|
|
$int++; |
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
|
|
380
|
0
|
|
|
|
|
|
return @subdirs; |
|
381
|
|
|
|
|
|
|
} |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
=head2 rendererGet |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
This returns the renderer type. |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
my $renderer=$foo->rendererGet; |
|
388
|
|
|
|
|
|
|
if($foo->error){ |
|
389
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
390
|
|
|
|
|
|
|
} |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=cut |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
sub rendererGet{ |
|
395
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
396
|
|
|
|
|
|
|
|
|
397
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
398
|
0
|
|
|
|
|
|
return undef; |
|
399
|
|
|
|
|
|
|
} |
|
400
|
|
|
|
|
|
|
|
|
401
|
0
|
|
|
|
|
|
return $self->{mime}->header('renderer'); |
|
402
|
|
|
|
|
|
|
} |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=head2 rendererSet |
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
This sets the renderer type. |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
One argument is taken and it is the render type. |
|
409
|
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
A value of undef sets it to the default, 'html'. |
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
my $renderer=$foo->rendererGet; |
|
413
|
|
|
|
|
|
|
if($foo->error){ |
|
414
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
415
|
|
|
|
|
|
|
} |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=cut |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
sub rendererSet{ |
|
420
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
421
|
0
|
|
|
|
|
|
my $renderer=$_[1]; |
|
422
|
|
|
|
|
|
|
|
|
423
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
424
|
0
|
|
|
|
|
|
return undef; |
|
425
|
|
|
|
|
|
|
} |
|
426
|
|
|
|
|
|
|
|
|
427
|
0
|
0
|
|
|
|
|
if (!defined( $renderer )) { |
|
428
|
0
|
|
|
|
|
|
$renderer='html'; |
|
429
|
|
|
|
|
|
|
} |
|
430
|
|
|
|
|
|
|
|
|
431
|
0
|
|
|
|
|
|
$self->{mime}->header_set('renderer'=>$renderer); |
|
432
|
|
|
|
|
|
|
|
|
433
|
0
|
|
|
|
|
|
return 1; |
|
434
|
|
|
|
|
|
|
} |
|
435
|
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
=head2 subpartsAdd |
|
437
|
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
This adds a new file as a subpart. |
|
439
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
One argument is required and it is the path to the file. |
|
441
|
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
$foo->subpartsAdd( $file ); |
|
443
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
444
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
445
|
|
|
|
|
|
|
} |
|
446
|
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=cut |
|
448
|
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
sub subpartsAdd{ |
|
450
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
451
|
0
|
|
|
|
|
|
my $file=$_[1]; |
|
452
|
|
|
|
|
|
|
|
|
453
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
454
|
0
|
|
|
|
|
|
return undef; |
|
455
|
|
|
|
|
|
|
} |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
#makes sure a file is specified |
|
458
|
0
|
0
|
|
|
|
|
if ( ! defined( $file ) ){ |
|
459
|
0
|
|
|
|
|
|
$self->{error}=18; |
|
460
|
0
|
|
|
|
|
|
$self->{errorstring}='No file specified'; |
|
461
|
0
|
|
|
|
|
|
$self->warn; |
|
462
|
0
|
|
|
|
|
|
return undef; |
|
463
|
|
|
|
|
|
|
} |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
#makes sure the file exists and is a file |
|
466
|
0
|
0
|
|
|
|
|
if ( ! -f $file ){ |
|
467
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
468
|
0
|
|
|
|
|
|
$self->{errorString}='The file, "'.$file.'", does not exist or is not a file'; |
|
469
|
0
|
|
|
|
|
|
$self->warn; |
|
470
|
0
|
|
|
|
|
|
return undef; |
|
471
|
|
|
|
|
|
|
} |
|
472
|
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
#gets the MIME type |
|
474
|
0
|
|
|
|
|
|
my $mimetype=mimetype( $file ); |
|
475
|
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
#makes sure it is a mimetype |
|
477
|
0
|
0
|
|
|
|
|
if ( !defined( $mimetype ) ) { |
|
478
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
479
|
0
|
|
|
|
|
|
$self->{errorString}="'".$file."' could not be read or does not exist"; |
|
480
|
0
|
|
|
|
|
|
$self->warn; |
|
481
|
0
|
|
|
|
|
|
return $self; |
|
482
|
|
|
|
|
|
|
} |
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
#create a short name for it... removing the path |
|
485
|
0
|
|
|
|
|
|
my $filename=$file; |
|
486
|
0
|
|
|
|
|
|
$filename=~s/.*\///g; |
|
487
|
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
#open and read the file |
|
489
|
0
|
|
|
|
|
|
my $fh; |
|
490
|
0
|
0
|
|
|
|
|
if ( ! open( $fh, '<', $file ) ) { |
|
491
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
492
|
0
|
|
|
|
|
|
$self->{errorString}="Unable to open '".$file."'"; |
|
493
|
0
|
|
|
|
|
|
$self->warn; |
|
494
|
0
|
|
|
|
|
|
return undef; |
|
495
|
|
|
|
|
|
|
} |
|
496
|
0
|
|
|
|
|
|
my $body=join('',<$fh>); |
|
497
|
0
|
|
|
|
|
|
close $fh; |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
#creates the part |
|
501
|
0
|
|
|
|
|
|
my $part=Email::MIME->create(attributes=>{ |
|
502
|
|
|
|
|
|
|
filename=>$filename, |
|
503
|
|
|
|
|
|
|
content_type=>$mimetype, |
|
504
|
|
|
|
|
|
|
encode=>"base64", |
|
505
|
|
|
|
|
|
|
}, |
|
506
|
|
|
|
|
|
|
body=>$body, |
|
507
|
|
|
|
|
|
|
); |
|
508
|
0
|
|
|
|
|
|
my @parts; |
|
509
|
0
|
|
|
|
|
|
push( @parts, $part ); |
|
510
|
0
|
|
|
|
|
|
$self->{mime}->parts_add( \@parts ); |
|
511
|
|
|
|
|
|
|
|
|
512
|
0
|
|
|
|
|
|
return 1; |
|
513
|
|
|
|
|
|
|
} |
|
514
|
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=head2 subpartsExtract |
|
516
|
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
This extracts the subparts of a entry. |
|
518
|
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
One argument is extracted, it is the directory |
|
520
|
|
|
|
|
|
|
to extract the files to. |
|
521
|
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
$foo->subpartsExtract( $dir ); |
|
523
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
524
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
525
|
|
|
|
|
|
|
} |
|
526
|
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=cut |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
sub subpartsExtract{ |
|
530
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
531
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
|
532
|
|
|
|
|
|
|
|
|
533
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
534
|
0
|
|
|
|
|
|
return undef; |
|
535
|
|
|
|
|
|
|
} |
|
536
|
|
|
|
|
|
|
|
|
537
|
0
|
0
|
|
|
|
|
if ( ! defined( $dir ) ){ |
|
538
|
0
|
|
|
|
|
|
$self->{error}=11; |
|
539
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
540
|
0
|
|
|
|
|
|
$self->warn; |
|
541
|
0
|
|
|
|
|
|
return undef; |
|
542
|
|
|
|
|
|
|
} |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
#make sure it exists and is a directory |
|
545
|
0
|
0
|
|
|
|
|
if ( ! -d $dir ){ |
|
546
|
0
|
|
|
|
|
|
$self->{error}=17; |
|
547
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not a directory or does not exist'; |
|
548
|
0
|
|
|
|
|
|
$self->warn; |
|
549
|
0
|
|
|
|
|
|
return undef; |
|
550
|
|
|
|
|
|
|
} |
|
551
|
|
|
|
|
|
|
|
|
552
|
0
|
|
|
|
|
|
my @subparts=$self->subpartsGet; |
|
553
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
554
|
0
|
|
|
|
|
|
$self->warnString('Failed to get the subparts'); |
|
555
|
0
|
|
|
|
|
|
return undef; |
|
556
|
|
|
|
|
|
|
} |
|
557
|
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
# no subparts to write to the FS |
|
559
|
0
|
0
|
|
|
|
|
if ( ! defined( $subparts[0] ) ){ |
|
560
|
0
|
|
|
|
|
|
return 1; |
|
561
|
|
|
|
|
|
|
} |
|
562
|
|
|
|
|
|
|
|
|
563
|
0
|
|
|
|
|
|
my $int=0; |
|
564
|
0
|
|
|
|
|
|
while ( defined( $subparts[$int] ) ){ |
|
565
|
0
|
|
|
|
|
|
my $file=$subparts[$int]->filename; |
|
566
|
0
|
0
|
|
|
|
|
if( defined( $file ) ){ |
|
567
|
0
|
|
|
|
|
|
my $file=$dir.'/'.$file; |
|
568
|
|
|
|
|
|
|
|
|
569
|
0
|
|
|
|
|
|
my $fh; |
|
570
|
0
|
0
|
|
|
|
|
if ( ! open( $fh, '>', $file ) ){ |
|
571
|
0
|
|
|
|
|
|
$self->{error}=18; |
|
572
|
0
|
|
|
|
|
|
$self->{errorString}='"Failed to open "'.$file. |
|
573
|
|
|
|
|
|
|
'" for writing the body of a subpart out to'; |
|
574
|
0
|
|
|
|
|
|
$self->warn; |
|
575
|
0
|
|
|
|
|
|
return undef; |
|
576
|
|
|
|
|
|
|
} |
|
577
|
0
|
|
|
|
|
|
print $fh $subparts[$int]->body; |
|
578
|
0
|
|
|
|
|
|
close( $fh ); |
|
579
|
|
|
|
|
|
|
} |
|
580
|
|
|
|
|
|
|
|
|
581
|
0
|
|
|
|
|
|
$int++; |
|
582
|
|
|
|
|
|
|
} |
|
583
|
|
|
|
|
|
|
|
|
584
|
0
|
|
|
|
|
|
return 1; |
|
585
|
|
|
|
|
|
|
} |
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=head2 subpartsGet |
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
This returns the results from the subparts |
|
590
|
|
|
|
|
|
|
methods from the internal L object. |
|
591
|
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
my @parts=$foo->subpartsGet; |
|
593
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
594
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
595
|
|
|
|
|
|
|
} |
|
596
|
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=cut |
|
598
|
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
sub subpartsGet{ |
|
600
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
601
|
|
|
|
|
|
|
|
|
602
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
603
|
0
|
|
|
|
|
|
return undef; |
|
604
|
|
|
|
|
|
|
} |
|
605
|
|
|
|
|
|
|
|
|
606
|
0
|
|
|
|
|
|
return $self->{mime}->subparts; |
|
607
|
|
|
|
|
|
|
} |
|
608
|
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=head2 subpartsList |
|
610
|
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
This returns a list filenames for the subparts. |
|
612
|
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
my @files=$foo->subpartsList; |
|
614
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
615
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
616
|
|
|
|
|
|
|
} |
|
617
|
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
=cut |
|
619
|
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
sub subpartsList{ |
|
621
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
622
|
|
|
|
|
|
|
|
|
623
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
624
|
0
|
|
|
|
|
|
return undef; |
|
625
|
|
|
|
|
|
|
} |
|
626
|
|
|
|
|
|
|
|
|
627
|
0
|
|
|
|
|
|
my @subparts=$self->subpartsGet; |
|
628
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
629
|
0
|
|
|
|
|
|
$self->warnString('Failed to get the subparts'); |
|
630
|
0
|
|
|
|
|
|
return undef; |
|
631
|
|
|
|
|
|
|
} |
|
632
|
|
|
|
|
|
|
|
|
633
|
0
|
|
|
|
|
|
my @files; |
|
634
|
0
|
|
|
|
|
|
my $int=0; |
|
635
|
0
|
|
|
|
|
|
while( defined( $subparts[$int] ) ){ |
|
636
|
0
|
0
|
|
|
|
|
if ( defined( $subparts[$int]->filename ) ){ |
|
637
|
0
|
|
|
|
|
|
push( @files, $subparts[$int]->filename ); |
|
638
|
|
|
|
|
|
|
} |
|
639
|
|
|
|
|
|
|
|
|
640
|
0
|
|
|
|
|
|
$int++; |
|
641
|
|
|
|
|
|
|
} |
|
642
|
|
|
|
|
|
|
|
|
643
|
0
|
|
|
|
|
|
return @files; |
|
644
|
|
|
|
|
|
|
} |
|
645
|
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=head2 subpartsRemove |
|
647
|
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
This removes the specified subpart. |
|
649
|
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
One argument is required and it is the name of the |
|
651
|
|
|
|
|
|
|
file to remove. |
|
652
|
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
$foo->subpartsRemove( $filename ); |
|
654
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
655
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
656
|
|
|
|
|
|
|
} |
|
657
|
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
=cut |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
sub subpartsRemove{ |
|
661
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
662
|
0
|
|
|
|
|
|
my $file=$_[1]; |
|
663
|
|
|
|
|
|
|
|
|
664
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
665
|
0
|
|
|
|
|
|
return undef; |
|
666
|
|
|
|
|
|
|
} |
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
#makes sure a file is specified |
|
669
|
0
|
0
|
|
|
|
|
if ( ! defined( $file ) ){ |
|
670
|
0
|
|
|
|
|
|
$self->{error}=18; |
|
671
|
0
|
|
|
|
|
|
$self->{errorstring}='No file specified'; |
|
672
|
0
|
|
|
|
|
|
$self->warn; |
|
673
|
0
|
|
|
|
|
|
return undef; |
|
674
|
|
|
|
|
|
|
} |
|
675
|
|
|
|
|
|
|
|
|
676
|
0
|
|
|
|
|
|
my @parts=$self->{mime}->parts; |
|
677
|
0
|
|
|
|
|
|
my @newparts; |
|
678
|
0
|
|
|
|
|
|
my $int=0; |
|
679
|
0
|
|
|
|
|
|
while ( defined( $parts[$int] ) ){ |
|
680
|
0
|
|
|
|
|
|
my $partFilename=$parts[$int]->filename; |
|
681
|
0
|
0
|
0
|
|
|
|
if ( ( ! defined( $partFilename ) ) || |
|
682
|
|
|
|
|
|
|
( $file ne $partFilename ) ){ |
|
683
|
0
|
|
|
|
|
|
push( @newparts, $parts[$int] ); |
|
684
|
|
|
|
|
|
|
} |
|
685
|
|
|
|
|
|
|
|
|
686
|
0
|
|
|
|
|
|
$int++; |
|
687
|
|
|
|
|
|
|
} |
|
688
|
|
|
|
|
|
|
|
|
689
|
0
|
|
|
|
|
|
$self->{mime}->parts_set( \@newparts ); |
|
690
|
|
|
|
|
|
|
|
|
691
|
0
|
|
|
|
|
|
return 1; |
|
692
|
|
|
|
|
|
|
} |
|
693
|
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
=head2 summaryGet |
|
695
|
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
This returns the summary. |
|
697
|
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
my $summary=$foo->summaryGet; |
|
699
|
|
|
|
|
|
|
if($foo->error){ |
|
700
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
701
|
|
|
|
|
|
|
} |
|
702
|
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
=cut |
|
704
|
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
sub summaryGet{ |
|
706
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
707
|
|
|
|
|
|
|
|
|
708
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
709
|
0
|
|
|
|
|
|
return undef; |
|
710
|
|
|
|
|
|
|
} |
|
711
|
|
|
|
|
|
|
|
|
712
|
0
|
|
|
|
|
|
my $summary=$self->{mime}->header('summary'); |
|
713
|
|
|
|
|
|
|
|
|
714
|
0
|
0
|
|
|
|
|
if ( ! defined( $summary ) ){ |
|
715
|
0
|
|
|
|
|
|
$summary=''; |
|
716
|
|
|
|
|
|
|
} |
|
717
|
|
|
|
|
|
|
|
|
718
|
0
|
|
|
|
|
|
return $summary; |
|
719
|
|
|
|
|
|
|
} |
|
720
|
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
=head2 summarySet |
|
722
|
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
This sets the summary. |
|
724
|
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
One argument is taken and it is the summary. |
|
726
|
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
$foo->summarySet($summary); |
|
728
|
|
|
|
|
|
|
if($foo->error){ |
|
729
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
730
|
|
|
|
|
|
|
} |
|
731
|
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=cut |
|
733
|
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
sub summarySet{ |
|
735
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
736
|
0
|
|
|
|
|
|
my $summary=$_[1]; |
|
737
|
|
|
|
|
|
|
|
|
738
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
739
|
0
|
|
|
|
|
|
return undef; |
|
740
|
|
|
|
|
|
|
} |
|
741
|
|
|
|
|
|
|
|
|
742
|
0
|
0
|
|
|
|
|
if (!defined( $summary )) { |
|
743
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
744
|
0
|
|
|
|
|
|
$self->{errorString}='No summary specified'; |
|
745
|
0
|
|
|
|
|
|
$self->warn; |
|
746
|
0
|
|
|
|
|
|
return $self; |
|
747
|
|
|
|
|
|
|
} |
|
748
|
|
|
|
|
|
|
|
|
749
|
0
|
|
|
|
|
|
$self->{mime}->header_set('summary'=>$summary); |
|
750
|
|
|
|
|
|
|
|
|
751
|
0
|
|
|
|
|
|
return 1; |
|
752
|
|
|
|
|
|
|
} |
|
753
|
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
=head2 write |
|
755
|
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
This saves the page file. It requires dirSet to |
|
757
|
|
|
|
|
|
|
have been called previously. |
|
758
|
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
$foo->write; |
|
760
|
|
|
|
|
|
|
if($foo->error){ |
|
761
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
762
|
|
|
|
|
|
|
} |
|
763
|
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
=cut |
|
765
|
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
sub write{ |
|
767
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
768
|
|
|
|
|
|
|
|
|
769
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
770
|
0
|
|
|
|
|
|
return undef; |
|
771
|
|
|
|
|
|
|
} |
|
772
|
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
#makes so a directory has been specified |
|
774
|
0
|
0
|
|
|
|
|
if (!defined( $self->{dir} )) { |
|
775
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
776
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been specified yet'; |
|
777
|
0
|
|
|
|
|
|
$self->warn; |
|
778
|
0
|
|
|
|
|
|
return undef; |
|
779
|
|
|
|
|
|
|
} |
|
780
|
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
#makes sure it is still a toader directory... |
|
782
|
0
|
0
|
|
|
|
|
if (! -d $self->{dir}.'/.toader/' ) { |
|
783
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
784
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been specified yet'; |
|
785
|
0
|
|
|
|
|
|
return undef; |
|
786
|
|
|
|
|
|
|
} |
|
787
|
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
#figure out the file will be |
|
789
|
0
|
|
|
|
|
|
my $file=$self->{dir}.'/.toader/index'; |
|
790
|
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
#converts the page to a string |
|
792
|
0
|
|
|
|
|
|
my $pageString=$self->as_string; |
|
793
|
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
#writes the file |
|
795
|
0
|
|
|
|
|
|
my $fh; |
|
796
|
0
|
0
|
|
|
|
|
if ( ! open($fh, '>', $file) ){ |
|
797
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
798
|
0
|
|
|
|
|
|
$self->{errorString}='Unable to open "'.$file.'" for writing'; |
|
799
|
0
|
|
|
|
|
|
$self->warn; |
|
800
|
0
|
|
|
|
|
|
return undef; |
|
801
|
|
|
|
|
|
|
} |
|
802
|
0
|
|
|
|
|
|
print $fh $pageString; |
|
803
|
0
|
|
|
|
|
|
close($fh); |
|
804
|
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
#if it is under VCS, we have nothing to do |
|
806
|
0
|
|
|
|
|
|
my $underVCS=$self->{vcs}->underVCS($file); |
|
807
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
|
808
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
809
|
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->underVCS errored. error="'. |
|
810
|
0
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
|
811
|
0
|
|
|
|
|
|
$self->warn; |
|
812
|
0
|
|
|
|
|
|
return undef; |
|
813
|
|
|
|
|
|
|
} |
|
814
|
0
|
0
|
|
|
|
|
if ( $underVCS ){ |
|
815
|
0
|
|
|
|
|
|
return 1; |
|
816
|
|
|
|
|
|
|
} |
|
817
|
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
#add it as if we reach here it is not under VCS and VCS is being used |
|
819
|
0
|
|
|
|
|
|
$self->{vcs}->add( $file ); |
|
820
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
|
821
|
0
|
|
|
|
|
|
$self->{error}=13; |
|
822
|
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->add errored. error="'. |
|
823
|
0
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
|
824
|
0
|
|
|
|
|
|
$self->warn; |
|
825
|
0
|
|
|
|
|
|
return undef; |
|
826
|
|
|
|
|
|
|
} |
|
827
|
|
|
|
|
|
|
|
|
828
|
0
|
|
|
|
|
|
return 1; |
|
829
|
|
|
|
|
|
|
} |
|
830
|
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
=head1 REQUIRED RENDERING METHODS |
|
832
|
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
=head2 filesDir |
|
834
|
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
This returns the file directory for the object. |
|
836
|
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
This is not a full path, but a partial path that should |
|
838
|
|
|
|
|
|
|
be appended the directory current directory being outputted to. |
|
839
|
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
=cut |
|
841
|
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
sub filesDir{ |
|
843
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
844
|
|
|
|
|
|
|
|
|
845
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
846
|
0
|
|
|
|
|
|
return undef; |
|
847
|
|
|
|
|
|
|
} |
|
848
|
|
|
|
|
|
|
|
|
849
|
0
|
|
|
|
|
|
return $self->renderDir.'/.files' |
|
850
|
|
|
|
|
|
|
} |
|
851
|
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
=head2 locationID |
|
853
|
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
This returns the location ID. |
|
855
|
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
This one requires the object to be initialized. |
|
857
|
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
=cut |
|
859
|
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
sub locationID{ |
|
861
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
862
|
|
|
|
|
|
|
|
|
863
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
864
|
0
|
|
|
|
|
|
return undef; |
|
865
|
|
|
|
|
|
|
} |
|
866
|
|
|
|
|
|
|
|
|
867
|
0
|
|
|
|
|
|
return 'Index'; |
|
868
|
|
|
|
|
|
|
} |
|
869
|
|
|
|
|
|
|
|
|
870
|
|
|
|
|
|
|
=head2 renderDir |
|
871
|
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
This is the directory that it will be rendered to. |
|
873
|
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
The base directory that will be used for rendering. |
|
875
|
|
|
|
|
|
|
|
|
876
|
|
|
|
|
|
|
=cut |
|
877
|
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
sub renderDir{ |
|
879
|
0
|
|
|
0
|
1
|
|
return '' |
|
880
|
|
|
|
|
|
|
} |
|
881
|
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
=head2 renderUsing |
|
883
|
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
This returns the module to use for rendering. |
|
885
|
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
my $module=$foo->renderUsing; |
|
887
|
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
=cut |
|
889
|
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
sub renderUsing{ |
|
891
|
0
|
|
|
0
|
1
|
|
return 'Toader::Render::Directory'; |
|
892
|
|
|
|
|
|
|
} |
|
893
|
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
=head2 toaderRenderable |
|
895
|
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
This method returns true and marks it as being Toader |
|
897
|
|
|
|
|
|
|
renderable. |
|
898
|
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
=cut |
|
900
|
|
|
|
|
|
|
|
|
901
|
|
|
|
|
|
|
sub toaderRenderable{ |
|
902
|
0
|
|
|
0
|
1
|
|
return 1; |
|
903
|
|
|
|
|
|
|
} |
|
904
|
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
=head2 toDir |
|
906
|
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
This returns the path to the object. |
|
908
|
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
This is not a full path, but a partial path that should |
|
910
|
|
|
|
|
|
|
be appended the directory current directory being outputted to. |
|
911
|
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
=cut |
|
913
|
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
sub toDir{ |
|
915
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
916
|
|
|
|
|
|
|
|
|
917
|
0
|
0
|
|
|
|
|
if (!$self->errorblank){ |
|
918
|
0
|
|
|
|
|
|
return undef; |
|
919
|
|
|
|
|
|
|
} |
|
920
|
|
|
|
|
|
|
|
|
921
|
0
|
|
|
|
|
|
return $self->renderDir; |
|
922
|
|
|
|
|
|
|
} |
|
923
|
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
=head1 ERROR CODES |
|
925
|
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
=head2 1, openIndexFailed |
|
927
|
|
|
|
|
|
|
|
|
928
|
|
|
|
|
|
|
Unable to open the index file for the specified directory. |
|
929
|
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
=head2 2, notAtoaderDir |
|
931
|
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
The specified directory is not a L directory. |
|
933
|
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
=head2 3, noTitleSpecified |
|
935
|
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
No title specified. |
|
937
|
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
=head2 4, noDirSet |
|
939
|
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
No directory has been specified yet. |
|
941
|
|
|
|
|
|
|
|
|
942
|
|
|
|
|
|
|
=head2 5, noLongerAtoaderDir |
|
943
|
|
|
|
|
|
|
|
|
944
|
|
|
|
|
|
|
The directory is no longer a L directory. |
|
945
|
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
=head2 6, indexOpenForWritingFailed |
|
947
|
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
Failed to open the file for writing. |
|
949
|
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
=head2 7, openDirFailed |
|
951
|
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
Failed to open the directory. |
|
953
|
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
=head2 8, noSummarySpecified |
|
955
|
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
No summary specified. |
|
957
|
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
=head2 9, notAtoaderObj |
|
959
|
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
The specified objected is not a L object. |
|
961
|
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
=head2 10, getVCSerrored |
|
963
|
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
L->getVCS errored. |
|
965
|
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
=head2 11, VCSusableErrored |
|
967
|
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
L->usable errored. |
|
969
|
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
=head2 12, underVCSerrored |
|
971
|
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
L->underVCS errored. |
|
973
|
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
=head2 13, VCSaddErrored |
|
975
|
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
L->add errored. |
|
977
|
|
|
|
|
|
|
|
|
978
|
|
|
|
|
|
|
=head2 14, noToaderObj |
|
979
|
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
No L object specified. |
|
981
|
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
=head1 AUTHOR |
|
983
|
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
|
985
|
|
|
|
|
|
|
|
|
986
|
|
|
|
|
|
|
=head1 BUGS |
|
987
|
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
989
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
990
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
991
|
|
|
|
|
|
|
|
|
992
|
|
|
|
|
|
|
=head1 SUPPORT |
|
993
|
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
995
|
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
perldoc Toader::Directory |
|
997
|
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
|
|
999
|
|
|
|
|
|
|
You can also look for information at: |
|
1000
|
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
=over 4 |
|
1002
|
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
1004
|
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
L |
|
1006
|
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
1008
|
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
L |
|
1010
|
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
1012
|
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
L |
|
1014
|
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
=item * Search CPAN |
|
1016
|
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
L |
|
1018
|
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
=back |
|
1020
|
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
1023
|
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
1026
|
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
Copyright 2013 Zane C. Bowers-Hadley |
|
1028
|
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
1030
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
1031
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
1032
|
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
1034
|
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
|
|
1036
|
|
|
|
|
|
|
=cut |
|
1037
|
|
|
|
|
|
|
|
|
1038
|
|
|
|
|
|
|
1; # End of Toader |