{
static int CrudeFileCopy(const char* in, const char* out)//----------------------------------------------------------------------------------------{	struct stat in_stat;	int stat_result = -1;	char	buf [1024];	FILE	*ifp, *ofp;	int	rbytes, wbytes;	if (!in || !out)		return -1;	stat_result = stat (in, &in_stat);	ifp = fopen (in, "r");	if (!ifp) 	{		return -1;	}	ofp = fopen (out, "w");	if (!ofp)	{		fclose (ifp);		return -1;	}	while ((rbytes = fread (buf, 1, sizeof(buf), ifp)) > 0)	{		while (rbytes > 0)		{			if ( (wbytes = fwrite (buf, 1, rbytes, ofp)) < 0 )			{				fclose (ofp);				fclose (ifp);				unlink(out);				return -1;			}			rbytes -= wbytes;		}	}	fclose (ofp);	fclose (ifp);	if (stat_result == 0)		{		chmod (out, in_stat.st_mode & 0777);		}	return 0;} // nsFileSpec::Rename