line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::ShareDir::Override; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
60150
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Override directories returned by File::ShareDir |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.100'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1725
|
use File::ShareDir; |
|
1
|
|
|
|
|
11149
|
|
|
1
|
|
|
|
|
300
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %dist_dirs; |
13
|
|
|
|
|
|
|
my %module_dirs; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
2
|
|
|
2
|
|
5287
|
my ($package, $dir) = @_; |
17
|
|
|
|
|
|
|
|
18
|
2
|
100
|
|
|
|
21
|
return if !defined $dir; |
19
|
|
|
|
|
|
|
|
20
|
1
|
50
|
|
|
|
7
|
if ($dir =~ /:/) { |
21
|
2
|
|
|
|
|
13
|
map { |
22
|
1
|
|
|
|
|
6
|
my @opt = split /(?
|
23
|
|
|
|
|
|
|
|
24
|
2
|
100
|
|
|
|
9
|
if ($opt[0] =~ /::/) { |
|
|
50
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# module_dir ("Foo::Bar:/some/path") |
26
|
1
|
|
33
|
|
|
2348
|
$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
|
|
|
|
|
6
|
$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
|
|
13
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
56
|
1
|
|
|
1
|
|
5
|
no warnings 'redefine'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
357
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
*{"File::ShareDir::dist_dir"} = sub { |
59
|
2
|
|
|
2
|
|
50
|
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
|
|
5
|
my $dist = File::ShareDir::_DIST(shift); |
66
|
1
|
|
|
|
|
16
|
my $file = File::ShareDir::_FILE(shift); |
67
|
|
|
|
|
|
|
|
68
|
1
|
50
|
|
|
|
23
|
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
|
|
39
|
my $module = File::ShareDir::_MODULE(shift); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
33
|
|
|
66
|
return $module_dirs{$module} || &$_File_ShareDir_module_dir($module); |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
*{"File::ShareDir::module_file"} = sub { |
83
|
1
|
|
|
1
|
|
5
|
my $module = File::ShareDir::_MODULE(shift); |
84
|
1
|
|
|
|
|
36
|
my $file = File::ShareDir::_FILE(shift); |
85
|
|
|
|
|
|
|
|
86
|
1
|
50
|
|
|
|
15
|
if ($module_dirs{$module}) { |
87
|
1
|
|
|
|
|
22
|
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__ |