| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::FTP::Rule::Dir; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Class representing a Directory |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
25
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
25
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
8
|
1
|
|
|
1
|
|
466
|
use experimental 'switch'; |
|
|
1
|
|
|
|
|
2934
|
|
|
|
1
|
|
|
|
|
6
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; # TRIAL |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
171
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
54
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use Fcntl qw[ :mode ]; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
217
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use File::Spec::Functions qw[ catdir catfile ]; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
376
|
use namespace::clean; |
|
|
1
|
|
|
|
|
11741
|
|
|
|
1
|
|
|
|
|
6
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
691
|
use parent 'Net::FTP::Rule::Entry'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
424
|
use Net::FTP::Rule::File; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
28
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
6
|
use constant is_file => 0; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use constant is_dir => 1; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
556
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _children { |
|
27
|
|
|
|
|
|
|
|
|
28
|
5
|
|
|
5
|
|
14
|
my $self = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
118
|
my %attr = ( server => $self->server, ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
136
|
my $entries = $self->_get_entries( $self->path ); |
|
33
|
|
|
|
|
|
|
|
|
34
|
5
|
|
|
|
|
36
|
my @children; |
|
35
|
|
|
|
|
|
|
|
|
36
|
5
|
|
|
|
|
26
|
for my $entry ( @$entries ) { |
|
37
|
|
|
|
|
|
|
|
|
38
|
13
|
|
|
|
|
36
|
my $obj; |
|
39
|
|
|
|
|
|
|
|
|
40
|
13
|
|
|
|
|
44
|
for ( $entry->{type} ) { |
|
41
|
|
|
|
|
|
|
|
|
42
|
13
|
|
|
|
|
47
|
when ( 'd' ) { |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$obj = Net::FTP::Rule::Dir->new( %$entry, %attr, |
|
45
|
4
|
|
|
|
|
196
|
path => catdir( $self->path, $entry->{name} ) ); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
9
|
|
|
|
|
30
|
when ( 'f' ) { |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$obj = Net::FTP::Rule::File->new( %$entry, %attr, |
|
51
|
9
|
|
|
|
|
400
|
path => catfile( $self->path, $entry->{name} ) ); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
default { |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
warn( "ignoring $entry->{name}; unknown type $_\n" ); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
13
|
|
|
|
|
327
|
push @children, $obj; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
5
|
|
|
|
|
50
|
return @children; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# if an entity doesn't have attributes, it didn't get loaded |
|
69
|
|
|
|
|
|
|
# from a directory listing. Try to get one. This should |
|
70
|
|
|
|
|
|
|
# happen rarely, so do this slowly but correctly. |
|
71
|
|
|
|
|
|
|
sub _retrieve_attrs { |
|
72
|
|
|
|
|
|
|
|
|
73
|
1
|
|
|
1
|
|
50
|
my $self = shift; |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
50
|
|
|
|
17
|
return if $self->_has_attrs; |
|
76
|
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
43
|
my $server = $self->server; |
|
78
|
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
17
|
my $pwd = $server->pwd; |
|
80
|
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
110
|
my $entry = {}; |
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
50
|
|
|
|
26
|
$server->cwd( $self->path ) |
|
84
|
|
|
|
|
|
|
or croak( "unable to chdir to ", $self->path, "\n" ); |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# File::Listing doesn't return . or .. (and some FTP servers |
|
87
|
|
|
|
|
|
|
# don't return that info anyway), so try to go up a dir and |
|
88
|
|
|
|
|
|
|
# look for the name |
|
89
|
1
|
|
|
|
|
169
|
eval { |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# cdup sometimes returns ok even if it didn't work |
|
92
|
1
|
|
|
|
|
13
|
$server->cdup; |
|
93
|
|
|
|
|
|
|
|
|
94
|
1
|
50
|
|
|
|
144
|
if ( $pwd ne $server->pwd ) { |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
0
|
my $entries = $self->_get_entries( '.' ); |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
0
|
( $entry ) = grep { $self->name eq $_->{name} } @$entries; |
|
|
0
|
|
|
|
|
0
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
0
|
croak( "unable to find attributes for ", $self->path, "\n" ) |
|
101
|
|
|
|
|
|
|
if !$entry; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
0
|
croak( $self->path, ": expected directory, got $entry->{type}\n" ) |
|
104
|
|
|
|
|
|
|
unless $entry->type eq 'd'; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# couldn't go up a directory; at the top? |
|
109
|
|
|
|
|
|
|
else { |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# fake it. |
|
112
|
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
86
|
$entry = { |
|
114
|
|
|
|
|
|
|
size => 0, |
|
115
|
|
|
|
|
|
|
mtime => 0, |
|
116
|
|
|
|
|
|
|
mode => S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH |
|
117
|
|
|
|
|
|
|
| S_IXOTH, |
|
118
|
|
|
|
|
|
|
type => 'd', |
|
119
|
|
|
|
|
|
|
_has_attrs => 1, |
|
120
|
|
|
|
|
|
|
}; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
}; |
|
125
|
|
|
|
|
|
|
|
|
126
|
1
|
|
|
|
|
4
|
my $err = $@; |
|
127
|
|
|
|
|
|
|
|
|
128
|
1
|
50
|
|
|
|
6
|
$server->cwd( $pwd ) |
|
129
|
|
|
|
|
|
|
or croak( "unable to return to directory: $pwd\n" ); |
|
130
|
|
|
|
|
|
|
|
|
131
|
1
|
50
|
|
|
|
135
|
croak( $err ) if $err; |
|
132
|
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
27
|
$self->$_( $entry->{$_} ) for keys %$entry; |
|
134
|
1
|
|
|
|
|
80
|
return; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# |
|
138
|
|
|
|
|
|
|
# This file is part of Net-FTP-Rule |
|
139
|
|
|
|
|
|
|
# |
|
140
|
|
|
|
|
|
|
# This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory. |
|
141
|
|
|
|
|
|
|
# |
|
142
|
|
|
|
|
|
|
# This is free software, licensed under: |
|
143
|
|
|
|
|
|
|
# |
|
144
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
|
145
|
|
|
|
|
|
|
# |
|
146
|
|
|
|
|
|
|
1; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
__END__ |