| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Toader::Entry::Manage; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
23370
|
use warnings; |
|
|
7
|
|
|
|
|
17
|
|
|
|
7
|
|
|
|
|
213
|
|
|
4
|
7
|
|
|
7
|
|
39
|
use strict; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
218
|
|
|
5
|
7
|
|
|
7
|
|
534
|
use Toader::isaToaderDir; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
185
|
|
|
6
|
7
|
|
|
7
|
|
649
|
use Toader::Entry::Helper; |
|
|
7
|
|
|
|
|
22
|
|
|
|
7
|
|
|
|
|
219
|
|
|
7
|
7
|
|
|
7
|
|
3211
|
use Toader::Entry; |
|
|
7
|
|
|
|
|
20
|
|
|
|
7
|
|
|
|
|
231
|
|
|
8
|
7
|
|
|
7
|
|
64
|
use base 'Error::Helper'; |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
18138
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Toader::Entry::Manage - Manage entries. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 1.0.0 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 METHODS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 new |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This initiates the object. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
One argument is required and it is a L object. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
After calling this, you should call setDir to set the directory to use. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $foo = Toader::New->new( $toader ); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new{ |
|
37
|
0
|
|
|
0
|
1
|
|
my $toader=$_[1]; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $self={ |
|
40
|
|
|
|
|
|
|
error=>undef, |
|
41
|
|
|
|
|
|
|
errorString=>'', |
|
42
|
|
|
|
|
|
|
dir=>undef, |
|
43
|
|
|
|
|
|
|
edir=>undef, |
|
44
|
|
|
|
|
|
|
isatd=>Toader::isaToaderDir->new, |
|
45
|
|
|
|
|
|
|
helper=>undef, |
|
46
|
|
|
|
|
|
|
VCSusable=>0, |
|
47
|
|
|
|
|
|
|
toader=>undef, |
|
48
|
|
|
|
|
|
|
errorExtra=>{ |
|
49
|
|
|
|
|
|
|
flags=>{ |
|
50
|
|
|
|
|
|
|
1=>'noDirSpecified', |
|
51
|
|
|
|
|
|
|
2=>'isaToaderDirErrored', |
|
52
|
|
|
|
|
|
|
3=>'notAtoaderDir', |
|
53
|
|
|
|
|
|
|
4=>'noDirDefined', |
|
54
|
|
|
|
|
|
|
5=>'openDirFailed', |
|
55
|
|
|
|
|
|
|
6=>'noEntrySpecified', |
|
56
|
|
|
|
|
|
|
7=>'invalidEntryName', |
|
57
|
|
|
|
|
|
|
8=>'entryDoesNotExist', |
|
58
|
|
|
|
|
|
|
9=>'unlinkFailed', |
|
59
|
|
|
|
|
|
|
10=>'openEntryFailed', |
|
60
|
|
|
|
|
|
|
11=>'entryObjCreationFailed', |
|
61
|
|
|
|
|
|
|
12=>'notAtoaderObj', |
|
62
|
|
|
|
|
|
|
13=>'getVCSerrored', |
|
63
|
|
|
|
|
|
|
14=>'VCSusableErrored', |
|
64
|
|
|
|
|
|
|
15=>'underVCSerrored', |
|
65
|
|
|
|
|
|
|
16=>'VCSdeleteErrored', |
|
66
|
|
|
|
|
|
|
17=>'noToaderObj', |
|
67
|
|
|
|
|
|
|
18=>'helperNewErrored', |
|
68
|
|
|
|
|
|
|
}, |
|
69
|
|
|
|
|
|
|
}, |
|
70
|
|
|
|
|
|
|
}; |
|
71
|
0
|
|
|
|
|
|
bless $self; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#if we have a Toader object, reel it in |
|
74
|
0
|
0
|
|
|
|
|
if ( ! defined( $toader ) ){ |
|
75
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
76
|
0
|
|
|
|
|
|
$self->{error}=17; |
|
77
|
0
|
|
|
|
|
|
$self->{errorString}='No Toader object specified'; |
|
78
|
0
|
|
|
|
|
|
$self->warn; |
|
79
|
0
|
|
|
|
|
|
return $self; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
0
|
0
|
|
|
|
|
if ( ref( $toader ) ne "Toader" ){ |
|
82
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
83
|
0
|
|
|
|
|
|
$self->{error}=12; |
|
84
|
0
|
|
|
|
|
|
$self->{errorString}='The object specified is a "'.ref($toader).'"'; |
|
85
|
0
|
|
|
|
|
|
$self->warn; |
|
86
|
0
|
|
|
|
|
|
return $self; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
0
|
|
|
|
|
|
$self->{toader}=$toader; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#init the helper |
|
91
|
0
|
|
|
|
|
|
$self->{helper}=Toader::Entry::Helper->new( $self->{toader} ); |
|
92
|
0
|
0
|
|
|
|
|
if ( $self->{helper}->error ){ |
|
93
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
94
|
0
|
|
|
|
|
|
$self->{error}=18; |
|
95
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to initialize Toader::Page::Helper.'. |
|
96
|
|
|
|
|
|
|
'error="'.$self->{helper}->error.'" errorString="'.$self->{helper}->errorString.'"'; |
|
97
|
0
|
|
|
|
|
|
$self->warn; |
|
98
|
0
|
|
|
|
|
|
return $self; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#gets the Toader::VCS object |
|
103
|
0
|
|
|
|
|
|
$self->{vcs}=$self->{toader}->getVCS; |
|
104
|
0
|
0
|
|
|
|
|
if ( $toader->error ){ |
|
105
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
106
|
0
|
|
|
|
|
|
$self->{error}=13; |
|
107
|
0
|
|
|
|
|
|
$self->{errorString}='Toader->getVCS errored. error="'. |
|
108
|
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
|
109
|
0
|
|
|
|
|
|
$self->warn; |
|
110
|
0
|
|
|
|
|
|
return $self; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#checks if VCS is usable |
|
114
|
0
|
|
|
|
|
|
$self->{VCSusable}=$self->{vcs}->usable; |
|
115
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
|
116
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
117
|
0
|
|
|
|
|
|
$self->{error}=14; |
|
118
|
0
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->usable errored. error="'. |
|
119
|
|
|
|
|
|
|
$self->{toader}->error.'" errorString="'.$self->{toader}->errorString.'"'; |
|
120
|
0
|
|
|
|
|
|
$self->warn; |
|
121
|
0
|
|
|
|
|
|
return $self; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
return $self; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 list |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This lists the available entries. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my @entries=$foo->list; |
|
132
|
|
|
|
|
|
|
if($foo->error){ |
|
133
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub list{ |
|
139
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
#blank any previous errors |
|
142
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
143
|
0
|
|
|
|
|
|
return undef; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
#make sure a directory has been set |
|
147
|
0
|
0
|
|
|
|
|
if (!defined($self->{dir})) { |
|
148
|
0
|
|
|
|
|
|
$self->{error}='4'; |
|
149
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been set yet'; |
|
150
|
0
|
|
|
|
|
|
$self->warn; |
|
151
|
0
|
|
|
|
|
|
return undef; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#this will be returned |
|
155
|
0
|
|
|
|
|
|
my @entries; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
#makes sure we have a entry directory |
|
158
|
0
|
0
|
|
|
|
|
if (!-d $self->{edir}) { |
|
159
|
0
|
|
|
|
|
|
return @entries; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
#read what is present in the directory |
|
163
|
0
|
|
|
|
|
|
my $dh; |
|
164
|
0
|
0
|
|
|
|
|
if (!opendir($dh, $self->{edir})) { |
|
165
|
0
|
|
|
|
|
|
$self->{error}='5'; |
|
166
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to open the directory "'.$self->{dir}.'"'; |
|
167
|
0
|
|
|
|
|
|
$self->warn; |
|
168
|
0
|
|
|
|
|
|
return undef; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
0
|
0
|
|
|
|
|
@entries=grep( { -f $self->{edir}.'/'.$_ && /$self->{helper}->{regex}/ } readdir($dh) ); |
|
|
0
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
close($dh); |
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
return @entries; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 published |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This returns a list of published or unpublished entries. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
One argument is accepted and that is the return value from |
|
181
|
|
|
|
|
|
|
Toader::Entry->publishGet. If that is not defined, then '1' |
|
182
|
|
|
|
|
|
|
is used. |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This will throw a warning for entries that can not be read, |
|
185
|
|
|
|
|
|
|
it will not throw a error. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
my @published=$foo->published; |
|
188
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
189
|
|
|
|
|
|
|
warn( 'Error:'.$foo->error.': '.$foo->errorStrin ); |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub published{ |
|
195
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
196
|
0
|
|
|
|
|
|
my $bool=$_[1]; |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
#blank any previous errors |
|
199
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
200
|
0
|
|
|
|
|
|
return undef; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
#set the default |
|
204
|
0
|
0
|
|
|
|
|
if ( ! defined( $bool ) ){ |
|
205
|
0
|
|
|
|
|
|
$bool='1'; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
#make sure the boolean is definitely zero or one |
|
209
|
0
|
0
|
|
|
|
|
if ( $bool ){ |
|
210
|
0
|
|
|
|
|
|
$bool='1'; |
|
211
|
|
|
|
|
|
|
}else{ |
|
212
|
0
|
|
|
|
|
|
$bool='0'; |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
my @entries=$self->list; |
|
216
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
217
|
0
|
|
|
|
|
|
$self->warnString('Failed to list the entries'); |
|
218
|
0
|
|
|
|
|
|
return undef; |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
#checks for them all |
|
222
|
0
|
|
|
|
|
|
my @published; |
|
223
|
0
|
|
|
|
|
|
my $int=0; |
|
224
|
0
|
|
|
|
|
|
while ( defined( $entries[$int] ) ){ |
|
225
|
0
|
|
|
|
|
|
my $entry=$self->read( $entries[$int] ); |
|
226
|
|
|
|
|
|
|
|
|
227
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
228
|
0
|
|
|
|
|
|
$self->warnString('Failed to read entry "'.$entries[$int].'"'); |
|
229
|
|
|
|
|
|
|
}else{ |
|
230
|
0
|
|
|
|
|
|
my $ispublished=$entry->publishGet; |
|
231
|
0
|
0
|
|
|
|
|
if ( $ispublished eq $bool ){ |
|
232
|
0
|
|
|
|
|
|
push( @published, $entries[$int] ); |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
|
|
236
|
0
|
|
|
|
|
|
$int++; |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
return @published; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head2 read |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This reads a entry. |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
One argument is taken and that is the entry name. |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
my $entry=$foo->read( $entryName ); |
|
249
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
250
|
|
|
|
|
|
|
warn( 'Error:'.$foo->error.': '.$foo->errorStrin ); |
|
251
|
|
|
|
|
|
|
} |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=cut |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub read{ |
|
256
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
257
|
0
|
|
|
|
|
|
my $entry=$_[1]; |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
#blank any previous errors |
|
260
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
261
|
0
|
|
|
|
|
|
return undef; |
|
262
|
|
|
|
|
|
|
} |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
#make sure a directory has been set |
|
265
|
0
|
0
|
|
|
|
|
if (!defined($self->{dir})) { |
|
266
|
0
|
|
|
|
|
|
$self->{error}='4'; |
|
267
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been set yet'; |
|
268
|
0
|
|
|
|
|
|
$self->warn; |
|
269
|
0
|
|
|
|
|
|
return undef; |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
#make sure it is valid and exists |
|
273
|
0
|
|
|
|
|
|
my $returned=$self->{helper}->entryExists($entry); |
|
274
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
275
|
0
|
0
|
|
|
|
|
if ($self->{helper}->error){ |
|
276
|
0
|
|
|
|
|
|
$self->{error}=7; |
|
277
|
0
|
|
|
|
|
|
$self->{errorString}='The entry name is not valid'; |
|
278
|
|
|
|
|
|
|
}else { |
|
279
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
280
|
0
|
|
|
|
|
|
$self->{errorString}='The entry does not exist'; |
|
281
|
|
|
|
|
|
|
} |
|
282
|
0
|
|
|
|
|
|
$self->warn; |
|
283
|
0
|
|
|
|
|
|
return undef; |
|
284
|
|
|
|
|
|
|
} |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
#the file that will be read |
|
287
|
0
|
|
|
|
|
|
my $file=$self->{dir}.'/.toader/entries/'.$entry; |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
#reads it |
|
290
|
0
|
|
|
|
|
|
my $entryString; |
|
291
|
|
|
|
|
|
|
my $fh; |
|
292
|
0
|
0
|
|
|
|
|
if ( ! open($fh, '<', $file) ){ |
|
293
|
0
|
|
|
|
|
|
$self->{error}=10; |
|
294
|
0
|
|
|
|
|
|
$self->{errorString}='Unable to open "'.$file.'" for writing'; |
|
295
|
0
|
|
|
|
|
|
$self->warn; |
|
296
|
0
|
|
|
|
|
|
return undef; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
0
|
|
|
|
|
|
$entryString=join("", <$fh>); |
|
299
|
0
|
|
|
|
|
|
close($fh); |
|
300
|
|
|
|
|
|
|
|
|
301
|
0
|
|
|
|
|
|
my $entryObj=Toader::Entry->newFromString($entryString, $self->{toader}); |
|
302
|
0
|
0
|
|
|
|
|
if ($entryObj->error) { |
|
303
|
0
|
|
|
|
|
|
$self->{error}=11; |
|
304
|
0
|
|
|
|
|
|
$self->{errorString}='Unable to generate a Toader::Entry object from '; |
|
305
|
0
|
|
|
|
|
|
$self->warn; |
|
306
|
0
|
|
|
|
|
|
return undef; |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
#sets the directory |
|
310
|
0
|
|
|
|
|
|
$entryObj->dirSet($self->{dir}); |
|
311
|
0
|
|
|
|
|
|
$entryObj->entryNameSet($entry); |
|
312
|
|
|
|
|
|
|
|
|
313
|
0
|
|
|
|
|
|
return $entryObj; |
|
314
|
|
|
|
|
|
|
} |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=head2 remove |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
This removes a entry. |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
One argument is required and it is entry name. |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
$foo->remove($entry); |
|
323
|
|
|
|
|
|
|
if($foo->error){ |
|
324
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
325
|
|
|
|
|
|
|
} |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=cut |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
sub remove{ |
|
330
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
331
|
0
|
|
|
|
|
|
my $entry=$_[1]; |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
#blank any previous errors |
|
334
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
335
|
0
|
|
|
|
|
|
return undef; |
|
336
|
|
|
|
|
|
|
} |
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
#makes sure a entry is specified |
|
339
|
0
|
0
|
|
|
|
|
if (!defined($entry)) { |
|
340
|
0
|
|
|
|
|
|
$self->{error}='6'; |
|
341
|
0
|
|
|
|
|
|
$self->{errorString}='No entry specified'; |
|
342
|
0
|
|
|
|
|
|
$self->warn; |
|
343
|
0
|
|
|
|
|
|
return undef; |
|
344
|
|
|
|
|
|
|
} |
|
345
|
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
#make sure a directory has been set |
|
347
|
0
|
0
|
|
|
|
|
if (!defined($self->{dir})) { |
|
348
|
0
|
|
|
|
|
|
$self->{error}='4'; |
|
349
|
0
|
|
|
|
|
|
$self->{errorString}='No directory has been set yet'; |
|
350
|
0
|
|
|
|
|
|
$self->warn; |
|
351
|
0
|
|
|
|
|
|
return undef; |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
#make sure it is valid and exists |
|
355
|
0
|
|
|
|
|
|
my $returned=$self->{helper}->entryExists($entry); |
|
356
|
0
|
0
|
|
|
|
|
if (!$returned) { |
|
357
|
0
|
0
|
|
|
|
|
if ($self->{helper}->error){ |
|
358
|
0
|
|
|
|
|
|
$self->{error}=7; |
|
359
|
0
|
|
|
|
|
|
$self->{errorString}='The entry name is not valid'; |
|
360
|
|
|
|
|
|
|
}else { |
|
361
|
0
|
|
|
|
|
|
$self->{error}=8; |
|
362
|
0
|
|
|
|
|
|
$self->{errorString}='The entry does not exist'; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
0
|
|
|
|
|
|
$self->warn; |
|
365
|
0
|
|
|
|
|
|
return undef; |
|
366
|
|
|
|
|
|
|
} |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
#saves this for later |
|
369
|
0
|
|
|
|
|
|
my $file=$self->{edir}.'/'.$entry; |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
#unlinks it |
|
372
|
0
|
0
|
|
|
|
|
if (!unlink( $file )) { |
|
373
|
0
|
|
|
|
|
|
$self->{error}=9; |
|
374
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to unlink the entry'; |
|
375
|
0
|
|
|
|
|
|
$self->warn; |
|
376
|
0
|
|
|
|
|
|
return undef; |
|
377
|
|
|
|
|
|
|
} |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
#if VCS is not usable, return here |
|
380
|
0
|
0
|
|
|
|
|
if ( ! $self->{VCSusable} ){ |
|
381
|
0
|
|
|
|
|
|
return 1; |
|
382
|
|
|
|
|
|
|
} |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
#if it is not under VCS, we have nothing to do |
|
385
|
0
|
|
|
|
|
|
my $underVCS=$self->{vcs}->underVCS($file); |
|
386
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
|
387
|
0
|
|
|
|
|
|
$self->{error}=15; |
|
388
|
0
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->underVCS errored. error="'. |
|
389
|
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
|
390
|
0
|
|
|
|
|
|
$self->warn; |
|
391
|
0
|
|
|
|
|
|
return undef; |
|
392
|
|
|
|
|
|
|
} |
|
393
|
0
|
0
|
|
|
|
|
if ( $underVCS ){ |
|
394
|
0
|
|
|
|
|
|
return 1; |
|
395
|
|
|
|
|
|
|
} |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
#delete it as if we reach here it is not under VCS and VCS is being used |
|
398
|
0
|
|
|
|
|
|
$self->{vcs}->delete( $file ); |
|
399
|
0
|
0
|
|
|
|
|
if ( $self->{vcs}->error ){ |
|
400
|
0
|
|
|
|
|
|
$self->{error}=16; |
|
401
|
0
|
|
|
|
|
|
$self->{errorString}='Toader::VCS->delete errored. error="'. |
|
402
|
|
|
|
|
|
|
$self->{vcs}->error.'" errorString="'.$self->{vcs}->errorString.'"'; |
|
403
|
0
|
|
|
|
|
|
$self->warn; |
|
404
|
0
|
|
|
|
|
|
return undef; |
|
405
|
|
|
|
|
|
|
} |
|
406
|
|
|
|
|
|
|
|
|
407
|
0
|
|
|
|
|
|
return 1; |
|
408
|
|
|
|
|
|
|
} |
|
409
|
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
=head2 setDir |
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
This sets the directory the module will work on. |
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
One argument is taken and that is the path for the L directory |
|
415
|
|
|
|
|
|
|
in question. |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
$foo->setDir($toaderDirectory) |
|
418
|
|
|
|
|
|
|
if($foo->error){ |
|
419
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
420
|
|
|
|
|
|
|
} |
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=cut |
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
sub setDir{ |
|
425
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
426
|
0
|
|
|
|
|
|
my $directory=$_[1]; |
|
427
|
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
#blank any previous errors |
|
429
|
0
|
0
|
|
|
|
|
if (!$self->errorblank) { |
|
430
|
0
|
|
|
|
|
|
return undef; |
|
431
|
|
|
|
|
|
|
} |
|
432
|
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
#makes sure a directory is specified |
|
434
|
0
|
0
|
|
|
|
|
if (!defined($directory)) { |
|
435
|
0
|
|
|
|
|
|
$self->{error}='1'; |
|
436
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
437
|
0
|
|
|
|
|
|
$self->warn; |
|
438
|
0
|
|
|
|
|
|
return undef; |
|
439
|
|
|
|
|
|
|
} |
|
440
|
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
#cleans up the naming |
|
442
|
0
|
|
|
|
|
|
my $pathHelper=Toader::pathHelper->new( $directory ); |
|
443
|
0
|
|
|
|
|
|
$directory=$pathHelper->cleanup( $directory ); |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
#makes sure it is a directory |
|
447
|
0
|
|
|
|
|
|
my $returned=$self->{isatd}->isaToaderDir($directory); |
|
448
|
0
|
0
|
|
|
|
|
if(!$returned){ |
|
449
|
0
|
0
|
|
|
|
|
if($self->{isatd}->error){ |
|
450
|
0
|
|
|
|
|
|
$self->{error}='2'; |
|
451
|
0
|
|
|
|
|
|
$self->{errorString}='isaToaderDir errored. error="'.$self->{isatd}->error.'" errorString="'.$self->{isatd}->errorString.'"'; |
|
452
|
0
|
|
|
|
|
|
$self->warn; |
|
453
|
0
|
|
|
|
|
|
return undef; |
|
454
|
|
|
|
|
|
|
} |
|
455
|
0
|
|
|
|
|
|
$self->{error}='3'; |
|
456
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$directory.'" is not a Toader directory'; |
|
457
|
0
|
|
|
|
|
|
$self->warn; |
|
458
|
0
|
|
|
|
|
|
return undef; |
|
459
|
|
|
|
|
|
|
} |
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
#it has been verified, so set it |
|
462
|
0
|
|
|
|
|
|
$self->{dir}=$directory; |
|
463
|
0
|
|
|
|
|
|
$self->{helper}->setDir($directory); #if the previous check has been worked, then this well |
|
464
|
0
|
|
|
|
|
|
$self->{edir}=$self->{helper}->entryDirectory; |
|
465
|
|
|
|
|
|
|
|
|
466
|
0
|
|
|
|
|
|
return 1; |
|
467
|
|
|
|
|
|
|
} |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
=head1 ERROR CODES |
|
470
|
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=head2 1, noDirSpecified |
|
472
|
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
No directory specified. |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=head2 2, isaToaderDirErrored |
|
476
|
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
isaToaderDir errored. |
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=head2 3, notAtoaderDir |
|
480
|
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
Is not a L directory. |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
=head2 4, noDirDefined |
|
484
|
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
No directory has been defined. |
|
486
|
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=head2 5, openDirFailed |
|
488
|
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
Failed to open the directory. |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=head2 6, noEntrySpecified |
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
No entry specified. |
|
494
|
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
=head2 7, invalidEntryName |
|
496
|
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
The entry is not a valid name. |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
=head2 8, entryDoesNotExist |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
The entry does not exist. |
|
502
|
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
=head2 9, unlinkFailed |
|
504
|
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
Failed to unlink the entry. |
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=head2 10, openEntryFailed |
|
508
|
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
Unable to open the entry file for reading. |
|
510
|
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
=head2 11, entryObjCreationFailed |
|
512
|
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
Generating a L object from a alredy existing entry failed. |
|
514
|
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=head2 12, notAtoaderObj |
|
516
|
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
The object specified is not a L object. |
|
518
|
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=head2 13, getVCSerrored |
|
520
|
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
L->getVCS errored. |
|
522
|
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
=head2 14, VCSusableErrored |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
L->usable errored. |
|
526
|
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=head2 15, underVCSerrored |
|
528
|
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
L->underVCS errored. |
|
530
|
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=head2 16, VCSdeleteErrored |
|
532
|
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
L->delete errored. |
|
534
|
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=head2 17, noToaderObj |
|
536
|
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
No L object specified. |
|
538
|
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=head2 18, helperNewErrored |
|
540
|
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
L->new errored. |
|
542
|
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=head1 AUTHOR |
|
544
|
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
|
546
|
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
=head1 BUGS |
|
549
|
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
551
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
552
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
553
|
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=head1 SUPPORT |
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
560
|
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
perldoc Toader::Entry::Manage |
|
562
|
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
You can also look for information at: |
|
565
|
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=over 4 |
|
567
|
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
569
|
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
L |
|
571
|
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
573
|
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
L |
|
575
|
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
577
|
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
L |
|
579
|
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
=item * Search CPAN |
|
581
|
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
L |
|
583
|
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
=back |
|
585
|
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
588
|
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
591
|
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
Copyright 2013 Zane C. Bowers-Hadley. |
|
593
|
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
595
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
596
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
597
|
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
599
|
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
=cut |
|
602
|
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
1; # End of Toader |