Fixed file copy loop to work for binary files.
git-svn-id: svn://10.0.0.236/trunk@77171 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
3f71c910bb
commit
311e08db86
@ -31,7 +31,7 @@ sub Cleanup
|
||||
sub JarIt
|
||||
{
|
||||
my ($jarfile, $args) = @_;
|
||||
system "zip -u $jarfile $args\n";
|
||||
system "zip -u $jarfile $args\n" || die "zip failed";
|
||||
my $cwd = cwd();
|
||||
print "+++ jarred $cwd => $jarfile\n";
|
||||
Cleanup();
|
||||
@ -72,8 +72,22 @@ sub CopyFile
|
||||
#print "copying $from to $to\n";
|
||||
open(OUT, ">$to") || die "error: can't open '$to': $!";
|
||||
open(IN, "<$from") || die "error: can't open '$from': $!";
|
||||
while (<IN>) {
|
||||
print OUT $_;
|
||||
binmode IN;
|
||||
binmode OUT;
|
||||
my $len;
|
||||
my $buf;
|
||||
while ($len = sysread(IN, $buf, 4096)) {
|
||||
if (!defined $len) {
|
||||
next if $! =~ /^Interrupted/;
|
||||
die "System read error: $!\n";
|
||||
}
|
||||
my $offset = 0;
|
||||
while ($len) {
|
||||
my $written = syswrite(OUT, $buf, $len, $offset);
|
||||
die "System write error: $!\n" unless defined $written;
|
||||
$len -= $written;
|
||||
$offset += $written;
|
||||
}
|
||||
}
|
||||
close(IN) || die "error: can't close '$from': $!";
|
||||
close(OUT) || die "error: can't close '$to': $!";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user