line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::System::Passthrough; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
95
|
|
9
|
1
|
|
|
1
|
|
7
|
use base 'File::System::Object'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
843
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
File::System::Passthrough - A file system module that delegates work to another |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package File::System::MyModule; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use strict; |
20
|
|
|
|
|
|
|
use base 'File::System::Passthrough'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# You now have all methods available, just define those you must. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module is pretty useless on it's own. It simply delegates all the real work to an internal wrapped module. It shouldn't be used directly. However, I've found that many of the special modules written are used to wrap others and this provides the basic functionality. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 SUBCLASSING |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Basically, you can just declare L as your base class and be done. You can define as many or few other methods as you prefer. You can refer to the wrapped class like so: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub my_method { |
33
|
|
|
|
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
my $wrapped_fs = $self->{fs}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# ... |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
As of this writing, no other key in the C<$self> hash is used, so you can manipulate the other keys as you wish. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 ADDITIONAL API |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item $obj = File::System-Enew('Passthrough', $wrapped_obj) |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The constructor takes either a decendent of L or a reference to an array that can be used to construct such an object in C<$wrapped_obj>. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new { |
52
|
1
|
|
|
1
|
1
|
4
|
my $class = shift; |
53
|
1
|
|
|
|
|
2
|
my $fs = shift; |
54
|
|
|
|
|
|
|
|
55
|
1
|
50
|
|
|
|
18
|
$fs = File::System->new(@$fs) if UNIVERSAL::isa($fs, 'ARRAY'); |
56
|
|
|
|
|
|
|
|
57
|
1
|
50
|
|
|
|
8
|
UNIVERSAL::isa($fs, 'File::System::Object') |
58
|
|
|
|
|
|
|
or croak "Wrapped object must be of type File::System::Object."; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
10
|
return bless { |
61
|
|
|
|
|
|
|
fs => $fs, |
62
|
|
|
|
|
|
|
}, $class; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my @plain = qw/ |
66
|
|
|
|
|
|
|
exists |
67
|
|
|
|
|
|
|
is_creatable |
68
|
|
|
|
|
|
|
is_valid |
69
|
|
|
|
|
|
|
basename |
70
|
|
|
|
|
|
|
dirname |
71
|
|
|
|
|
|
|
path |
72
|
|
|
|
|
|
|
is_root |
73
|
|
|
|
|
|
|
properties |
74
|
|
|
|
|
|
|
settable_properties |
75
|
|
|
|
|
|
|
get_property |
76
|
|
|
|
|
|
|
set_property |
77
|
|
|
|
|
|
|
rename |
78
|
|
|
|
|
|
|
move |
79
|
|
|
|
|
|
|
remove |
80
|
|
|
|
|
|
|
object_type |
81
|
|
|
|
|
|
|
has_content |
82
|
|
|
|
|
|
|
is_container |
83
|
|
|
|
|
|
|
is_readable |
84
|
|
|
|
|
|
|
is_seekable |
85
|
|
|
|
|
|
|
is_writable |
86
|
|
|
|
|
|
|
is_appendable |
87
|
|
|
|
|
|
|
open |
88
|
|
|
|
|
|
|
content |
89
|
|
|
|
|
|
|
has_children |
90
|
|
|
|
|
|
|
children_paths |
91
|
|
|
|
|
|
|
/; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my @wrap_if_defined = qw/ |
94
|
|
|
|
|
|
|
root |
95
|
|
|
|
|
|
|
lookup |
96
|
|
|
|
|
|
|
create |
97
|
|
|
|
|
|
|
parent |
98
|
|
|
|
|
|
|
copy |
99
|
|
|
|
|
|
|
child |
100
|
|
|
|
|
|
|
/; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my @wrap_list = qw/ |
103
|
|
|
|
|
|
|
glob |
104
|
|
|
|
|
|
|
children |
105
|
|
|
|
|
|
|
/; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
for my $sub (@plain) { |
108
|
122
|
0
|
|
122
|
1
|
294
|
eval <
|
|
122
|
0
|
|
8
|
1
|
273
|
|
|
0
|
0
|
|
64
|
1
|
0
|
|
|
122
|
0
|
|
218
|
1
|
486
|
|
|
8
|
100
|
|
148
|
1
|
15
|
|
|
8
|
50
|
|
72
|
1
|
21
|
|
|
0
|
0
|
|
8
|
1
|
0
|
|
|
8
|
0
|
|
16
|
1
|
37
|
|
|
64
|
0
|
|
16
|
1
|
103
|
|
|
64
|
0
|
|
9
|
1
|
112
|
|
|
0
|
0
|
|
0
|
1
|
0
|
|
|
64
|
0
|
|
16
|
1
|
225
|
|
|
218
|
0
|
|
49
|
1
|
343
|
|
|
218
|
0
|
|
16
|
1
|
343
|
|
|
0
|
0
|
|
24
|
1
|
0
|
|
|
218
|
0
|
|
16
|
1
|
709
|
|
|
148
|
100
|
|
48
|
1
|
27761
|
|
|
148
|
0
|
|
0
|
1
|
300
|
|
|
108
|
50
|
|
48
|
1
|
971
|
|
|
148
|
0
|
|
3888
|
1
|
590
|
|
|
72
|
0
|
|
171
|
1
|
132
|
|
|
72
|
50
|
|
48
|
1
|
133
|
|
|
72
|
50
|
|
48
|
1
|
1125
|
|
|
72
|
50
|
|
72
|
1
|
282
|
|
|
8
|
0
|
|
24
|
1
|
15
|
|
|
8
|
|
|
|
|
20
|
|
|
0
|
|
|
|
|
0
|
|
|
8
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
46
|
|
|
0
|
|
|
|
|
0
|
|
|
16
|
|
|
|
|
93
|
|
|
16
|
|
|
|
|
30
|
|
|
16
|
|
|
|
|
38
|
|
|
0
|
|
|
|
|
0
|
|
|
16
|
|
|
|
|
64
|
|
|
9
|
|
|
|
|
30
|
|
|
9
|
|
|
|
|
25
|
|
|
0
|
|
|
|
|
0
|
|
|
9
|
|
|
|
|
43
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
42
|
|
|
0
|
|
|
|
|
0
|
|
|
16
|
|
|
|
|
77
|
|
|
49
|
|
|
|
|
84
|
|
|
49
|
|
|
|
|
90
|
|
|
0
|
|
|
|
|
0
|
|
|
49
|
|
|
|
|
213
|
|
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
39
|
|
|
0
|
|
|
|
|
0
|
|
|
16
|
|
|
|
|
68
|
|
|
24
|
|
|
|
|
63
|
|
|
24
|
|
|
|
|
71
|
|
|
0
|
|
|
|
|
0
|
|
|
24
|
|
|
|
|
130
|
|
|
16
|
|
|
|
|
27
|
|
|
16
|
|
|
|
|
42
|
|
|
0
|
|
|
|
|
0
|
|
|
16
|
|
|
|
|
77
|
|
|
48
|
|
|
|
|
90
|
|
|
48
|
|
|
|
|
83
|
|
|
64
|
|
|
|
|
396
|
|
|
48
|
|
|
|
|
268
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
48
|
|
|
|
|
82
|
|
|
48
|
|
|
|
|
89
|
|
|
48
|
|
|
|
|
405
|
|
|
48
|
|
|
|
|
224
|
|
|
3888
|
|
|
|
|
6672
|
|
|
3888
|
|
|
|
|
6678
|
|
|
0
|
|
|
|
|
0
|
|
|
3888
|
|
|
|
|
13433
|
|
|
171
|
|
|
|
|
13250
|
|
|
171
|
|
|
|
|
286
|
|
|
0
|
|
|
|
|
0
|
|
|
171
|
|
|
|
|
869
|
|
|
48
|
|
|
|
|
16779
|
|
|
48
|
|
|
|
|
93
|
|
|
32
|
|
|
|
|
304
|
|
|
48
|
|
|
|
|
198
|
|
|
48
|
|
|
|
|
92
|
|
|
48
|
|
|
|
|
92
|
|
|
48
|
|
|
|
|
367
|
|
|
48
|
|
|
|
|
200
|
|
|
72
|
|
|
|
|
135
|
|
|
72
|
|
|
|
|
136
|
|
|
144
|
|
|
|
|
744
|
|
|
72
|
|
|
|
|
302
|
|
|
24
|
|
|
|
|
46
|
|
|
24
|
|
|
|
|
52
|
|
|
0
|
|
|
|
|
0
|
|
|
24
|
|
|
|
|
101
|
|
109
|
|
|
|
|
|
|
sub $sub { |
110
|
|
|
|
|
|
|
my \$self = shift; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my \@args = map { |
113
|
|
|
|
|
|
|
UNIVERSAL::isa(\$_, 'File::System::Passthrough') ? |
114
|
|
|
|
|
|
|
\$_->{fs} : \$_ |
115
|
|
|
|
|
|
|
} \@_; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
return \$self->{fs}->$sub(\@args); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
EOF |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
die $@ if $@; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
for my $sub (@wrap_if_defined) { |
125
|
22
|
50
|
|
22
|
1
|
562
|
eval <
|
|
22
|
100
|
|
24
|
1
|
41
|
|
|
22
|
100
|
|
48
|
1
|
159
|
|
|
22
|
50
|
|
152
|
1
|
84
|
|
|
22
|
50
|
|
297
|
1
|
57
|
|
|
21
|
50
|
|
10
|
1
|
111
|
|
|
1
|
50
|
|
|
|
7
|
|
|
24
|
50
|
|
|
|
45
|
|
|
24
|
0
|
|
|
|
47
|
|
|
32
|
50
|
|
|
|
198
|
|
|
24
|
0
|
|
|
|
111
|
|
|
24
|
50
|
|
|
|
97
|
|
|
24
|
|
|
|
|
190
|
|
|
0
|
|
|
|
|
0
|
|
|
48
|
|
|
|
|
32692
|
|
|
48
|
|
|
|
|
128
|
|
|
96
|
|
|
|
|
611
|
|
|
48
|
|
|
|
|
247
|
|
|
48
|
|
|
|
|
154
|
|
|
48
|
|
|
|
|
319
|
|
|
0
|
|
|
|
|
0
|
|
|
152
|
|
|
|
|
32935
|
|
|
152
|
|
|
|
|
299
|
|
|
152
|
|
|
|
|
1452
|
|
|
152
|
|
|
|
|
816
|
|
|
152
|
|
|
|
|
429
|
|
|
152
|
|
|
|
|
1090
|
|
|
0
|
|
|
|
|
0
|
|
|
297
|
|
|
|
|
524
|
|
|
297
|
|
|
|
|
823
|
|
|
0
|
|
|
|
|
0
|
|
|
297
|
|
|
|
|
1148
|
|
|
297
|
|
|
|
|
898
|
|
|
297
|
|
|
|
|
2035
|
|
|
0
|
|
|
|
|
0
|
|
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
24
|
|
|
0
|
|
|
|
|
0
|
|
|
10
|
|
|
|
|
124
|
|
|
10
|
|
|
|
|
40
|
|
|
10
|
|
|
|
|
56
|
|
|
0
|
|
|
|
|
0
|
|
126
|
|
|
|
|
|
|
sub $sub { |
127
|
|
|
|
|
|
|
my \$self = shift; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my \@args = map { |
130
|
|
|
|
|
|
|
UNIVERSAL::isa(\$_, 'File::System::Passthrough') ? |
131
|
|
|
|
|
|
|
\$_->{fs} : \$_ |
132
|
|
|
|
|
|
|
} \@_; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my \$obj = \$self->{fs}->$sub(\@args); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
if (defined \$obj) { |
137
|
|
|
|
|
|
|
return bless { |
138
|
|
|
|
|
|
|
fs => \$obj, |
139
|
|
|
|
|
|
|
}, ref \$self; |
140
|
|
|
|
|
|
|
} else { |
141
|
|
|
|
|
|
|
return undef; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
EOF |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
die $@ if $@; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
for my $sub (@wrap_list) { |
150
|
8
|
0
|
|
8
|
1
|
18
|
eval <
|
|
8
|
50
|
|
72
|
1
|
23
|
|
|
0
|
|
|
|
|
0
|
|
|
8
|
|
|
|
|
45
|
|
|
8
|
|
|
|
|
61
|
|
|
72
|
|
|
|
|
114
|
|
|
72
|
|
|
|
|
120
|
|
|
72
|
|
|
|
|
8317
|
|
|
72
|
|
|
|
|
345
|
|
|
66
|
|
|
|
|
323
|
|
151
|
|
|
|
|
|
|
sub $sub { |
152
|
|
|
|
|
|
|
my \$self = shift; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my \@args = map { |
155
|
|
|
|
|
|
|
UNIVERSAL::isa(\$_, 'File::System::Passthrough') ? |
156
|
|
|
|
|
|
|
\$_->{fs} : \$_ |
157
|
|
|
|
|
|
|
} \@_; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
return map { |
160
|
|
|
|
|
|
|
bless { |
161
|
|
|
|
|
|
|
fs => \$_, |
162
|
|
|
|
|
|
|
}, ref \$self; |
163
|
|
|
|
|
|
|
} \$self->{fs}->$sub(\@args); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
EOF |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
die $@ if $@; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub find { |
171
|
80
|
|
|
80
|
1
|
126
|
my $self = shift; |
172
|
80
|
|
|
|
|
120
|
my $want = shift; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
my @args = (sub { |
175
|
362
|
|
|
362
|
|
407
|
my $file = shift; |
176
|
362
|
|
|
|
|
2005
|
return $want->(bless { fs => $file }, ref $self); |
177
|
80
|
|
|
|
|
411
|
}); |
178
|
|
|
|
|
|
|
|
179
|
36
|
50
|
|
|
|
198
|
push @args, map { |
180
|
80
|
|
|
|
|
154
|
UNIVERSAL::isa($_, 'File::System::Passthrough') ? |
181
|
|
|
|
|
|
|
$_->{fs} : $_ |
182
|
|
|
|
|
|
|
} @_; |
183
|
|
|
|
|
|
|
|
184
|
76
|
|
|
|
|
579
|
return map { |
185
|
80
|
|
|
|
|
354
|
bless { |
186
|
|
|
|
|
|
|
fs => $_, |
187
|
|
|
|
|
|
|
}, ref $self; |
188
|
|
|
|
|
|
|
} $self->{fs}->find(@args); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=back |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 SEE ALSO |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
L, L |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 AUTHOR |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp, Ehanenkamp@users.sourceforge.netE |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Copyright 2005 Andrew Sterling Hanenkamp. All Rights Reserved. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This software is distributed and licensed under the same terms as Perl itself. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=cut |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
1 |