line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Find; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.31'; |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
152021
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
247
|
|
6
|
5
|
|
|
5
|
|
29
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
401
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
31
|
use Carp; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
3252
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# selects implementation module: |
11
|
|
|
|
|
|
|
our @ISA; |
12
|
|
|
|
|
|
|
BEGIN { |
13
|
5
|
50
|
|
5
|
|
51
|
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
|
5
|
|
|
|
|
2808
|
require Config::Find::Unix; |
52
|
5
|
|
|
|
|
3096
|
@ISA=qw(Config::Find::Unix); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub find { |
57
|
9
|
|
|
9
|
1
|
6689
|
my $class=shift; |
58
|
9
|
|
|
|
|
34
|
my ($write, $global, $fn, @names)=$class->parse_opts(@_); |
59
|
6
|
50
|
|
|
|
23
|
if (defined $fn) { |
60
|
0
|
0
|
0
|
|
|
0
|
return ($write or -f $fn) ? $fn : undef; |
61
|
|
|
|
|
|
|
} |
62
|
6
|
|
|
|
|
80
|
$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
|
34
|
my ($class, %opts)=@_; |
82
|
9
|
|
|
|
|
15
|
my $fn=$opts{file}; |
83
|
9
|
|
|
|
|
13
|
my @names; |
84
|
9
|
100
|
|
|
|
40
|
if (exists $opts{name}) { |
|
|
50
|
|
|
|
|
|
85
|
1
|
|
|
|
|
6
|
@names=$opts{name}; |
86
|
|
|
|
|
|
|
} elsif (exists $opts{names}) { |
87
|
8
|
100
|
|
|
|
375
|
UNIVERSAL::isa($opts{names}, 'ARRAY') |
88
|
|
|
|
|
|
|
or croak "invalid argument for 'names', expecting an array ref"; |
89
|
7
|
|
|
|
|
10
|
@names=@{$opts{names}} |
|
7
|
|
|
|
|
22
|
|
90
|
|
|
|
|
|
|
} else { |
91
|
0
|
|
|
|
|
0
|
@names=$class->guess_script_name(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
8
|
|
|
|
|
42
|
my $write; |
95
|
8
|
100
|
|
|
|
24
|
if (exists $opts{mode}) { |
96
|
4
|
100
|
|
|
|
37
|
if ($opts{mode}=~/^r(ead)?$/i) { |
|
|
100
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# yes, do nothing! |
98
|
|
|
|
|
|
|
} elsif ($opts{mode}=~/w(rite)?$/i) { |
99
|
2
|
|
|
|
|
5
|
$write=1; |
100
|
|
|
|
|
|
|
} else { |
101
|
1
|
|
|
|
|
209
|
croak "invalid option mode => '$opts{mode}'"; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
7
|
|
|
|
|
10
|
my $global; |
106
|
7
|
100
|
|
|
|
19
|
if (exists $opts{scope}) { |
107
|
2
|
50
|
|
|
|
17
|
if ($opts{scope}=~/^u(ser)?$/i) { |
|
|
100
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# yes, do nothing! |
109
|
|
|
|
|
|
|
} elsif ($opts{scope}=~/g(lobal)?$/i) { |
110
|
1
|
|
|
|
|
3
|
$global=1; |
111
|
|
|
|
|
|
|
} else { |
112
|
1
|
|
|
|
|
260
|
croak "invalid option scope => '$opts{scope}'"; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
6
|
|
|
|
|
30
|
return ($write, $global, $fn, @names) |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__END__ |