line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::FTP::blat; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
88133
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
71
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
764
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = 0.03; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub Net::FTP::slurp |
13
|
|
|
|
|
|
|
# store a remote file to a scalar |
14
|
|
|
|
|
|
|
# syntax: $ftpobj->slurp($remote_file_name [, $lvalue ] ) |
15
|
|
|
|
|
|
|
{ |
16
|
0
|
|
|
0
|
0
|
|
my($ftp,$remote) = @_[0,1]; |
17
|
0
|
0
|
|
|
|
|
my $target = ( exists($_[2])? \$_[2] : \(my $foo)); |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my($len,$buf,$resp,$data); |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
croak("Bad remote filename '$remote'\n") |
22
|
|
|
|
|
|
|
if $remote =~ /[\r\n]/s; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
delete ${*$ftp}{'net_ftp_port'}; |
|
0
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
delete ${*$ftp}{'net_ftp_pasv'}; |
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
unless( $data = $ftp->retr($remote)){ |
28
|
0
|
0
|
|
|
|
|
$^W and carp "could not retr [$remote]"; |
29
|
0
|
|
|
|
|
|
$$target=undef; |
30
|
0
|
|
|
|
|
|
return undef; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$buf = ''; |
34
|
0
|
|
|
|
|
|
my($count) = (0); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $blksize = ${*$ftp}{'net_ftp_blksize'}; |
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
local $\; # Just in case |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my @pieces = (); |
40
|
0
|
|
|
|
|
|
while( |
41
|
|
|
|
|
|
|
$data->read($buf,$blksize) |
42
|
|
|
|
|
|
|
){ |
43
|
0
|
|
|
|
|
|
push @pieces, $buf; |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$data->close(); # implied $ftp->response |
47
|
0
|
0
|
|
|
|
|
if (defined(wantarray)){ |
48
|
0
|
|
|
|
|
|
$$target = my $result = join('',@pieces); |
49
|
0
|
|
|
|
|
|
return $result |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$$target = join('',@pieces); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub Net::FTP::blat |
57
|
|
|
|
|
|
|
# STOR a scalar to a remote file |
58
|
|
|
|
|
|
|
# syntax: $ftpobj->blat($value,$remote) |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
0
|
|
my($ftp,$remote) = @_[0,2]; |
61
|
0
|
|
|
|
|
|
my $value = \$_[1]; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my($sock,$len,$buf); |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
unless(defined $remote) |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
|
|
|
|
croak 'Must specify remote filename with stream input'; |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# ALLO |
71
|
0
|
|
|
|
|
|
$ftp->_ALLO( length $$value); |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
croak("Bad remote filename '$remote'\n") |
74
|
|
|
|
|
|
|
if $remote =~ /[\r\n]/s; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
delete ${*$ftp}{'net_ftp_port'}; |
|
0
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
delete ${*$ftp}{'net_ftp_pasv'}; |
|
0
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
$sock = $ftp->_data_cmd('STOR', $remote) or |
80
|
|
|
|
|
|
|
croak "failure of STOR [$remote] data_cmd"; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
#chunking really only makes sense when we're reading |
84
|
|
|
|
|
|
|
#from disk and sending. Since we're sending a scalar, |
85
|
|
|
|
|
|
|
#we can avoid multiple substr calls , each of which |
86
|
|
|
|
|
|
|
#will need to do a full FETCH on a tied scalar, and just |
87
|
|
|
|
|
|
|
#write the whole thing at once. |
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
# my $blksize = ${*$ftp}{'net_ftp_blksize'}; |
90
|
|
|
|
|
|
|
# |
91
|
|
|
|
|
|
|
# my($pos) = (0); |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# while( |
94
|
|
|
|
|
|
|
# $len = length ( $buf = substr ( $$value, $pos, $blksize)) |
95
|
|
|
|
|
|
|
# ){ |
96
|
|
|
|
|
|
|
# |
97
|
|
|
|
|
|
|
# my $wlen; |
98
|
|
|
|
|
|
|
# unless(defined($wlen = $sock->write($buf,$len)) && $wlen == $len) |
99
|
|
|
|
|
|
|
# { |
100
|
|
|
|
|
|
|
# $sock->abort; |
101
|
|
|
|
|
|
|
# croak "only wrote $wlen of $len data to FTP data channel at [$remote]:$pos\n"; |
102
|
|
|
|
|
|
|
# } |
103
|
|
|
|
|
|
|
# $pos += $len; |
104
|
|
|
|
|
|
|
# } |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$len = length $$value; |
107
|
0
|
|
|
|
|
|
my $wlen; |
108
|
0
|
0
|
0
|
|
|
|
unless(defined($wlen = $sock->write($$value,$len)) |
109
|
|
|
|
|
|
|
&& $wlen == $len) |
110
|
|
|
|
|
|
|
{ |
111
|
0
|
|
|
|
|
|
$sock->abort; |
112
|
0
|
|
|
|
|
|
croak "only wrote $wlen of $len data to FTP data channel at [$remote] "; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$sock->close(); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$$value; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |