void GScr_FS_Remove(){ if(Scr_GetNumParam() != 1) Scr_Error("Usage: FS_Delete(<filename>)\n"); char* qpath = Scr_GetString(0); if(!Scr_FS_AlreadyOpened(qpath)) { Scr_Error("FS_Remove: Tried to delete an opened file!\n"); Scr_AddBool(qfalse); return; } if(FS_HomeRemove(qpath)) { Scr_AddBool(qtrue); }else{ Scr_AddBool(qfalse); } }
/* ==================== CL_StopRecording_f stoprecord <slot> stop recording a demo ==================== */ void CL_StopRecord( client_t *cl ) { int len; int clientnum; clientnum = cl - svs.clients; fileHandle_t demofile; char *demoname; if ( !cl->demorecording ) { Com_Printf ("Not recording a demo for client %i.\n", clientnum); return; } // remember handle and name demofile = cl->demofile; demoname = cl->demoName; cl->demorecording = qfalse; // finish up len = -1; FS_Write (&len, 4, demofile); FS_Write (&len, 4, demofile); FS_FCloseFile (demofile); if (!sv_autorecord->integer) { Com_Printf ("Stopped demo for client %i.\n", clientnum); } else { if (cl->savedemo) { // keep demo Com_Printf ("Stoprecord: %i: stop\n", clientnum); // SV_SendServerCommand(NULL, "print \"%s^7's game was recorded as ^2http:/ /bb.game-host.org/oa/^3%s\n\"", cl->name, demoname);// } else { Com_Printf ("Stoprecord: %i: abort\n", clientnum); FS_HomeRemove(demoname); } } }
void DL_End( CURLcode res, CURLMcode resm ) { CURLMsg *msg; int msgs; if( dl_verbose->integer == 0 && dl_showprogress->integer == 2 && !curlm ) Com_Printf( "\n" ); if( curlm ) { // res = final download result while( ( msg = curl_multi_info_read( curlm, &msgs ) ) ) { if( msg->msg != CURLMSG_DONE ) { if( dl_error[0] == '\0' ) Q_strncpyz( dl_error, "Download Interrupted.", sizeof(dl_error) ); } else if( msg->easy_handle == curl ) { if( msg->data.result != CURLE_OK ); res = msg->data.result; } else { Com_Printf( "Invalid cURL handle.\n" ); } } curl_multi_cleanup( curlm ); curlm = NULL; } if( curl ) { curl_easy_cleanup( curl ); curl = NULL; } // get possible error messages if( !*dl_error && res != CURLE_OK ) Q_strncpyz( dl_error, curl_easy_strerror(res), sizeof(dl_error) ); if( !*dl_error && resm != CURLM_OK ) Q_strncpyz( dl_error, curl_multi_strerror(resm), sizeof(dl_error) ); if( !*dl_error && !f ) Q_strncpyz( dl_error, "File is not opened.", sizeof(dl_error) ); if (f) { FS_FCloseFile(f); f = 0; if (!*dl_error) { // download succeeded char dest[MAX_OSPATH]; Com_Printf("Download complete, restarting filesystem.\n"); Q_strncpyz(dest, path, strlen(path)-3); // -4 +1 for the trailing \0 Q_strcat(dest, sizeof(dest), ".pk3"); if (!FS_FileExists(dest)) { FS_SV_Rename(path, dest); FS_Restart(clc.checksumFeed); if (dl_showmotd->integer && *motd) { Com_Printf("Server motd: %s\n", motd); } } else { // normally such errors should be caught upon starting the transfer. Anyway better do // it here again - the filesystem might have changed, plus this may help contain some // bugs / exploitable flaws in the code. Com_Printf("Failed to copy downloaded file to its location - file already exists.\n"); FS_HomeRemove(path); } } else { FS_HomeRemove(path); } } Cvar_Set( "cl_downloadName", "" ); // hide the ui downloading screen Cvar_SetValue( "cl_downloadSize", 0 ); Cvar_SetValue( "cl_downloadCount", 0 ); Cvar_SetValue( "cl_downloadTime", 0 ); Cvar_Set( "cl_downloadMotd", "" ); if( *dl_error ) { if( clc.state == CA_CONNECTED ) Com_Error( ERR_DROP, "%s\n", dl_error ); // download error while connecting, can not continue loading else Com_Printf( "%s\n", dl_error ); // download error while in game, do not disconnect *dl_error = '\0'; } else { if (strlen(Cvar_VariableString("cl_downloadDemo"))) { Cbuf_AddText( va("demo %s\n", Cvar_VariableString("cl_downloadDemo") ) ); // download completed, request new gamestate to check possible new map if we are not already in game } else if( clc.state == CA_CONNECTED) CL_AddReliableCommand( "donedl", qfalse); // get new gamestate info from server } }