line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LEOCHARRE::Dir; |
2
|
1
|
|
|
1
|
|
15274
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT_OK); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
72
|
|
5
|
1
|
|
|
1
|
|
5
|
use Exporter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
671
|
|
6
|
|
|
|
|
|
|
@ISA = qw/Exporter/; |
7
|
|
|
|
|
|
|
@EXPORT_OK = qw(reqdir ls lsa lsf lsfa lsd lsda lsr lsfr lsdr); |
8
|
|
|
|
|
|
|
%EXPORT_TAGS = ( all => \@EXPORT_OK ); |
9
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)/g; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
*reqdir = \&__require_dir; |
12
|
|
|
|
|
|
|
*ls = \&__ls; |
13
|
|
|
|
|
|
|
*lsa = \&__lsa; |
14
|
|
|
|
|
|
|
*lsf = \&__lsf; |
15
|
|
|
|
|
|
|
*lsfa = \&__lsfa; |
16
|
|
|
|
|
|
|
*lsd = \&__lsd; |
17
|
|
|
|
|
|
|
*lsda = \&__lsda; |
18
|
|
|
|
|
|
|
*lsr = \&__lsr; |
19
|
|
|
|
|
|
|
*lsfr = \&__lsfr; |
20
|
|
|
|
|
|
|
*lsdr = \&__lsdr; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub __require_dir { |
24
|
4
|
|
|
4
|
|
598
|
require Cwd; |
25
|
4
|
50
|
|
|
|
375
|
my $_d = Cwd::abs_path($_[0]) or croak("Bad or missing argument '@_'."); |
26
|
4
|
50
|
0
|
|
|
441
|
-d $_d or mkdir $_d or warn("cant mkdir $_d") and return; |
|
|
|
33
|
|
|
|
|
27
|
4
|
|
|
|
|
23
|
return $_d; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub __ls { |
31
|
11
|
100
|
|
11
|
|
854
|
$_[0] or croak("Bad or missing argument."); |
32
|
10
|
50
|
|
|
|
355
|
opendir(DIR, $_[0]) or die("Cant open dir '$_[0]', $!"); |
33
|
10
|
|
|
|
|
161
|
my @ls = grep { !/^\.+$/ } readdir DIR; |
|
65
|
|
|
|
|
197
|
|
34
|
10
|
|
|
|
|
126
|
closedir DIR; |
35
|
10
|
|
|
|
|
44
|
return @ls; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
sub __lsa { |
38
|
7
|
50
|
|
7
|
|
930
|
$_[0] or croak("Bad or missing argument"); |
39
|
7
|
|
|
|
|
81
|
require Cwd; |
40
|
7
|
50
|
|
|
|
573
|
my $abs = Cwd::abs_path($_[0]) or die("Can't resolve abs path to '@_'"); |
41
|
7
|
|
|
|
|
26
|
my @ls = map { "$abs/$_" } __ls($abs); |
|
30
|
|
|
|
|
82
|
|
42
|
7
|
|
|
|
|
391
|
return @ls; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# no leading path |
47
|
1
|
|
|
1
|
|
303
|
sub __lsf { return ( grep { -f "$_[0]/$_" } __ls( $_[0]) ) } |
|
5
|
|
|
|
|
120
|
|
48
|
1
|
|
|
1
|
|
331
|
sub __lsd { return ( grep { -d "$_[0]/$_" } __ls( $_[0]) ) } |
|
5
|
|
|
|
|
119
|
|
49
|
|
|
|
|
|
|
#*__lsd = \&__lsreaddir; this is stupidly broken |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# absolute path |
52
|
2
|
|
|
2
|
|
393
|
sub __lsfa { return ( grep -f, __lsa( $_[0]) ) } |
53
|
2
|
|
|
2
|
|
374
|
sub __lsda { return ( grep -d, __lsa( $_[0]) ) } |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# relative path to docroot |
56
|
1
|
|
|
1
|
|
18
|
sub __lsr { return ( map { __rel2docroot($_) } __lsa( $_[0]) ) } |
|
5
|
|
|
|
|
17
|
|
57
|
1
|
|
|
1
|
|
599
|
sub __lsfr { return ( map { __rel2docroot($_) } __lsfa( $_[0]) ) } |
|
2
|
|
|
|
|
5
|
|
58
|
1
|
|
|
1
|
|
440
|
sub __lsdr { return ( map { __rel2docroot($_) } __lsda( $_[0]) ) } |
|
3
|
|
|
|
|
7
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub __rel2docroot { |
61
|
10
|
50
|
|
10
|
|
42
|
$ENV{DOCUMENT_ROOT} or die("ENV DOCUMENT ROOT not set"); |
62
|
|
|
|
|
|
|
|
63
|
10
|
|
|
|
|
15
|
my $p = shift; |
64
|
10
|
50
|
|
|
|
73
|
$p or die('missing argument'); |
65
|
|
|
|
|
|
|
|
66
|
10
|
50
|
|
|
|
96
|
$p=~s/^$ENV{DOCUMENT_ROOT}// or return; |
67
|
10
|
|
|
|
|
37
|
return $p; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# see .pod |
73
|
|
|
|
|
|
|
|