line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::FTP::Path::Iter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Iterative, recursive, FTP file finder |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
188700
|
use 5.010; |
|
1
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
22
|
|
9
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
517
|
use Net::FTP; |
|
1
|
|
|
|
|
83947
|
|
|
1
|
|
|
|
|
76
|
|
14
|
1
|
|
|
1
|
|
495
|
use File::Spec::Functions qw[ splitpath ]; |
|
1
|
|
|
|
|
682
|
|
|
1
|
|
|
|
|
59
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
7
|
use parent 'Path::Iterator::Rule'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
13184
|
use Net::FTP::Path::Iter::Dir; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
6
|
use namespace::clean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
1
|
1
|
1964
|
my $class = shift; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
2
|
my %attr; |
50
|
1
|
50
|
|
|
|
4
|
if (@_ % 2) { |
51
|
1
|
|
|
|
|
2
|
my $host = shift; |
52
|
1
|
|
|
|
|
4
|
%attr = @_; |
53
|
1
|
|
|
|
|
3
|
$attr{Host} = $host; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
0
|
|
|
|
|
0
|
%attr = @_; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
10
|
my $self = $class->SUPER::new(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
defined( my $host = delete $attr{Host} ) |
62
|
1
|
50
|
|
|
|
13
|
or croak( "missing Host attribute\n" ); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
defined( my $user = delete $attr{user} ) |
65
|
1
|
50
|
|
|
|
4
|
or croak( "missing user attribute\n" ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
defined( my $password = delete $attr{password} ) |
68
|
1
|
50
|
|
|
|
4
|
or croak( "missing password attribute\n" ); |
69
|
|
|
|
|
|
|
|
70
|
1
|
50
|
|
|
|
6
|
$self->{server} = Net::FTP->new($host, %attr) |
71
|
|
|
|
|
|
|
or croak("unable to connect to server $host\n"); |
72
|
|
|
|
|
|
|
|
73
|
1
|
50
|
|
|
|
46
|
$self->{server}->login( $user, $password ) |
74
|
|
|
|
|
|
|
or croak("unable to log in to $host\n"); |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
87
|
return $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _defaults { |
80
|
|
|
|
|
|
|
return ( |
81
|
|
|
|
|
|
|
_stringify => 0, |
82
|
|
|
|
|
|
|
follow_symlinks => 1, |
83
|
|
|
|
|
|
|
depthfirst => 0, |
84
|
|
|
|
|
|
|
sorted => 1, |
85
|
|
|
|
|
|
|
loop_safe => 1, |
86
|
0
|
|
|
0
|
|
0
|
error_handler => sub { die sprintf( "%s: %s", @_ ) }, |
87
|
1
|
|
|
1
|
|
751
|
visitor => undef, |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub _fast_defaults { |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return ( |
94
|
0
|
|
|
0
|
|
0
|
_stringify => 0, |
95
|
|
|
|
|
|
|
follow_symlinks => 1, |
96
|
|
|
|
|
|
|
depthfirst => -1, |
97
|
|
|
|
|
|
|
sorted => 0, |
98
|
|
|
|
|
|
|
loop_safe => 0, |
99
|
|
|
|
|
|
|
error_handler => undef, |
100
|
|
|
|
|
|
|
visitor => undef, |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _objectify { |
105
|
|
|
|
|
|
|
|
106
|
1
|
|
|
1
|
|
43
|
my ( $self, $path ) = @_; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
4
|
my ( $volume, $directories, $name ) = splitpath($path); |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
30
|
$directories =~ s{(.+)/$}{$1}; |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
5
|
my %attr = ( |
113
|
|
|
|
|
|
|
parent => $directories, |
114
|
|
|
|
|
|
|
name => $name, |
115
|
|
|
|
|
|
|
path => $path, |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
16
|
return Net::FTP::Path::Iter::Dir->new( server => $self->{server}, %attr ); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _children { |
122
|
|
|
|
|
|
|
|
123
|
5
|
|
|
5
|
|
155
|
my ( $self, $path ) = @_; |
124
|
|
|
|
|
|
|
|
125
|
5
|
|
|
|
|
14
|
return map { [ $_->{name}, $_ ] } $path->_children; |
|
13
|
|
|
|
|
88
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _iter { |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
131
|
1
|
|
|
|
|
2
|
my $defaults = shift; |
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
3
|
$defaults->{loop_safe} = 0; |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
6
|
$self->SUPER::_iter( $defaults, @_ ); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# |
142
|
|
|
|
|
|
|
# This file is part of Net-FTP-Path-Iter |
143
|
|
|
|
|
|
|
# |
144
|
|
|
|
|
|
|
# This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory. |
145
|
|
|
|
|
|
|
# |
146
|
|
|
|
|
|
|
# This is free software, licensed under: |
147
|
|
|
|
|
|
|
# |
148
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
149
|
|
|
|
|
|
|
# |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__END__ |