line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::FileThing; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::FileThing.pm |
11
|
|
|
|
|
|
|
# Description: A new generic type of "Thing" in The Goo based on global config |
12
|
|
|
|
|
|
|
# files. A Thing is a handle on an underlying Thing. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Date Change |
15
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
16
|
|
|
|
|
|
|
# 01/11/2005 Subclassed Thing - I wanted to avoid this ... but now it does |
17
|
|
|
|
|
|
|
# make sense - may use composition later. |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
############################################################################### |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
482
|
use Goo::Thing; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
24
|
1
|
|
|
1
|
|
539
|
use Goo::FileUtilities; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
31
|
|
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
9
|
use base qw(Goo::Thing); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
319
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
############################################################################### |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# new - constructor |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
############################################################################### |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
my ($class, $full_path) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
unless ($full_path) { |
40
|
0
|
|
|
|
|
|
die("No file location specified: " . caller()); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# pull apart the path |
44
|
0
|
|
|
|
|
|
$full_path =~ /(.*)\/(.*)$/; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $location = $1; |
47
|
0
|
|
|
|
|
|
my $filename = $2; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# start making this Thing |
50
|
0
|
|
|
|
|
|
my $this = $class->SUPER::new($filename); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# remember where this Thing can be found |
53
|
0
|
|
|
|
|
|
$this->{location} = $location; |
54
|
0
|
|
|
|
|
|
$this->{full_path} = $full_path; |
55
|
0
|
|
|
|
|
|
$this->{filename} = $filename; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $this; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
############################################################################### |
63
|
|
|
|
|
|
|
# |
64
|
|
|
|
|
|
|
# get_file - get the full contents of the file |
65
|
|
|
|
|
|
|
# |
66
|
|
|
|
|
|
|
############################################################################### |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub get_file { |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return Goo::FileUtilities::get_file_as_string($this->{full_path}); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
############################################################################### |
78
|
|
|
|
|
|
|
# |
79
|
|
|
|
|
|
|
# get_full_path - where is this thang located? |
80
|
|
|
|
|
|
|
# |
81
|
|
|
|
|
|
|
############################################################################### |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_full_path { |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# return the current location |
88
|
0
|
|
|
|
|
|
return $this->{full_path}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
############################################################################### |
94
|
|
|
|
|
|
|
# |
95
|
|
|
|
|
|
|
# get_filename - return the filename |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
############################################################################### |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub get_filename { |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return $this->{filename}; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
############################################################################### |
109
|
|
|
|
|
|
|
# |
110
|
|
|
|
|
|
|
# get_location - return the directory this thing is located in |
111
|
|
|
|
|
|
|
# |
112
|
|
|
|
|
|
|
############################################################################### |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub get_location { |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
return $this->{location}; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 NAME |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Goo::FileThing - A "Thing" that is found in the filesystem and has a location |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SYNOPSIS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
use Goo::FileThing; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 DESCRIPTION |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
A FileThing has a location in the file system. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 METHODS |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item new |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
constructor |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item get_file |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
return the full contents of the file |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item get_full_path |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
return the full file system path |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item get_filename |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
return the filename |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item get_location |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
return the directory this Thing is located in |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 AUTHOR |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SEE ALSO |
170
|
|
|
|
|
|
|
|