line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::ShareDir::Override; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21384
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Override directories returned by File::ShareDir |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.200'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
503
|
use File::ShareDir; |
|
1
|
|
|
|
|
5211
|
|
|
1
|
|
|
|
|
225
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %dist_dirs; |
13
|
|
|
|
|
|
|
my %module_dirs; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
2
|
|
|
2
|
|
2265
|
my ($package, $dir) = @_; |
17
|
|
|
|
|
|
|
|
18
|
2
|
100
|
|
|
|
16
|
return if !defined $dir; |
19
|
|
|
|
|
|
|
|
20
|
1
|
50
|
|
|
|
5
|
if ($dir =~ /:/) { |
21
|
2
|
|
|
|
|
9
|
map { |
22
|
1
|
|
|
|
|
4
|
my @opt = split /(?
|
23
|
|
|
|
|
|
|
|
24
|
2
|
100
|
|
|
|
7
|
if ($opt[0] =~ /::/) { |
|
|
50
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# module_dir ("Foo::Bar:/some/path") |
26
|
1
|
|
33
|
|
|
1538
|
$module_dirs{$opt[0]} = $opt[2] || $opt[1]; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
elsif (defined $opt[2]) { |
29
|
0
|
0
|
|
|
|
0
|
if ($opt[1] eq 'dist') { |
|
|
0
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# dist_dir ("Foo:dist:/some/path") |
31
|
0
|
|
|
|
|
0
|
$dist_dirs{$opt[0]} = $opt[2]; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ($opt[1] eq 'module') { |
34
|
|
|
|
|
|
|
# module_dir ("Foo:module:/some/path") |
35
|
0
|
|
|
|
|
0
|
$module_dirs{$opt[0]} = $opt[2]; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
|
|
|
|
|
|
# Assume dist_dir ("Foo-Bar:/some/path" or "Foo:/some/path") |
40
|
1
|
|
|
|
|
4
|
$dist_dirs{$opt[0]} = $opt[1]; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} split ';', $dir; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
|
|
|
|
|
|
# TODO: Guess the distribution and the share directory? |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
my $_File_ShareDir_dist_dir = \&File::ShareDir::dist_dir; |
51
|
|
|
|
|
|
|
my $_File_ShareDir_dist_file = \&File::ShareDir::dist_file; |
52
|
|
|
|
|
|
|
my $_File_ShareDir_module_dir = \&File::ShareDir::module_dir; |
53
|
|
|
|
|
|
|
my $_File_ShareDir_module_file = \&File::ShareDir::module_file; |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
56
|
1
|
|
|
1
|
|
4
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
246
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
*{"File::ShareDir::dist_dir"} = sub { |
59
|
2
|
|
|
2
|
|
51
|
my $dist = File::ShareDir::_DIST(shift); |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
100
|
|
|
39
|
return $dist_dirs{$dist} || &$_File_ShareDir_dist_dir($dist); |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
*{"File::ShareDir::dist_file"} = sub { |
65
|
1
|
|
|
1
|
|
3
|
my $dist = File::ShareDir::_DIST(shift); |
66
|
1
|
|
|
|
|
13
|
my $file = File::ShareDir::_FILE(shift); |
67
|
|
|
|
|
|
|
|
68
|
1
|
50
|
|
|
|
27
|
if ($dist_dirs{$dist}) { |
69
|
1
|
|
|
|
|
37
|
return File::Spec->catfile($dist_dirs{$dist}, $file); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
0
|
|
|
|
|
0
|
return &$_File_ShareDir_dist_file($dist, $file); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
*{"File::ShareDir::module_dir"} = sub { |
77
|
2
|
|
|
2
|
|
24
|
my $module = File::ShareDir::_MODULE(shift); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
33
|
|
|
52
|
return $module_dirs{$module} || &$_File_ShareDir_module_dir($module); |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
*{"File::ShareDir::module_file"} = sub { |
83
|
1
|
|
|
1
|
|
4
|
my $module = File::ShareDir::_MODULE(shift); |
84
|
1
|
|
|
|
|
29
|
my $file = File::ShareDir::_FILE(shift); |
85
|
|
|
|
|
|
|
|
86
|
1
|
50
|
|
|
|
11
|
if ($module_dirs{$module}) { |
87
|
1
|
|
|
|
|
15
|
return File::Spec->catfile($module_dirs{$module}, $file); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else { |
90
|
0
|
|
|
|
|
|
return &$_File_ShareDir_module_file($module, $file); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |