| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Goo::FileFinder; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
|
4
|
|
|
|
|
|
|
# Nigel Hamilton |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
|
7
|
|
|
|
|
|
|
# All Rights Reserved |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
|
10
|
|
|
|
|
|
|
# Filename: Goo::FileFinder.pm |
|
11
|
|
|
|
|
|
|
# Description: Go looking for files |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# Date Change |
|
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
15
|
|
|
|
|
|
|
# 17/11/2005 Find files given locations |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
############################################################################### |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
145
|
|
|
20
|
1
|
|
|
1
|
|
16
|
use Goo::Prompter; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
228
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
############################################################################### |
|
24
|
|
|
|
|
|
|
# |
|
25
|
|
|
|
|
|
|
# find - return a location for a Thing - look for it in Goo space!! |
|
26
|
|
|
|
|
|
|
# |
|
27
|
|
|
|
|
|
|
############################################################################### |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub find { |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
|
|
my ($filename, @locations) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my @found_locations; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# check all the locations where this Thing can be found |
|
36
|
0
|
|
|
|
|
|
foreach my $location (@locations) { |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
### checking a location location |
|
39
|
0
|
|
|
|
|
|
my $file_location = $location . "/" . $filename; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if (-e $file_location) { |
|
42
|
|
|
|
|
|
|
### return the first file we find of that name |
|
43
|
0
|
|
|
|
|
|
push(@found_locations, $file_location); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if (scalar(@found_locations) > 1) { |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $selected_location = Goo::Prompter::pick_one("Select which file?", @found_locations); |
|
51
|
0
|
|
|
|
|
|
foreach my $location (@found_locations) { |
|
52
|
0
|
0
|
|
|
|
|
next if $location eq $selected_location; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#if (Goo::Prompter::confirm("Delete $location", "N")) { |
|
55
|
|
|
|
|
|
|
# unlink($location); |
|
56
|
|
|
|
|
|
|
#} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return $selected_location; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} else { |
|
62
|
0
|
|
|
|
|
|
return pop(@found_locations); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
############################################################################### |
|
69
|
|
|
|
|
|
|
# |
|
70
|
|
|
|
|
|
|
# run_driver |
|
71
|
|
|
|
|
|
|
# |
|
72
|
|
|
|
|
|
|
############################################################################### |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub run_driver { |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
|
|
print find("FileFinder.pm", ("/home/goo/src/Goo")); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# called from the command line |
|
81
|
|
|
|
|
|
|
run_driver(@ARGV) unless (caller()); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Goo::FileFinder - Go looking for files |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
use Goo::FileFinder; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 METHODS |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
112
|
|
|
|
|
|
|
|