rem: int	src, dest; int	n; char	*tmp; char	buf[BUFSIZE];
add: int    src, dest; int    n; char    *tmp; char    buf[BUFSIZE];  if ((src = open(imageSrcFile, O_RDONLY)) < 0) { wsyserror("Could not open %s", imageSrcFile); return -1; }  tmp = wstrappend(toPath, imageDestFile); if ((dest = open( tmp, O_RDWR|O_CREAT, S_IRWXU|S_IRGRP|S_IROTH)) < 0) { wsyserror("Could not create %s", tmp); free(tmp); return -1; } free(tmp);    while ((n = read(src, buf, BUFSIZE)) > 0) { if (write(dest, buf, n) != n)    { wsyserror("Write error on file %s", imageDestFile); return -1; } }
context: fetchImageFile(char *toPath, char *imageSrcFile, char *imageDestFile){	int	src, dest;	int	n;	char	*tmp;	char	buf[BUFSIZE];	if ((src = open(imageSrcFile, O_RDONLY)) == 0) {		wwarning("Could not open %s", imageSrcFile);		return -1;	}	tmp = wstrappend(toPath, imageDestFile);	if ((dest = open( tmp, O_RDWR|O_CREAT, S_IRWXU|S_IRGRP|S_IROTH)) == 0) {		wwarning("Could not create %s", tmp);		free(tmp);		return -1;	}	free(tmp);	/* Copy the file */	while ((n = read(src, buf, BUFSIZE)) > 0)	{		if (write (dest, buf, n) != n)	{			wwarning("Write error on file %s", imageDestFile);			return -1;		}	}	return 0;}