https://github.com/git/git
Revision 281e67d6fa8e523147792c17fbe6db03f13f72e1 authored by Alan Chandler on 03 October 2006, 20:11:25 UTC, committed by Junio C Hamano on 04 October 2006, 06:58:38 UTC
Still not managed to understand git-send-mail sufficiently well to  not
accidently miss of this list when I sending it to Junio

Signed-off-by: Alan Chandler <alan@chandlerfamily.org.uk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 604cb21
Raw File
Tip revision: 281e67d6fa8e523147792c17fbe6db03f13f72e1 authored by Alan Chandler on 03 October 2006, 20:11:25 UTC
Fix usage string to match that given in the man page
Tip revision: 281e67d
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