| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Toader::pathHelper; |
|
2
|
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
23817
|
use warnings; |
|
|
16
|
|
|
|
|
29
|
|
|
|
16
|
|
|
|
|
474
|
|
|
4
|
16
|
|
|
16
|
|
90
|
use strict; |
|
|
16
|
|
|
|
|
34
|
|
|
|
16
|
|
|
|
|
358
|
|
|
5
|
16
|
|
|
16
|
|
75
|
use base 'Error::Helper'; |
|
|
16
|
|
|
|
|
26
|
|
|
|
16
|
|
|
|
|
1820
|
|
|
6
|
16
|
|
|
16
|
|
3292
|
use Toader::isaToaderDir; |
|
|
16
|
|
|
|
|
65
|
|
|
|
16
|
|
|
|
|
345
|
|
|
7
|
16
|
|
|
16
|
|
85
|
use File::Spec; |
|
|
16
|
|
|
|
|
25
|
|
|
|
16
|
|
|
|
|
367
|
|
|
8
|
16
|
|
|
16
|
|
7528
|
use Toader::findToaderRoot; |
|
|
16
|
|
|
|
|
40
|
|
|
|
16
|
|
|
|
|
413
|
|
|
9
|
16
|
|
|
16
|
|
212
|
use Cwd 'abs_path'; |
|
|
16
|
|
|
|
|
31
|
|
|
|
16
|
|
|
|
|
23847
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Toader::pathHelper - Various path related helpers. |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.1.0 |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Toader::pathHelper; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $foo = Toader::pathHelper->new; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 new |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
This initiates the object. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
One argument is taken. That is the a L directory. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $foo=Toader::pathHelper->new($toaderDir); |
|
38
|
|
|
|
|
|
|
if($foo->error){ |
|
39
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new{ |
|
45
|
0
|
|
|
0
|
1
|
|
my $dir=$_[1]; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $self={ |
|
48
|
|
|
|
|
|
|
error=>undef, |
|
49
|
|
|
|
|
|
|
errorString=>'', |
|
50
|
|
|
|
|
|
|
isatd=>Toader::isaToaderDir->new, |
|
51
|
|
|
|
|
|
|
perror=>undef, |
|
52
|
|
|
|
|
|
|
errorExtra=>{ |
|
53
|
|
|
|
|
|
|
flags=>{ |
|
54
|
|
|
|
|
|
|
1=>'noDirSpecified', |
|
55
|
|
|
|
|
|
|
2=>'notAtoaderDir', |
|
56
|
|
|
|
|
|
|
3=>'otherToaderDir', |
|
57
|
|
|
|
|
|
|
4=>'notAbleToFindRoot', |
|
58
|
|
|
|
|
|
|
5=>'notUnderToaderRoot', |
|
59
|
|
|
|
|
|
|
}, |
|
60
|
|
|
|
|
|
|
}, |
|
61
|
|
|
|
|
|
|
}; |
|
62
|
0
|
|
|
|
|
|
bless $self; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#make sure a directory has been specified |
|
65
|
0
|
0
|
|
|
|
|
if (!defined($dir)) { |
|
66
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
67
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
68
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
69
|
0
|
|
|
|
|
|
$self->warn; |
|
70
|
0
|
|
|
|
|
|
return undef; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $returned=$self->{isatd}->isaToaderDir($dir); |
|
74
|
0
|
0
|
|
|
|
|
if (! $returned ) { |
|
75
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
76
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not a Toader directory'; |
|
77
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
78
|
0
|
|
|
|
|
|
$self->warn; |
|
79
|
0
|
|
|
|
|
|
return undef; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#finds the root |
|
83
|
0
|
|
|
|
|
|
my $findroot = Toader::findToaderRoot->new; |
|
84
|
0
|
|
|
|
|
|
my $root=$findroot->findToaderRoot($dir); |
|
85
|
0
|
0
|
|
|
|
|
if($findroot->error){ |
|
86
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
87
|
0
|
|
|
|
|
|
$self->{errorString}='Could not find the root for "'.$dir.'" '. |
|
88
|
|
|
|
|
|
|
'error="'.$findroot->error.'" '. |
|
89
|
|
|
|
|
|
|
'errorString="'.$findroot->errorString.'"'; |
|
90
|
0
|
|
|
|
|
|
$self->warn; |
|
91
|
0
|
|
|
|
|
|
return undef; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
0
|
|
|
|
|
|
$self->cleanup($root); |
|
94
|
0
|
|
|
|
|
|
$self->{root}=$root; |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return $self; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 atRoot |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This checks if a directory is the root or not. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub atRoot{ |
|
106
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
107
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
|
if( ! $self->errorblank ){ |
|
110
|
0
|
|
|
|
|
|
return undef; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#make sure a directory has been specified |
|
114
|
0
|
0
|
|
|
|
|
if ( ! defined( $dir ) ) { |
|
115
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
116
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
117
|
0
|
|
|
|
|
|
$self->warn; |
|
118
|
0
|
|
|
|
|
|
return undef; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#cleans up the directory |
|
122
|
0
|
|
|
|
|
|
$dir=$self->cleanup($dir); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
#check if it is the same |
|
125
|
0
|
0
|
|
|
|
|
if ( $self->{root} eq $dir ){ |
|
126
|
0
|
|
|
|
|
|
return 1; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return 0; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 back2root |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This returns relative path from specified directory, |
|
135
|
|
|
|
|
|
|
back to the L root directory. |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
One argument is taken and that is the Toader directory |
|
138
|
|
|
|
|
|
|
under the root L directory. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub back2root{ |
|
143
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
144
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
|
145
|
|
|
|
|
|
|
|
|
146
|
0
|
0
|
|
|
|
|
if( ! $self->errorblank ){ |
|
147
|
0
|
|
|
|
|
|
return undef; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
#make sure a directory has been specified |
|
151
|
0
|
0
|
|
|
|
|
if ( ! defined( $dir ) ) { |
|
152
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
153
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
154
|
0
|
|
|
|
|
|
$self->warn; |
|
155
|
0
|
|
|
|
|
|
return undef; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#make sure it is a Toader dir |
|
159
|
0
|
0
|
|
|
|
|
if (! $self->{isatd}->isaToaderDir($dir) ) { |
|
160
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
161
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not a Toader directory'; |
|
162
|
0
|
|
|
|
|
|
$self->warn; |
|
163
|
0
|
|
|
|
|
|
return undef; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
#makes sure they are both under the root directory |
|
167
|
0
|
0
|
|
|
|
|
if( ! $self->underRoot( $dir ) ){ |
|
168
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
169
|
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not under the root Toader directory "'. |
|
170
|
0
|
|
|
|
|
|
$self->{root}.'",'; |
|
171
|
0
|
|
|
|
|
|
return undef; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
return $self->relative( $dir, $self->{root} ); |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 cleanup |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This cleans up the path for a L directory. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
my $cleandir=$foo->cleanup($dir); |
|
182
|
|
|
|
|
|
|
if($foo->error){ |
|
183
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub cleanup{ |
|
189
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
190
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
|
191
|
|
|
|
|
|
|
|
|
192
|
0
|
0
|
|
|
|
|
if(!$self->errorblank){ |
|
193
|
0
|
|
|
|
|
|
return undef; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
#make sure a directory has been specified |
|
197
|
0
|
0
|
|
|
|
|
if (!defined($dir)) { |
|
198
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
199
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
200
|
0
|
|
|
|
|
|
$self->warn; |
|
201
|
0
|
|
|
|
|
|
return undef; |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
my $returned=$self->{isatd}->isaToaderDir($dir); |
|
205
|
0
|
0
|
|
|
|
|
if (! $returned ) { |
|
206
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
207
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not a Toader directory'; |
|
208
|
0
|
|
|
|
|
|
$self->warn; |
|
209
|
0
|
|
|
|
|
|
return undef; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
#cleanup the path |
|
213
|
0
|
|
|
|
|
|
$dir=File::Spec->canonpath( $dir ) ; |
|
214
|
0
|
|
|
|
|
|
$dir=abs_path( $dir ); |
|
215
|
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
return $dir; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 relative |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This finds the relative path between two toader directories. |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Two arguments are accepted. Both are L directories. The first |
|
224
|
|
|
|
|
|
|
one is the directory to start in and the second is the directory |
|
225
|
|
|
|
|
|
|
to end in. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
my $relativePath=$foo->relative($fromDir, $toDir); |
|
228
|
|
|
|
|
|
|
if($foo->error){ |
|
229
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=cut |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub relative{ |
|
235
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
236
|
0
|
|
|
|
|
|
my $dir0=$_[1]; |
|
237
|
0
|
|
|
|
|
|
my $dir1=$_[2]; |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
0
|
|
|
|
|
if(!$self->errorblank){ |
|
240
|
0
|
|
|
|
|
|
return undef; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
#make sure a directory has been specified |
|
244
|
0
|
0
|
0
|
|
|
|
if ( |
|
245
|
|
|
|
|
|
|
(!defined($dir0)) || |
|
246
|
|
|
|
|
|
|
(!defined($dir1)) |
|
247
|
|
|
|
|
|
|
) { |
|
248
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
249
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
250
|
0
|
|
|
|
|
|
$self->warn; |
|
251
|
0
|
|
|
|
|
|
return undef; |
|
252
|
|
|
|
|
|
|
} |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
#make sure both directories are Toader directories |
|
255
|
0
|
0
|
|
|
|
|
if (! $self->{isatd}->isaToaderDir($dir0) ) { |
|
256
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
257
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir0.'" is not a Toader directory'; |
|
258
|
0
|
|
|
|
|
|
$self->warn; |
|
259
|
0
|
|
|
|
|
|
return undef; |
|
260
|
|
|
|
|
|
|
} |
|
261
|
0
|
0
|
|
|
|
|
if (! $self->{isatd}->isaToaderDir($dir1) ) { |
|
262
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
263
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir1.'" is not a Toader directory'; |
|
264
|
0
|
|
|
|
|
|
$self->warn; |
|
265
|
0
|
|
|
|
|
|
return undef; |
|
266
|
|
|
|
|
|
|
} |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
#makes sure they are both under the root directory |
|
269
|
0
|
0
|
|
|
|
|
if( ! $self->underRoot( $dir0 ) ){ |
|
270
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
271
|
|
|
|
|
|
|
$self->{errorString}='"'.$dir0.'" is not under the root Toader directory "'. |
|
272
|
0
|
|
|
|
|
|
$self->{root}.'",'; |
|
273
|
0
|
|
|
|
|
|
return undef; |
|
274
|
|
|
|
|
|
|
} |
|
275
|
0
|
0
|
|
|
|
|
if( ! $self->underRoot( $dir1 ) ){ |
|
276
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
277
|
|
|
|
|
|
|
$self->{errorString}='"'.$dir1.'" is not under the root Toader directory "'. |
|
278
|
0
|
|
|
|
|
|
$self->{root}.'",'; |
|
279
|
0
|
|
|
|
|
|
return undef; |
|
280
|
|
|
|
|
|
|
} |
|
281
|
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
|
$dir0=$self->cleanup($dir0); |
|
283
|
0
|
|
|
|
|
|
$dir1=$self->cleanup($dir1); |
|
284
|
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
return File::Spec->abs2rel( $dir1, $dir0 ); |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=head2 relative2root |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
This returns relative path from the root L directory. |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
One argument is taken and that is the L directory |
|
293
|
|
|
|
|
|
|
under the root L directory. |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=cut |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub relative2root{ |
|
298
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
299
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
|
300
|
|
|
|
|
|
|
|
|
301
|
0
|
0
|
|
|
|
|
if( ! $self->errorblank ){ |
|
302
|
0
|
|
|
|
|
|
return undef; |
|
303
|
|
|
|
|
|
|
} |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
#make sure a directory has been specified |
|
306
|
0
|
0
|
|
|
|
|
if ( ! defined( $dir ) ) { |
|
307
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
308
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
309
|
0
|
|
|
|
|
|
$self->warn; |
|
310
|
0
|
|
|
|
|
|
return undef; |
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
#make sure it is a Toader dir |
|
314
|
0
|
0
|
|
|
|
|
if (! $self->{isatd}->isaToaderDir($dir) ) { |
|
315
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
316
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not a Toader directory'; |
|
317
|
0
|
|
|
|
|
|
$self->warn; |
|
318
|
0
|
|
|
|
|
|
return undef; |
|
319
|
|
|
|
|
|
|
} |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
#makes sure they are both under the root directory |
|
322
|
0
|
0
|
|
|
|
|
if( ! $self->underRoot( $dir ) ){ |
|
323
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
324
|
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not under the root Toader directory "'. |
|
325
|
0
|
|
|
|
|
|
$self->{root}.'",'; |
|
326
|
0
|
|
|
|
|
|
return undef; |
|
327
|
|
|
|
|
|
|
} |
|
328
|
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
|
return $self->relative( $self->{root}, $dir ); |
|
330
|
|
|
|
|
|
|
} |
|
331
|
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=head2 underRoot |
|
333
|
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
This checks if a specified L directory is under the L root |
|
335
|
|
|
|
|
|
|
directory. |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
One argument is taken and that is a directory. This directory must be a L |
|
338
|
|
|
|
|
|
|
directory. |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
The returned value is a boolean value. |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
my $return=$self->underRoot($dir); |
|
343
|
|
|
|
|
|
|
if($foo->error){ |
|
344
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=cut |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
sub underRoot{ |
|
350
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
351
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
|
352
|
|
|
|
|
|
|
|
|
353
|
0
|
0
|
|
|
|
|
if(!$self->errorblank){ |
|
354
|
0
|
|
|
|
|
|
return undef; |
|
355
|
|
|
|
|
|
|
} |
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
#make sure a directory has been specified |
|
358
|
0
|
0
|
|
|
|
|
if ( !defined($dir) ) { |
|
359
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
360
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
361
|
0
|
|
|
|
|
|
$self->warn; |
|
362
|
0
|
|
|
|
|
|
return undef; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
#make sure both directories are Toader directories |
|
366
|
0
|
|
|
|
|
|
my $returned=$self->{isatd}->isaToaderDir($dir); |
|
367
|
0
|
0
|
|
|
|
|
if (! $returned ) { |
|
368
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
369
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$dir.'" is not a Toader directory'; |
|
370
|
0
|
|
|
|
|
|
$self->warn; |
|
371
|
0
|
|
|
|
|
|
return undef; |
|
372
|
|
|
|
|
|
|
} |
|
373
|
|
|
|
|
|
|
|
|
374
|
0
|
|
|
|
|
|
return $self->underRootNT( $dir ); |
|
375
|
|
|
|
|
|
|
} |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
=head2 underRootNT |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
This checks if a specified directory is under the L root |
|
380
|
|
|
|
|
|
|
directory. Unlike underRoot, no check is done on if it is a |
|
381
|
|
|
|
|
|
|
Toader directory or not. |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
One argument is taken and that is a directory. |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
The returned value is a boolean value. |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
This does not check if it exists or not. |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
my $return=$self->underRootNT($dir); |
|
390
|
|
|
|
|
|
|
if($foo->error){ |
|
391
|
|
|
|
|
|
|
warn('Error:'.$foo->error.': '.$foo->errorString); |
|
392
|
|
|
|
|
|
|
} |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=cut |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
sub underRootNT{ |
|
397
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
398
|
0
|
|
|
|
|
|
my $dir=$_[1]; |
|
399
|
|
|
|
|
|
|
|
|
400
|
0
|
0
|
|
|
|
|
if(!$self->errorblank){ |
|
401
|
0
|
|
|
|
|
|
return undef; |
|
402
|
|
|
|
|
|
|
} |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
#make sure a directory has been specified |
|
405
|
0
|
0
|
|
|
|
|
if ( !defined($dir) ) { |
|
406
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
407
|
0
|
|
|
|
|
|
$self->{errorString}='No directory specified'; |
|
408
|
0
|
|
|
|
|
|
$self->warn; |
|
409
|
0
|
|
|
|
|
|
return undef; |
|
410
|
|
|
|
|
|
|
} |
|
411
|
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
#cleans up the directory |
|
413
|
0
|
|
|
|
|
|
$dir=$self->cleanup($dir); |
|
414
|
0
|
|
|
|
|
|
$dir=$dir.'/'; #done to make sure other things are not matched... if it is the same as the root |
|
415
|
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
#add / to the root to make sure other items are not matched and make it into a regexp |
|
417
|
0
|
|
|
|
|
|
my $root=$self->{root}.'/'; |
|
418
|
0
|
|
|
|
|
|
$root='^'.quotemeta($root); |
|
419
|
|
|
|
|
|
|
|
|
420
|
0
|
0
|
|
|
|
|
if( $dir =~ /$root/ ){ |
|
421
|
0
|
|
|
|
|
|
return 1; |
|
422
|
|
|
|
|
|
|
} |
|
423
|
|
|
|
|
|
|
|
|
424
|
0
|
|
|
|
|
|
return 0; |
|
425
|
|
|
|
|
|
|
} |
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
=head1 ERROR CODES |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=head2 1, noDirSpecified |
|
430
|
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
No directory specified. |
|
432
|
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=head2 2, notAtoaderDir |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
The directory is not a L directory. |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
=head2 3, otherToaderDir |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
The L directory in question is not under the L |
|
440
|
|
|
|
|
|
|
directory root it was initialized with. |
|
441
|
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
=head2 4, notAbleToFindRoot |
|
443
|
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
Unable to find the root L directory. |
|
445
|
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=head2 5, notUnderToaderRoot |
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
The directory is not under the root L directory. |
|
449
|
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
=head1 AUTHOR |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
|
453
|
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
=head1 BUGS |
|
455
|
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
457
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
458
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=head1 SUPPORT |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
466
|
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
perldoc Toader::Render |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
You can also look for information at: |
|
471
|
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
=over 4 |
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
475
|
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
L |
|
477
|
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
479
|
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
L |
|
481
|
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
L |
|
485
|
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=item * Search CPAN |
|
487
|
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
L |
|
489
|
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
=back |
|
491
|
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
494
|
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
Copyright 2011. Zane C. Bowers-Hadley. |
|
499
|
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
501
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
502
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
505
|
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=cut |
|
508
|
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
1; # End of Toader |