line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Listing::Ftpcopy; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
156791
|
use strict; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
344
|
|
4
|
12
|
|
|
12
|
|
60
|
use warnings; |
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
309
|
|
5
|
12
|
|
|
12
|
|
277
|
use 5.008001; |
|
12
|
|
|
|
|
37
|
|
6
|
12
|
|
|
12
|
|
54
|
use Exporter; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
543
|
|
7
|
12
|
|
|
12
|
|
56
|
use Carp qw( croak ); |
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
692
|
|
8
|
12
|
|
|
12
|
|
19399
|
use Time::Local qw( timelocal ); |
|
12
|
|
|
|
|
20890
|
|
|
12
|
|
|
|
|
9658
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: parse directory listing using ftpparse from ftpcopy |
11
|
|
|
|
|
|
|
our $VERSION = '0.07'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse_dir ($;$$$) |
15
|
|
|
|
|
|
|
{ |
16
|
7
|
|
|
7
|
1
|
11157
|
my($listing, $time_zone, $type, $error) = @_; |
17
|
|
|
|
|
|
|
|
18
|
7
|
100
|
|
0
|
|
47
|
$error = sub { warn shift } if (defined $error ? $error : '') eq 'warn'; |
|
0
|
50
|
|
|
|
0
|
|
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
|
|
15
|
my $next; |
21
|
7
|
100
|
|
|
|
58
|
if(ref($listing) eq 'ARRAY') |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
2
|
|
|
|
|
6
|
my @lines = @$listing; |
24
|
2
|
|
|
5
|
|
12
|
$next = sub { shift @lines }; |
|
5
|
|
|
|
|
14
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif(ref($listing) eq 'GLOB') |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
$next = sub { |
29
|
3
|
|
|
3
|
|
13
|
my $line = <$listing>; |
30
|
3
|
|
|
|
|
8
|
$line; |
31
|
1
|
|
|
|
|
7
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif(ref $listing) |
34
|
|
|
|
|
|
|
{ |
35
|
0
|
|
|
|
|
0
|
croak "Illegal argument to parse_dir()"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif($listing =~ /^\*\w+(::\w+)+$/) |
38
|
|
|
|
|
|
|
{ |
39
|
|
|
|
|
|
|
$next = sub { |
40
|
3
|
|
|
3
|
|
11
|
my $line = <$listing>; |
41
|
3
|
|
|
|
|
9
|
$line; |
42
|
1
|
|
|
|
|
6
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else |
45
|
|
|
|
|
|
|
{ |
46
|
3
|
|
|
|
|
51
|
my @lines = split /\015?\012/, $listing; |
47
|
3
|
|
|
49
|
|
16
|
$next = sub { shift @lines }; |
|
49
|
|
|
|
|
125
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
7
|
|
|
|
|
14
|
my @answer; |
51
|
|
|
|
|
|
|
|
52
|
7
|
|
|
|
|
22
|
my $line = $next->(); |
53
|
7
|
|
|
|
|
26
|
while(defined $line) |
54
|
|
|
|
|
|
|
{ |
55
|
53
|
|
|
|
|
73
|
chomp $line; |
56
|
53
|
|
|
|
|
296
|
my $h = _parse_dir($line); |
57
|
53
|
100
|
|
|
|
113
|
if(defined $h) |
|
|
100
|
|
|
|
|
|
58
|
|
|
|
|
|
|
{ |
59
|
34
|
|
|
|
|
47
|
my $mtimetype = pop @$h; |
60
|
34
|
50
|
66
|
|
|
86
|
if($mtimetype == MTIME_LOCAL()) |
|
|
50
|
33
|
|
|
|
|
61
|
|
|
|
|
|
|
{ |
62
|
0
|
0
|
|
|
|
0
|
if(defined $time_zone) |
63
|
|
|
|
|
|
|
{ |
64
|
0
|
|
|
|
|
0
|
my $secs = localtime($h->[3]); |
65
|
0
|
|
|
|
|
0
|
local $ENV{TZ} = $time_zone; |
66
|
0
|
|
|
|
|
0
|
$h->[3] = timelocal($secs); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif($mtimetype == MTIME_REMOTEMINUTE() |
70
|
|
|
|
|
|
|
|| $mtimetype == MTIME_REMOTEDAY() |
71
|
|
|
|
|
|
|
|| $mtimetype == MTIME_REMOTESECOND()) |
72
|
|
|
|
|
|
|
{ |
73
|
34
|
50
|
|
|
|
60
|
if(defined $time_zone) |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
|
|
0
|
local $ENV{TZ} = $time_zone; |
76
|
0
|
|
|
|
|
0
|
$h->[3] = timelocal(gmtime($h->[3])); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else |
79
|
|
|
|
|
|
|
{ |
80
|
34
|
|
|
|
|
197
|
$h->[3] = timelocal(gmtime($h->[3])); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
34
|
|
|
|
|
1683
|
push @answer, $h; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
elsif(defined $error) |
86
|
|
|
|
|
|
|
{ |
87
|
1
|
|
|
|
|
3
|
$error->($line) |
88
|
|
|
|
|
|
|
} |
89
|
53
|
|
|
|
|
196
|
$line = $next->(); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
7
|
100
|
|
|
|
61
|
return wantarray ? @answer : \@answer; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
our @ISA = qw( Exporter ); |
97
|
|
|
|
|
|
|
our @EXPORT = qw( parse_dir ); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => [qw( |
100
|
|
|
|
|
|
|
parse_dir |
101
|
|
|
|
|
|
|
ftpparse |
102
|
|
|
|
|
|
|
FORMAT_EPLF |
103
|
|
|
|
|
|
|
FORMAT_LS |
104
|
|
|
|
|
|
|
FORMAT_MLSX |
105
|
|
|
|
|
|
|
FORMAT_UNKNOWN |
106
|
|
|
|
|
|
|
ID_FULL |
107
|
|
|
|
|
|
|
ID_UNKNOWN |
108
|
|
|
|
|
|
|
MTIME_LOCAL |
109
|
|
|
|
|
|
|
MTIME_REMOTEDAY |
110
|
|
|
|
|
|
|
MTIME_REMOTEMINUTE |
111
|
|
|
|
|
|
|
MTIME_REMOTESECOND |
112
|
|
|
|
|
|
|
MTIME_UNKNOWN |
113
|
|
|
|
|
|
|
SIZE_ASCII |
114
|
|
|
|
|
|
|
SIZE_BINARY |
115
|
|
|
|
|
|
|
SIZE_UNKNOWN |
116
|
|
|
|
|
|
|
) ] ); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{all} } ); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
require XSLoader; |
121
|
|
|
|
|
|
|
XSLoader::load('File::Listing::Ftpcopy', $VERSION); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub AUTOLOAD |
124
|
|
|
|
|
|
|
{ |
125
|
27
|
|
|
27
|
|
2718
|
my $name; |
126
|
27
|
|
|
|
|
35
|
our $AUTOLOAD; |
127
|
27
|
|
|
|
|
125
|
($name = $AUTOLOAD) =~ s/.*:://; |
128
|
27
|
50
|
|
|
|
83
|
croak "$AUTOLOAD not defined" if $name eq '_constant'; |
129
|
27
|
|
|
|
|
87
|
my $val = _constant($name); |
130
|
27
|
50
|
|
|
|
64
|
croak "$AUTOLOAD not defined" if $val == -1; |
131
|
27
|
|
|
|
|
36
|
do { |
132
|
12
|
|
|
12
|
|
84
|
no strict 'refs'; |
|
12
|
|
|
|
|
17
|
|
|
12
|
|
|
|
|
1133
|
|
133
|
27
|
|
|
85
|
|
182
|
*$AUTOLOAD = sub { $val }; |
|
85
|
|
|
|
|
291
|
|
134
|
|
|
|
|
|
|
}; |
135
|
27
|
|
|
|
|
139
|
goto &$AUTOLOAD; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlxstut.html |
142
|
|
|
|
|
|
|
# http://perldoc.perl.org/perlguts.html |
143
|
|
|
|
|
|
|
# http://old.nabble.com/*URGENT*-ftpparse-licensing-issue-to61623.html |
144
|
|
|
|
|
|
|
# http://fossies.org/dox/ftpcopy-0.6.7/index.html |
145
|
|
|
|
|
|
|
# http://woodsheep.jp/wget-ftpparse/wget-1.5.3-ftpparse-19970712-0.52.patch |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__END__ |