39 |
use html; |
use html; |
40 |
our $static_pids; |
our $static_pids; |
41 |
|
|
42 |
|
use Time::HiRes qw/time/; |
43 |
|
|
44 |
sub static { |
sub static { |
45 |
my ($client,$path) = @_; |
my ($client,$path) = @_; |
46 |
|
|
48 |
|
|
49 |
return if ! -f $full; |
return if ! -f $full; |
50 |
|
|
51 |
|
my $start_t = time(); |
52 |
|
|
53 |
if ( my $pid = fork ) { |
if ( my $pid = fork ) { |
54 |
# parent |
# parent |
55 |
close($client); |
close($client); |
80 |
while( my $len = read $fh, $buff, $block ) { |
while( my $len = read $fh, $buff, $block ) { |
81 |
print $client $buff; |
print $client $buff; |
82 |
$pos += $len; |
$pos += $len; |
83 |
printf "%s %d/%d %.2f%%\r", $path, $pos, $size, $pos * 100 / $size; |
printf "%s %d/%d %.2f%% %.2f K/s\r" |
84 |
|
, $path, $pos |
85 |
|
, $size, $pos * 100 / $size |
86 |
|
, ( $pos / 1024 ) / ( time() - $start_t ) |
87 |
|
; |
88 |
} |
} |
89 |
close($fh); |
close($fh); |
90 |
close($client); |
close($client); |