line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::FTP::Path::Iter::Entry; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
377
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Class representing a Filesystem Entry |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
15
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
13
|
1
|
|
|
1
|
|
5
|
use Fcntl qw[ :mode ]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
178
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
377
|
use File::Listing qw[ parse_dir ]; |
|
1
|
|
|
|
|
3812
|
|
|
1
|
|
|
|
|
44
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
6
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use overload |
20
|
|
|
|
|
|
|
'-X' => '_statit', |
21
|
14
|
|
|
14
|
|
738
|
'bool' => sub { 1 }, |
22
|
14
|
|
|
14
|
|
180
|
'""' => sub { $_[0]->{path} }, |
23
|
1
|
|
|
1
|
|
567
|
; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
4
|
use Class::Tiny qw[ |
26
|
|
|
|
|
|
|
name type size mtime mode parent server path |
27
|
1
|
|
|
1
|
|
469
|
], { _has_attrs => 0 }; |
|
1
|
|
|
|
|
1437
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub BUILD { |
39
|
|
|
|
|
|
|
|
40
|
14
|
|
|
14
|
1
|
1141
|
my $self = shift; |
41
|
14
|
100
|
|
|
|
243
|
$self->_retrieve_attrs |
42
|
|
|
|
|
|
|
unless $self->_has_attrs; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _statit { |
46
|
|
|
|
|
|
|
|
47
|
33
|
|
|
33
|
|
201
|
my $self = shift; |
48
|
33
|
|
|
|
|
54
|
my $op = shift; |
49
|
|
|
|
|
|
|
|
50
|
33
|
50
|
|
|
|
484
|
$self->_retrieve_attrs |
51
|
|
|
|
|
|
|
unless $self->_has_attrs; |
52
|
|
|
|
|
|
|
|
53
|
33
|
100
|
|
|
|
197
|
if ( $op eq 'd' ) { return $self->is_dir } |
|
14
|
50
|
|
|
|
35
|
|
|
|
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
|
|
|
|
|
64
|
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
|
|
|
|
|
32
|
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
|
|
27
|
my ( $self, $path ) = @_; |
74
|
|
|
|
|
|
|
|
75
|
5
|
|
|
|
|
61
|
my $server = $self->server; |
76
|
|
|
|
|
|
|
|
77
|
5
|
|
|
|
|
34
|
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
|
|
|
|
|
413
|
my @entries; |
85
|
5
|
|
|
|
|
19
|
eval { |
86
|
5
|
50
|
|
|
|
19
|
$server->cwd( $path ) |
87
|
|
|
|
|
|
|
or croak( "unable to chdir to ", $path, "\n" ); |
88
|
|
|
|
|
|
|
|
89
|
5
|
50
|
|
|
|
638
|
my $listing = $server->dir( '.' ) |
90
|
|
|
|
|
|
|
or croak( "error listing $path" ); |
91
|
|
|
|
|
|
|
|
92
|
5
|
|
|
|
|
21428
|
for my $entry ( parse_dir( $listing ) ) { |
93
|
|
|
|
|
|
|
|
94
|
13
|
|
|
|
|
3803
|
my %attr; |
95
|
13
|
|
|
|
|
133
|
@attr{qw[ name type size mtime mode]} = @$entry; |
96
|
13
|
|
|
|
|
47
|
$attr{parent} = $path; |
97
|
13
|
|
|
|
|
33
|
$attr{_has_attrs} = 1; |
98
|
|
|
|
|
|
|
|
99
|
13
|
|
|
|
|
54
|
push @entries, \%attr; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
|
104
|
5
|
|
|
|
|
12
|
my $err = $@; |
105
|
|
|
|
|
|
|
|
106
|
5
|
50
|
|
|
|
78
|
$server->cwd( $pwd ) |
107
|
|
|
|
|
|
|
or croak( "unable to return to directory: $pwd\n" ); |
108
|
|
|
|
|
|
|
|
109
|
5
|
50
|
|
|
|
1252
|
croak( $err ) if $err; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
5
|
|
|
|
|
72
|
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__ |