Source/ThunderBeast/QuakeToonProto1/client/cl_parse.c
qboolean	CL_CheckOrDownloadFile (char *filename)
{
	FILE *fp;
	char	name[MAX_OSPATH];

	if (strstr (filename, ".."))
	{
		Com_Printf ("Refusing to download a path with ..\n");
		return true;
	}

	if (FS_LoadFile (filename, NULL) != -1)
	{	// it exists, no need to download
		return true;
	}

	strcpy (cls.downloadname, filename);

	// download to a temp name, and only rename
	// to the real name when done, so if interrupted
	// a runt file wont be left
	COM_StripExtension (cls.downloadname, cls.downloadtempname);
	strcat (cls.downloadtempname, ".tmp");

//ZOID
	// check to see if we already have a tmp for this file, if so, try to resume
	// open the file if not opened yet
	CL_DownloadFileName(name, sizeof(name), cls.downloadtempname);

//	FS_CreatePath (name);

	fp = fopen (name, "r+b");
	if (fp) { // it exists
		int len;
		fseek(fp, 0, SEEK_END);
		len = ftell(fp);

		cls.download = fp;

		// give the server an offset to start the download
		Com_Printf ("Resuming %s\n", cls.downloadname);
		MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
		MSG_WriteString (&cls.netchan.message,
			va("download %s %i", cls.downloadname, len));
	} else {
		Com_Printf ("Downloading %s\n", cls.downloadname);
		MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
		MSG_WriteString (&cls.netchan.message,
			va("download %s", cls.downloadname));
	}

	cls.downloadnumber++;

	return false;
}
/*
===============
CL_CheckOrDownloadFile

Returns true if the file exists, otherwise it attempts
to start a download from the server.
===============
*/
CL_CheckOrDownloadFile
Returns true if the file exists, otherwise it attempts
to start a download from the server.
CL_CheckOrDownloadFile Returns true if the file exists otherwise it attempts to start a download from the server .
qboolean	CL_CheckOrDownloadFile (char *filename)
{
	FILE *fp;
	char	name[MAX_OSPATH];
	if (strstr (filename, ".."))
	{
		Com_Printf ("Refusing to download a path with ..\n");
		return true;
	}
	if (FS_LoadFile (filename, NULL) != -1)
	{	
		return true;
	}
	strcpy (cls.downloadname, filename);
	COM_StripExtension (cls.downloadname, cls.downloadtempname);
	strcat (cls.downloadtempname, ".tmp");
	CL_DownloadFileName(name, sizeof(name), cls.downloadtempname);
	fp = fopen (name, "r+b");
	if (fp) { 
		int len;
		fseek(fp, 0, SEEK_END);
		len = ftell(fp);
		cls.download = fp;
		Com_Printf ("Resuming %s\n", cls.downloadname);
		MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
		MSG_WriteString (&cls.netchan.message,
			va("download %s %i", cls.downloadname, len));
	} else {
		Com_Printf ("Downloading %s\n", cls.downloadname);
		MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
		MSG_WriteString (&cls.netchan.message,
			va("download %s", cls.downloadname));
	}
	cls.downloadnumber++;
	return false;
}
qboolean CL_CheckOrDownloadFile ( char * filename ) { FILE * fp ; char name [ MAX_OSPATH ] ; if ( strstr ( filename , " " ) ) { Com_Printf ( " \n " ) ; return true ; } if ( FS_LoadFile ( filename , NULL ) != -1 ) { return true ; } strcpy ( cls . downloadname , filename ) ; COM_StripExtension ( cls . downloadname , cls . downloadtempname ) ; strcat ( cls . downloadtempname , " " ) ; CL_DownloadFileName ( name , sizeof ( name ) , cls . downloadtempname ) ; fp = fopen ( name , " " ) ; if ( fp ) { int len ; fseek ( fp , 0 , SEEK_END ) ; len = ftell ( fp ) ; cls . download = fp ; Com_Printf ( " \n " , cls . downloadname ) ; MSG_WriteByte ( & cls . netchan . message , clc_stringcmd ) ; MSG_WriteString ( & cls . netchan . message , va ( " " , cls . downloadname , len ) ) ; } else { Com_Printf ( " \n " , cls . downloadname ) ; MSG_WriteByte ( & cls . netchan . message , clc_stringcmd ) ; MSG_WriteString ( & cls . netchan . message , va ( " " , cls . downloadname ) ) ; } cls . downloadnumber ++ ; return false ; }
CL_CheckOrDownloadFile
Returns true if the file exists, otherwise it attempts
to start a download from the server.
CL_CheckOrDownloadFile Returns true if the file exists otherwise it attempts to start a download from the server .
// it exists, no need to download // download to a temp name, and only rename // to the real name when done, so if interrupted // a runt file wont be left //ZOID // check to see if we already have a tmp for this file, if so, try to resume // open the file if not opened yet //	FS_CreatePath (name); // it exists // give the server an offset to start the download