line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::AddInc; |
2
|
2
|
|
|
2
|
|
3668
|
use 5.008001; |
|
2
|
|
|
|
|
9
|
|
3
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
27
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
339
|
use mro qw/c3/; |
|
2
|
|
|
|
|
485
|
|
|
2
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.001"; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
63
|
use File::Spec; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
10
|
2
|
|
|
2
|
|
8
|
use File::Basename; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
91
|
|
11
|
2
|
|
|
2
|
|
8
|
use Cwd (); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
18
|
|
12
|
2
|
|
|
2
|
|
342
|
use lib (); |
|
2
|
|
|
|
|
474
|
|
|
2
|
|
|
|
|
22
|
|
13
|
2
|
|
|
2
|
|
6
|
use Carp (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
39
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
8
|
use constant DEBUG => $ENV{DEBUG_MOP4IMPORT}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
967
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
0
|
|
|
0
|
|
0
|
my ($pack) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
my ($callpack, $filename, $line) = caller; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
$pack->declare_file_inc($callpack, $filename); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub declare_file_inc { |
26
|
0
|
|
|
0
|
0
|
0
|
my ($pack, @caller) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
0
|
@caller = caller unless @caller; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
my $libdir = libdir($pack, @caller); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
print STDERR "# use lib '$libdir'\n" if DEBUG; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
lib->import($libdir); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub libdir { |
38
|
2
|
|
|
2
|
1
|
3440
|
my ($pack, @caller) = @_; |
39
|
|
|
|
|
|
|
|
40
|
2
|
50
|
|
|
|
6
|
my ($callpack, $filename) = @caller ? @caller : caller; |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
8
|
(my $packfn = $callpack) =~ s,::,/,g; |
43
|
2
|
|
|
|
|
11
|
$packfn .= ".pm"; |
44
|
|
|
|
|
|
|
|
45
|
2
|
50
|
|
|
|
109
|
my $realFn = -l $filename |
46
|
|
|
|
|
|
|
? resolve_symlink($pack, $filename) |
47
|
|
|
|
|
|
|
: $filename; |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
55
|
my $absfn = File::Spec->rel2abs($realFn); |
50
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
19
|
$absfn =~ /\Q$packfn\E\z/ |
52
|
|
|
|
|
|
|
or Carp::croak("Can't handle this case! absfn=$absfn; packfn=$packfn"); |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
13
|
substr($absfn, 0, length($absfn) - length($packfn) - 1); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub resolve_symlink { |
58
|
0
|
|
|
0
|
0
|
|
my ($pack, $filePath) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
print STDERR "# resolve_symlink($filePath)...\n" if DEBUG; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
(undef, my ($realDir)) = fileparse($filePath); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
while (defined (my $linkText = readlink $filePath)) { |
65
|
0
|
|
|
|
|
|
($filePath, $realDir) = resolve_symlink_1($pack, $linkText, $realDir); |
66
|
0
|
|
|
|
|
|
print STDERR "# => $filePath (realDir=$realDir)\n" if DEBUG; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $filePath; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub resolve_symlink_1 { |
73
|
0
|
|
|
0
|
0
|
|
my ($pack, $linkText, $realDir) = @_; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $filePath = do { |
76
|
0
|
0
|
|
|
|
|
if (File::Spec->file_name_is_absolute($linkText)) { |
77
|
0
|
|
|
|
|
|
$linkText; |
78
|
|
|
|
|
|
|
} else { |
79
|
0
|
|
|
|
|
|
File::Spec->catfile($realDir, $linkText); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if (wantarray) { |
84
|
|
|
|
|
|
|
# purify x/../y to y |
85
|
0
|
|
|
|
|
|
my $realPath = Cwd::realpath($filePath); |
86
|
0
|
|
|
|
|
|
(undef, $realDir) = fileparse($realPath); |
87
|
0
|
|
|
|
|
|
($realPath, $realDir); |
88
|
|
|
|
|
|
|
} else { |
89
|
0
|
|
|
|
|
|
$filePath; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |