line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Find; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.29'; |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
62447
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
150
|
|
6
|
6
|
|
|
6
|
|
15
|
use warnings; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
109
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
18
|
use Carp; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
2330
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# selects implementation module: |
11
|
|
|
|
|
|
|
our @ISA; |
12
|
|
|
|
|
|
|
BEGIN { |
13
|
6
|
50
|
|
6
|
|
29
|
if ($^O=~/Win32/) { |
14
|
0
|
|
|
|
|
0
|
require Win32; |
15
|
0
|
|
|
|
|
0
|
my $OS = uc Win32::GetOSName(); |
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
0
|
if ($OS=~/^WIN95/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
require Config::Find::Win95; |
19
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::Win95); |
20
|
|
|
|
|
|
|
} elsif ($OS=~/^WIN98/) { |
21
|
0
|
|
|
|
|
0
|
require Config::Find::Win98; |
22
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::Win98); |
23
|
|
|
|
|
|
|
} elsif ($OS=~/^WINME/) { |
24
|
0
|
|
|
|
|
0
|
require Config::Find::WinME; |
25
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::WinME); |
26
|
|
|
|
|
|
|
} elsif ($OS=~/^WINNT/) { |
27
|
0
|
|
|
|
|
0
|
require Config::Find::WinNT; |
28
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::WinNT); |
29
|
|
|
|
|
|
|
} elsif ($OS=~/^WIN2000/) { |
30
|
0
|
|
|
|
|
0
|
require Config::Find::Win2k; |
31
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::Win2k); |
32
|
|
|
|
|
|
|
} elsif ($OS=~/^WIN2003/) { |
33
|
0
|
|
|
|
|
0
|
require Config::Find::Win2k3; |
34
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::Win2k3); |
35
|
|
|
|
|
|
|
} elsif ($OS=~/^WINXP/) { |
36
|
0
|
|
|
|
|
0
|
require Config::Find::WinXP; |
37
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::WinXP); |
38
|
|
|
|
|
|
|
} elsif ($OS=~/^WINCE/) { |
39
|
0
|
|
|
|
|
0
|
require Config::Find::WinCE; |
40
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::WinCE); |
41
|
|
|
|
|
|
|
} elsif ($OS=~/^WIN7/) { |
42
|
0
|
|
|
|
|
0
|
require Config::Find::Win7; |
43
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::Win7); |
44
|
|
|
|
|
|
|
} else { |
45
|
|
|
|
|
|
|
# default to WinAny, and separate exceptions |
46
|
0
|
|
|
|
|
0
|
require Config::Find::WinAny; |
47
|
0
|
|
|
|
|
0
|
@ISA=qw(Config::Find::WinAny); |
48
|
|
|
|
|
|
|
#croak "Unknown MSWin32 OS '$OS'"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} else { |
51
|
6
|
|
|
|
|
1795
|
require Config::Find::Unix; |
52
|
6
|
|
|
|
|
2137
|
@ISA=qw(Config::Find::Unix); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub find { |
57
|
9
|
|
|
9
|
1
|
2118
|
my $class=shift; |
58
|
9
|
|
|
|
|
17
|
my ($write, $global, $fn, @names)=$class->parse_opts(@_); |
59
|
6
|
50
|
|
|
|
8
|
if (defined $fn) { |
60
|
0
|
0
|
0
|
|
|
0
|
return ($write or -f $fn) ? $fn : undef; |
61
|
|
|
|
|
|
|
} |
62
|
6
|
|
|
|
|
19
|
$class->_find($write, $global, @names); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub open { |
66
|
0
|
|
|
0
|
1
|
0
|
my $class=shift; |
67
|
0
|
|
|
|
|
0
|
my ($write, $global, $fn, @names)=$class->parse_opts(@_); |
68
|
0
|
0
|
|
|
|
0
|
defined($fn) or $fn=$class->_find($write, $global, @names); |
69
|
0
|
|
|
|
|
0
|
$class->_open($write, $global, $fn); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub install { |
73
|
0
|
|
|
0
|
1
|
0
|
my $class=shift; |
74
|
0
|
|
|
|
|
0
|
my $orig=shift; |
75
|
0
|
|
|
|
|
0
|
my ($write, $global, $fn, @names)=$class->parse_opts( mode => 'w', @_); |
76
|
0
|
0
|
|
|
|
0
|
defined($fn) or $fn=$class->_find($write, $global, @names); |
77
|
0
|
|
|
|
|
0
|
$class->_install($orig, $write, $global, $fn); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub parse_opts { |
81
|
9
|
|
|
9
|
0
|
19
|
my ($class, %opts)=@_; |
82
|
9
|
|
|
|
|
8
|
my $fn=$opts{file}; |
83
|
9
|
|
|
|
|
6
|
my @names; |
84
|
9
|
100
|
|
|
|
18
|
if (exists $opts{name}) { |
|
|
50
|
|
|
|
|
|
85
|
1
|
|
|
|
|
14
|
@names=$opts{name}; |
86
|
|
|
|
|
|
|
} elsif (exists $opts{names}) { |
87
|
8
|
100
|
|
|
|
192
|
UNIVERSAL::isa($opts{names}, 'ARRAY') |
88
|
|
|
|
|
|
|
or croak "invalid argument for 'names', expecting an array ref"; |
89
|
7
|
|
|
|
|
5
|
@names=@{$opts{names}} |
|
7
|
|
|
|
|
10
|
|
90
|
|
|
|
|
|
|
} else { |
91
|
0
|
|
|
|
|
0
|
@names=$class->guess_script_name(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
8
|
|
|
|
|
6
|
my $write; |
95
|
8
|
100
|
|
|
|
13
|
if (exists $opts{mode}) { |
96
|
4
|
100
|
|
|
|
19
|
if ($opts{mode}=~/^r(ead)?$/i) { |
|
|
100
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# yes, do nothing! |
98
|
|
|
|
|
|
|
} elsif ($opts{mode}=~/w(rite)?$/i) { |
99
|
2
|
|
|
|
|
3
|
$write=1; |
100
|
|
|
|
|
|
|
} else { |
101
|
1
|
|
|
|
|
108
|
croak "invalid option mode => '$opts{mode}'"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
7
|
|
|
|
|
5
|
my $global; |
106
|
7
|
100
|
|
|
|
8
|
if (exists $opts{scope}) { |
107
|
2
|
50
|
|
|
|
7
|
if ($opts{scope}=~/^u(ser)?$/i) { |
|
|
100
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# yes, do nothing! |
109
|
|
|
|
|
|
|
} elsif ($opts{scope}=~/g(lobal)?$/i) { |
110
|
1
|
|
|
|
|
1
|
$global=1; |
111
|
|
|
|
|
|
|
} else { |
112
|
1
|
|
|
|
|
98
|
croak "invalid option scope => '$opts{scope}'"; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
6
|
|
|
|
|
13
|
return ($write, $global, $fn, @names) |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__END__ |