| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1724
|
use HTTP::Headers::UserAgent; |
|
|
1
|
|
|
|
|
21951
|
|
|
|
1
|
|
|
|
|
79
|
|
|
5
|
1
|
|
|
1
|
|
11
|
use File::Basename; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
118
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
664
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$HTTP::File::VERSION = '4.0'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package HTTP::File; |
|
12
|
|
|
|
|
|
|
sub platform { |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
|
|
0
|
1
|
|
my $__platform; |
|
15
|
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
$__platform = HTTP::Headers::UserAgent::GetPlatform ($ENV{HTTP_USER_AGENT}); |
|
17
|
0
|
0
|
|
|
|
|
$__platform =~ /^Win/ && return 'MSWin32'; |
|
18
|
0
|
0
|
|
|
|
|
$__platform =~ /^MAC/ && return 'MacOS'; |
|
19
|
0
|
0
|
|
|
|
|
$__platform =~ /x$/ && return ''; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# wifd == warn if debug |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
0
|
0
|
|
sub wifd { warn "HTTP::File --- $_[0]" if $_[1]; } |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub upload { |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
1
|
|
my ($raw_file, $path,$debug,$kludge) = @_; |
|
31
|
0
|
|
|
|
|
|
my $temp_dir = '/tmp'; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
$path = $path ? $path : $temp_dir; |
|
34
|
0
|
|
|
|
|
|
my $platform = platform; |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
wifd "raw_file \t $raw_file" , $debug; |
|
37
|
0
|
|
|
|
|
|
wifd "path \t $path" , $debug; |
|
38
|
0
|
|
|
|
|
|
wifd "platform \t $platform" , $debug; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
File::Basename::fileparse_set_fstype(platform); |
|
41
|
0
|
|
|
|
|
|
my ($basename,$junk,$junk2) = File::Basename::fileparse $raw_file; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
wifd(sprintf("ref(raw_file) \t %s", ref($raw_file)) , $debug); |
|
44
|
0
|
|
|
|
|
|
wifd "raw_file \t $raw_file" , $debug; |
|
45
|
0
|
|
|
|
|
|
wifd "path \t $path" , $debug; |
|
46
|
0
|
|
|
|
|
|
wifd "platform \t $platform" , $debug; |
|
47
|
0
|
|
|
|
|
|
wifd "basename \t $basename" , $debug; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if ($path =~ m/^(.*)$/) { $path = $1; } |
|
|
0
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ($basename =~ m/^(.*)$/) { $basename = $1; } |
|
|
0
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
0
|
|
|
|
open O, ">$path/$basename" || die $!; |
|
53
|
|
|
|
|
|
|
# If the input file is binary, the output file should also be binary |
|
54
|
0
|
0
|
|
|
|
|
binmode O if (-B $raw_file); |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
0
|
0
|
|
|
|
(open K, ">$temp_dir/$basename" || die $!) if $kludge; |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
0
|
|
|
|
|
|
my $buffer; |
|
|
0
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $bytesread = read($raw_file,$buffer,1024); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# let's exit with an error if read() returned undef |
|
62
|
0
|
0
|
|
|
|
|
die "error with file read: $!" if !defined($bytesread); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# let's exit with an error if print() did not return true |
|
65
|
0
|
0
|
|
|
|
|
die "error with print: $!" unless (print O $buffer); |
|
66
|
0
|
0
|
|
|
|
|
if ($kludge) { |
|
67
|
0
|
0
|
|
|
|
|
die "error with print: $!" unless (print K $buffer); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# let's redo the loop if we read > 0 chars on the last read |
|
71
|
0
|
0
|
|
|
|
|
redo unless !$bytesread; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
|
74
|
0
|
|
|
|
|
|
close O; |
|
75
|
0
|
0
|
|
|
|
|
close K if $kludge; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $basename; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
|
85
|
|
|
|
|
|
|
|