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
|
|
177511
|
use 5.010; |
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
9
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
521
|
use Net::FTP; |
|
1
|
|
|
|
|
79879
|
|
|
1
|
|
|
|
|
43
|
|
14
|
1
|
|
|
1
|
|
330
|
use File::Spec::Functions qw[ splitpath ]; |
|
1
|
|
|
|
|
632
|
|
|
1
|
|
|
|
|
51
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
6
|
use parent 'Path::Iterator::Rule'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
12357
|
use Net::FTP::Path::Iter::Dir; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
5
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
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
|
1690
|
my $class = shift; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
3
|
my %attr; |
50
|
1
|
50
|
|
|
|
4
|
if (@_ % 2) { |
51
|
1
|
|
|
|
|
1
|
my $host = shift; |
52
|
1
|
|
|
|
|
4
|
%attr = @_; |
53
|
1
|
|
|
|
|
2
|
$attr{Host} = $host; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
0
|
|
|
|
|
0
|
%attr = @_; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
8
|
my $self = $class->SUPER::new(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
defined( my $host = delete $attr{Host} ) |
62
|
1
|
50
|
|
|
|
11
|
or croak( "missing Host attribute\n" ); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
defined( my $user = delete $attr{user} ) |
65
|
1
|
50
|
|
|
|
3
|
or croak( "missing user attribute\n" ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
defined( my $password = delete $attr{password} ) |
68
|
1
|
50
|
|
|
|
3
|
or croak( "missing password attribute\n" ); |
69
|
|
|
|
|
|
|
|
70
|
1
|
50
|
|
|
|
5
|
$self->{server} = Net::FTP->new($host, %attr) |
71
|
|
|
|
|
|
|
or croak("unable to connect to server $host\n"); |
72
|
|
|
|
|
|
|
|
73
|
1
|
50
|
|
|
|
41
|
$self->{server}->login( $user, $password ) |
74
|
|
|
|
|
|
|
or croak("unable to log in to $host\n"); |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
78
|
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
|
|
641
|
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
|
|
36
|
my ( $self, $path ) = @_; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
4
|
my ( $volume, $directories, $name ) = splitpath($path); |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
28
|
$directories =~ s{(.+)/$}{$1}; |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
4
|
my %attr = ( |
113
|
|
|
|
|
|
|
parent => $directories, |
114
|
|
|
|
|
|
|
name => $name, |
115
|
|
|
|
|
|
|
path => $path, |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
14
|
return Net::FTP::Path::Iter::Dir->new( server => $self->{server}, %attr ); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _children { |
122
|
|
|
|
|
|
|
|
123
|
5
|
|
|
5
|
|
130
|
my ( $self, $path ) = @_; |
124
|
|
|
|
|
|
|
|
125
|
5
|
|
|
|
|
12
|
return map { [ $_->{name}, $_ ] } $path->_children; |
|
13
|
|
|
|
|
73
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _iter { |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
131
|
1
|
|
|
|
|
2
|
my $defaults = shift; |
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
2
|
$defaults->{loop_safe} = 0; |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
5
|
$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__ |