line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::FTP::Path::Iter::Entry; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
446
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Class representing a Filesystem Entry |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
19
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
81
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
69
|
|
13
|
1
|
|
|
1
|
|
6
|
use Fcntl qw[ :mode ]; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
297
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
431
|
use File::Listing qw[ parse_dir ]; |
|
1
|
|
|
|
|
4050
|
|
|
1
|
|
|
|
|
46
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
7
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use overload |
20
|
|
|
|
|
|
|
'-X' => '_statit', |
21
|
14
|
|
|
14
|
|
694
|
'bool' => sub { 1 }, |
22
|
14
|
|
|
14
|
|
211
|
'""' => sub { $_[0]->{path} }, |
23
|
1
|
|
|
1
|
|
612
|
; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
5
|
use Class::Tiny qw[ |
26
|
|
|
|
|
|
|
name type size mtime mode parent server path |
27
|
1
|
|
|
1
|
|
519
|
], { _has_attrs => 0 }; |
|
1
|
|
|
|
|
1506
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub BUILD { |
39
|
|
|
|
|
|
|
|
40
|
14
|
|
|
14
|
1
|
1210
|
my $self = shift; |
41
|
14
|
100
|
|
|
|
281
|
$self->_retrieve_attrs |
42
|
|
|
|
|
|
|
unless $self->_has_attrs; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _statit { |
46
|
|
|
|
|
|
|
|
47
|
33
|
|
|
33
|
|
217
|
my $self = shift; |
48
|
33
|
|
|
|
|
58
|
my $op = shift; |
49
|
|
|
|
|
|
|
|
50
|
33
|
50
|
|
|
|
497
|
$self->_retrieve_attrs |
51
|
|
|
|
|
|
|
unless $self->_has_attrs; |
52
|
|
|
|
|
|
|
|
53
|
33
|
100
|
|
|
|
201
|
if ( $op eq 'd' ) { return $self->is_dir } |
|
14
|
50
|
|
|
|
44
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
0
|
elsif ( $op eq 'f' ) { return $self->is_file } |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
elsif ( $op eq 's' ) { return $self->size } |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
0
|
elsif ( $op eq 'z' ) { return $self->size != 0 } |
60
|
|
|
|
|
|
|
|
61
|
5
|
|
|
|
|
79
|
elsif ( $op eq 'r' ) { return S_IROTH & $self->mode } |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
0
|
elsif ( $op eq 'R' ) { return S_IROTH & $self->mode } |
64
|
|
|
|
|
|
|
|
65
|
14
|
|
|
|
|
28
|
elsif ( $op eq 'l' ) { return 0 } |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
else { croak( "unsupported file test: -$op\n" ) } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _get_entries { |
72
|
|
|
|
|
|
|
|
73
|
5
|
|
|
5
|
|
28
|
my ( $self, $path ) = @_; |
74
|
|
|
|
|
|
|
|
75
|
5
|
|
|
|
|
64
|
my $server = $self->server; |
76
|
|
|
|
|
|
|
|
77
|
5
|
|
|
|
|
37
|
my $pwd = $server->pwd; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# on some ftp servers, if $path is a symbolic link, dir($path) |
80
|
|
|
|
|
|
|
# willl return a listing of $path's own entry, not of its |
81
|
|
|
|
|
|
|
# contents. as a work around, explicitly cwd($path), |
82
|
|
|
|
|
|
|
# get the listing, then restore the working directory |
83
|
|
|
|
|
|
|
|
84
|
5
|
|
|
|
|
419
|
my @entries; |
85
|
5
|
|
|
|
|
9
|
eval { |
86
|
5
|
50
|
|
|
|
19
|
$server->cwd( $path ) |
87
|
|
|
|
|
|
|
or croak( "unable to chdir to ", $path, "\n" ); |
88
|
|
|
|
|
|
|
|
89
|
5
|
50
|
|
|
|
744
|
my $listing = $server->dir( '.' ) |
90
|
|
|
|
|
|
|
or croak( "error listing $path" ); |
91
|
|
|
|
|
|
|
|
92
|
5
|
|
|
|
|
25524
|
for my $entry ( parse_dir( $listing ) ) { |
93
|
|
|
|
|
|
|
|
94
|
13
|
|
|
|
|
4225
|
my %attr; |
95
|
13
|
|
|
|
|
162
|
@attr{qw[ name type size mtime mode]} = @$entry; |
96
|
13
|
|
|
|
|
48
|
$attr{parent} = $path; |
97
|
13
|
|
|
|
|
45
|
$attr{_has_attrs} = 1; |
98
|
|
|
|
|
|
|
|
99
|
13
|
|
|
|
|
80
|
push @entries, \%attr; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
|
104
|
5
|
|
|
|
|
20
|
my $err = $@; |
105
|
|
|
|
|
|
|
|
106
|
5
|
50
|
|
|
|
80
|
$server->cwd( $pwd ) |
107
|
|
|
|
|
|
|
or croak( "unable to return to directory: $pwd\n" ); |
108
|
|
|
|
|
|
|
|
109
|
5
|
50
|
|
|
|
1547
|
croak( $err ) if $err; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
5
|
|
|
|
|
64
|
return \@entries; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# |
117
|
|
|
|
|
|
|
# This file is part of Net-FTP-Path-Iter |
118
|
|
|
|
|
|
|
# |
119
|
|
|
|
|
|
|
# This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory. |
120
|
|
|
|
|
|
|
# |
121
|
|
|
|
|
|
|
# This is free software, licensed under: |
122
|
|
|
|
|
|
|
# |
123
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
124
|
|
|
|
|
|
|
# |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |