FreeBSD/usr.sbin/kgzip/xio.c
/*
 * Copy bytes from one file to another.
 */
Copy bytes from one file to another.
Copy bytes from one file to another .
void
xcopy(const struct iodesc * idi, const struct iodesc * ido,
      size_t nbyte, off_t offset)
{
    char buf[8192];
    size_t n;
    while (nbyte) {
	if ((n = sizeof(buf)) > nbyte)
	    n = nbyte;
	if (xread(idi, buf, n, offset) != n)
	    errx(1, "%s: Short read", idi->fname);
	xwrite(ido, buf, n);
	nbyte -= n;
	offset = -1;
    }
}
void xcopy ( const struct iodesc * idi , const struct iodesc * ido , size_t nbyte , off_t offset ) { char buf [ 8192 ] ; size_t n ; while ( nbyte ) { if ( ( n = sizeof ( buf ) ) > nbyte ) n = nbyte ; if ( xread ( idi , buf , n , offset ) != n ) errx ( 1 , " " , idi -> fname ) ; xwrite ( ido , buf , n ) ; nbyte -= n ; offset = -1 ; } }
Copy bytes from one file to another.
Copy bytes from one file to another .