From 311e08db8673dca149763dc8804c9f05aae63fc2 Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Fri, 25 Aug 2000 04:38:43 +0000 Subject: [PATCH] Fixed file copy loop to work for binary files. git-svn-id: svn://10.0.0.236/trunk@77171 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/config/make-jars.pl | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mozilla/config/make-jars.pl b/mozilla/config/make-jars.pl index 5e0d62dc353..915c72d8f17 100644 --- a/mozilla/config/make-jars.pl +++ b/mozilla/config/make-jars.pl @@ -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 () { - 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': $!";