Staging
v0.5.1
Revision 6c2f207b2316149ee8dfaf026e4a869ff9ab42f7 authored by Shawn O. Pearce on 05 November 2006, 05:37:23 UTC, committed by Junio C Hamano on 05 November 2006, 07:48:36 UTC
At least one older version of the Solaris C compiler doesn't support
the newer C99 style struct initializers.  To allow Git to compile
on those systems use an archive description struct which is easier
to initialize without the C99 struct initializer syntax.

Also since the archives array is not used by anyone other than
archive.c we can make it static.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent af8ffbe
Raw File
copy.c
#include "cache.h"

int copy_fd(int ifd, int ofd)
{
	while (1) {
		int len;
		char buffer[8192];
		char *buf = buffer;
		len = xread(ifd, buffer, sizeof(buffer));
		if (!len)
			break;
		if (len < 0) {
			int read_error;
			read_error = errno;
			close(ifd);
			return error("copy-fd: read returned %s",
				     strerror(read_error));
		}
		while (len) {
			int written = xwrite(ofd, buf, len);
			if (written > 0) {
				buf += written;
				len -= written;
			}
			else if (!written) {
				close(ifd);
				return error("copy-fd: write returned 0");
			} else {
				close(ifd);
				return error("copy-fd: write returned %s",
					     strerror(errno));
			}
		}
	}
	close(ifd);
	return 0;
}

back to top