line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Listing::Ftpcopy; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
2684574
|
use strict; |
|
11
|
|
|
|
|
80
|
|
|
11
|
|
|
|
|
319
|
|
4
|
11
|
|
|
11
|
|
57
|
use warnings; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
246
|
|
5
|
11
|
|
|
11
|
|
316
|
use 5.008001; |
|
11
|
|
|
|
|
40
|
|
6
|
11
|
|
|
11
|
|
75
|
use Exporter; |
|
11
|
|
|
|
|
39
|
|
|
11
|
|
|
|
|
493
|
|
7
|
11
|
|
|
11
|
|
64
|
use Carp qw( croak ); |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
507
|
|
8
|
11
|
|
|
11
|
|
5584
|
use Time::Local qw( timelocal ); |
|
11
|
|
|
|
|
24645
|
|
|
11
|
|
|
|
|
8143
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: parse directory listing using ftpparse from ftpcopy |
11
|
|
|
|
|
|
|
our $VERSION = '0.09'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse_dir ($;$$$) |
15
|
|
|
|
|
|
|
{ |
16
|
7
|
|
|
7
|
1
|
9490
|
my($listing, $time_zone, $type, $error) = @_; |
17
|
|
|
|
|
|
|
|
18
|
7
|
100
|
|
0
|
|
52
|
$error = sub { warn shift } if (defined $error ? $error : '') eq 'warn'; |
|
0
|
50
|
|
|
|
0
|
|
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
|
|
16
|
my $next; |
21
|
7
|
100
|
|
|
|
60
|
if(ref($listing) eq 'ARRAY') |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
2
|
|
|
|
|
26
|
my @lines = @$listing; |
24
|
2
|
|
|
5
|
|
15
|
$next = sub { shift @lines }; |
|
5
|
|
|
|
|
20
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif(ref($listing) eq 'GLOB') |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
$next = sub { |
29
|
3
|
|
|
3
|
|
23
|
my $line = <$listing>; |
30
|
3
|
|
|
|
|
14
|
$line; |
31
|
1
|
|
|
|
|
18
|
}; |
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
|
|
24
|
my $line = <$listing>; |
41
|
3
|
|
|
|
|
12
|
$line; |
42
|
1
|
|
|
|
|
15
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else |
45
|
|
|
|
|
|
|
{ |
46
|
3
|
|
|
|
|
92
|
my @lines = split /\015?\012/, $listing; |
47
|
3
|
|
|
49
|
|
22
|
$next = sub { shift @lines }; |
|
49
|
|
|
|
|
134
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
7
|
|
|
|
|
17
|
my @answer; |
51
|
|
|
|
|
|
|
|
52
|
7
|
|
|
|
|
50
|
my $line = $next->(); |
53
|
7
|
|
|
|
|
29
|
while(defined $line) |
54
|
|
|
|
|
|
|
{ |
55
|
53
|
|
|
|
|
104
|
chomp $line; |
56
|
53
|
|
|
|
|
311
|
my $h = _parse_dir($line); |
57
|
53
|
100
|
|
|
|
127
|
if(defined $h) |
|
|
100
|
|
|
|
|
|
58
|
|
|
|
|
|
|
{ |
59
|
34
|
|
|
|
|
62
|
my $mtimetype = pop @$h; |
60
|
34
|
50
|
66
|
|
|
105
|
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
|
|
|
|
66
|
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
|
|
|
|
|
172
|
$h->[3] = timelocal(gmtime($h->[3])); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
34
|
|
|
|
|
2120
|
push @answer, $h; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
elsif(defined $error) |
86
|
|
|
|
|
|
|
{ |
87
|
1
|
|
|
|
|
3
|
$error->($line) |
88
|
|
|
|
|
|
|
} |
89
|
53
|
|
|
|
|
100
|
$line = $next->(); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
7
|
100
|
|
|
|
72
|
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
|
|
12154
|
my $name; |
126
|
27
|
|
|
|
|
44
|
our $AUTOLOAD; |
127
|
27
|
|
|
|
|
167
|
($name = $AUTOLOAD) =~ s/.*:://; |
128
|
27
|
50
|
|
|
|
97
|
croak "$AUTOLOAD not defined" if $name eq '_constant'; |
129
|
27
|
|
|
|
|
128
|
my $val = _constant($name); |
130
|
27
|
50
|
|
|
|
67
|
croak "$AUTOLOAD not defined" if $val == -1; |
131
|
27
|
|
|
|
|
41
|
do { |
132
|
11
|
|
|
11
|
|
97
|
no strict 'refs'; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
1030
|
|
133
|
27
|
|
|
85
|
|
227
|
*$AUTOLOAD = sub { $val }; |
|
85
|
|
|
|
|
297
|
|
134
|
|
|
|
|
|
|
}; |
135
|
27
|
|
|
|
|
111
|
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__ |