line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::FTP::Path::Iter::Entry; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
417
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Class representing a Filesystem Entry |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
9
|
1
|
|
|
1
|
|
4
|
use experimental 'switch'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
139
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
14
|
1
|
|
|
1
|
|
8
|
use Fcntl qw[ :mode ]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
209
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
417
|
use File::Listing qw[ parse_dir ]; |
|
1
|
|
|
|
|
3535
|
|
|
1
|
|
|
|
|
47
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
9
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use overload |
21
|
|
|
|
|
|
|
'-X' => '_statit', |
22
|
14
|
|
|
14
|
|
511
|
'bool' => sub { 1 }, |
23
|
14
|
|
|
14
|
|
219
|
'""' => sub { $_[0]->{path} }, |
24
|
1
|
|
|
1
|
|
724
|
; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
15
|
use Class::Tiny qw[ |
27
|
|
|
|
|
|
|
name type size mtime mode parent server path |
28
|
1
|
|
|
1
|
|
564
|
], { _has_attrs => 0 }; |
|
1
|
|
|
|
|
1399
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#pod =begin pod_coverage |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =head3 BUILD |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod =end pod_coverage |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod =cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub BUILD { |
40
|
|
|
|
|
|
|
|
41
|
14
|
|
|
14
|
1
|
1046
|
my $self = shift; |
42
|
14
|
100
|
|
|
|
240
|
$self->_retrieve_attrs |
43
|
|
|
|
|
|
|
unless $self->_has_attrs; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _statit { |
47
|
|
|
|
|
|
|
|
48
|
33
|
|
|
33
|
|
245
|
my $self = shift; |
49
|
33
|
|
|
|
|
54
|
my $op = shift; |
50
|
|
|
|
|
|
|
|
51
|
33
|
50
|
|
|
|
511
|
$self->_retrieve_attrs |
52
|
|
|
|
|
|
|
unless $self->_has_attrs; |
53
|
|
|
|
|
|
|
|
54
|
33
|
|
|
|
|
215
|
for ( $op ) { |
55
|
|
|
|
|
|
|
|
56
|
33
|
|
|
|
|
72
|
when ( 'd' ) { return $self->is_dir } |
|
14
|
|
|
|
|
44
|
|
57
|
|
|
|
|
|
|
|
58
|
19
|
|
|
|
|
41
|
when ( 'f' ) { return $self->is_file } |
|
0
|
|
|
|
|
0
|
|
59
|
|
|
|
|
|
|
|
60
|
19
|
|
|
|
|
31
|
when ( 's' ) { return $self->size } |
|
0
|
|
|
|
|
0
|
|
61
|
|
|
|
|
|
|
|
62
|
19
|
|
|
|
|
29
|
when ( 'z' ) { return $self->size != 0 } |
|
0
|
|
|
|
|
0
|
|
63
|
|
|
|
|
|
|
|
64
|
19
|
|
|
|
|
33
|
when ( 'r' ) { return S_IROTH & $self->mode } |
|
5
|
|
|
|
|
76
|
|
65
|
|
|
|
|
|
|
|
66
|
14
|
|
|
|
|
26
|
when ( 'R' ) { return S_IROTH & $self->mode } |
|
0
|
|
|
|
|
0
|
|
67
|
|
|
|
|
|
|
|
68
|
14
|
|
|
|
|
25
|
when ( 'l' ) { return 0 } |
|
14
|
|
|
|
|
54
|
|
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
default { croak( "unsupported file test: -$op\n" ) } |
|
0
|
|
|
|
|
0
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _get_entries { |
77
|
|
|
|
|
|
|
|
78
|
5
|
|
|
5
|
|
30
|
my ( $self, $path ) = @_; |
79
|
|
|
|
|
|
|
|
80
|
5
|
|
|
|
|
63
|
my $server = $self->server; |
81
|
|
|
|
|
|
|
|
82
|
5
|
|
|
|
|
41
|
my $pwd = $server->pwd; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# on some ftp servers, if $path is a symbolic link, dir($path) |
85
|
|
|
|
|
|
|
# willl return a listing of $path's own entry, not of its |
86
|
|
|
|
|
|
|
# contents. as a work around, explicitly cwd($path), |
87
|
|
|
|
|
|
|
# get the listing, then restore the working directory |
88
|
|
|
|
|
|
|
|
89
|
5
|
|
|
|
|
499
|
my @entries; |
90
|
5
|
|
|
|
|
16
|
eval { |
91
|
5
|
50
|
|
|
|
28
|
$server->cwd( $path ) |
92
|
|
|
|
|
|
|
or croak( "unable to chdir to ", $path, "\n" ); |
93
|
|
|
|
|
|
|
|
94
|
5
|
50
|
|
|
|
693
|
my $listing = $server->dir( '.' ) |
95
|
|
|
|
|
|
|
or croak( "error listing $path" ); |
96
|
|
|
|
|
|
|
|
97
|
5
|
|
|
|
|
17284
|
for my $entry ( parse_dir( $listing ) ) { |
98
|
|
|
|
|
|
|
|
99
|
13
|
|
|
|
|
3604
|
my %attr; |
100
|
13
|
|
|
|
|
81
|
@attr{qw[ name type size mtime mode]} = @$entry; |
101
|
13
|
|
|
|
|
43
|
$attr{parent} = $path; |
102
|
13
|
|
|
|
|
29
|
$attr{_has_attrs} = 1; |
103
|
|
|
|
|
|
|
|
104
|
13
|
|
|
|
|
44
|
push @entries, \%attr; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
}; |
108
|
|
|
|
|
|
|
|
109
|
5
|
|
|
|
|
56
|
my $err = $@; |
110
|
|
|
|
|
|
|
|
111
|
5
|
50
|
|
|
|
56
|
$server->cwd( $pwd ) |
112
|
|
|
|
|
|
|
or croak( "unable to return to directory: $pwd\n" ); |
113
|
|
|
|
|
|
|
|
114
|
5
|
50
|
|
|
|
993
|
croak( $err ) if $err; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
5
|
|
|
|
|
35
|
return \@entries; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# |
122
|
|
|
|
|
|
|
# This file is part of Net-FTP-Path-Iter |
123
|
|
|
|
|
|
|
# |
124
|
|
|
|
|
|
|
# This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory. |
125
|
|
|
|
|
|
|
# |
126
|
|
|
|
|
|
|
# This is free software, licensed under: |
127
|
|
|
|
|
|
|
# |
128
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
129
|
|
|
|
|
|
|
# |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=pod |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 NAME |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Net::FTP::Path::Iter::Entry - Class representing a Filesystem Entry |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 VERSION |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
version 0.04 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 DESCRIPTION |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
A B object represents an entry in the remote |
146
|
|
|
|
|
|
|
FTP filesystem. It is rarely seen in the wild. Rather, |
147
|
|
|
|
|
|
|
L uses the subclasses B |
148
|
|
|
|
|
|
|
and B when passing paths to callbacks or |
149
|
|
|
|
|
|
|
returning paths to iterators. These subclasses have no unique methods |
150
|
|
|
|
|
|
|
or attributes of their own; they only have those of this, their parent |
151
|
|
|
|
|
|
|
class. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 mode |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
The entry mode as returned by L. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 mtime |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
The entry modification time. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 name |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
The entry name. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 path |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
The complete path to the entry |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 parent |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
The parent directory of the entry |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 server |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
The L server object |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 size |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
The size of the entry |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 type |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
The type of the entry, one of |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=over |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item f |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
file |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item d |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
directory |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item l |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
symbolic link. See however L |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item ? |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
unknown |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=back |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 METHODS |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 is_dir |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
$bool = $entry->is_dir; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
returns true if the entry is a directory. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head2 is_file |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
$bool = $entry->is_file; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
returns true if the entry is a file. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=begin pod_coverage |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head3 BUILD |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=end pod_coverage |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
You can make new bug reports, and view existing ones, through the |
230
|
|
|
|
|
|
|
web interface at L. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 SEE ALSO |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=over 4 |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item * |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
L |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=back |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 AUTHOR |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Diab Jerius |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
This is free software, licensed under: |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=cut |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
__END__ |