当前位置: 首页>>代码示例>>C++>>正文


C++ FS_FOpenFileWrite函数代码示例

本文整理汇总了C++中FS_FOpenFileWrite函数的典型用法代码示例。如果您正苦于以下问题:C++ FS_FOpenFileWrite函数的具体用法?C++ FS_FOpenFileWrite怎么用?C++ FS_FOpenFileWrite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FS_FOpenFileWrite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Com_InitJournaling

/*
=================
Com_InitJournaling
=================
*/
void Com_InitJournaling( void ) {
	Com_StartupVariable( "journal" );
	com_journal = Cvar_Get ("journal", "0", CVAR_INIT);
	if ( !com_journal->integer ) {
		return;
	}

	if ( com_journal->integer == 1 ) {
		Com_Printf( "Journaling events\n");
		com_journalFile = FS_FOpenFileWrite( "journal.dat" );
		com_journalDataFile = FS_FOpenFileWrite( "journaldata.dat" );
	} else if ( com_journal->integer == 2 ) {
		Com_Printf( "Replaying journaled events\n");
		FS_FOpenFileRead( "journal.dat", &com_journalFile, qtrue );
		FS_FOpenFileRead( "journaldata.dat", &com_journalDataFile, qtrue );
	}

   	if ( !com_journalFile || !com_journalDataFile ) {
		Cvar_Set( "com_journal", "0" );
		com_journalFile = 0;
		com_journalDataFile = 0;
		Com_Printf( "Couldn't open journal files\n" );
	}

}
开发者ID:LTolosa,项目名称:Jedi-Outcast,代码行数:30,代码来源:common.cpp

示例2: LAN_SaveServersToFile

/**
 * @brief LAN_SaveServersToFile
 */
void LAN_SaveServersToFile(void)
{
    int32_t      size;
    fileHandle_t fileOut;
    char         filename[MAX_QPATH];

    if (cl_profile->string[0])
    {
        Com_sprintf(filename, sizeof(filename), "profiles/%s/favcache.dat", cl_profile->string);
    }
    else
    {
        Q_strncpyz(filename, "favcache.dat", sizeof(filename));
    }

    // moved to mod/profiles dir
    fileOut = FS_FOpenFileWrite(filename); // FIXME: catch error
    (void) FS_Write(&cls.numfavoriteservers, sizeof(int32_t), fileOut);

    size = sizeof(cls.favoriteServers);

    (void) FS_Write(&size, sizeof(int32_t), fileOut);
    (void) FS_Write(&cls.favoriteServers, sizeof(cls.favoriteServers), fileOut);
    FS_FCloseFile(fileOut);

    Com_Printf("Total favourite servers saved: %i\n", cls.numfavoriteservers);
}
开发者ID:etlegacy,项目名称:etlegacy,代码行数:30,代码来源:cl_ui.c

示例3: FS_FOpenFileWrite

void idCameraDef::save(const char *filename)
{
	fileHandle_t file = FS_FOpenFileWrite(filename);

	if(file)
	{
		int i;
		idStr s = "cameraPathDef { \n";
		FS_Write(s.c_str(), s.length(), file);
		s = va("\ttime %f\n", baseTime);
		FS_Write(s.c_str(), s.length(), file);

		cameraPosition->write(file, va("camera_%s", cameraPosition->typeStr()));

		for(i = 0; i < numTargets(); i++)
		{
			targetPositions[i]->write(file, va("target_%s", targetPositions[i]->typeStr()));
		}

		for(i = 0; i < events.Num(); i++)
		{
			events[i]->write(file, "event");
		}

		fov.write(file, "fov");

		s = "}\n";
		FS_Write(s.c_str(), s.length(), file);
	}

	FS_FCloseFile(file);
}
开发者ID:Diskutant,项目名称:RTCW-SP,代码行数:32,代码来源:splines.cpp

示例4: CL_DumpMapReferences

/*
====================
CL_DumpMapReferences

Called after a map has loaded, dumps all the files loaded by the map to a .ref file
====================
*/
void Q_EXTERNAL_CALL CL_DumpMapReferences( ) {
	if ( cl.mapname && cl.mapname[0] )
	{
		fileHandle_t refFile;
		char refname[MAX_QPATH], gamedir[MAX_QPATH], *homedir, *textures, *sounds;
		
		Q_strncpyz( gamedir, Cvar_VariableString( "fs_game" ), MAX_QPATH);
		homedir = Cvar_VariableString( "fs_homepath" );
		if (!gamedir || !gamedir[0] ) Q_strncpyz( gamedir, BASEGAME, MAX_QPATH );
		
		COM_StripExtension(cl.mapname, refname, MAX_QPATH);
		Com_sprintf(refname, MAX_QPATH, "%s/%s%s",gamedir, refname, ".ref"); 
		textures = (char*)re.DumpGetImagesString("textures = [", "]\n", "\t\"%s\",\n");
		sounds = S_DumpGetSoundString("sounds = [", "]\n", "\t\"%s\",\n");

		refFile = FS_FOpenFileWrite(refname);
		if (refFile)
		{
			FS_Write( textures, strlen( textures ), refFile );
			FS_Write( sounds, strlen( sounds ), refFile );
			FS_FCloseFile( refFile );
			Com_sprintf(refname, MAX_QPATH, "%s/%s",homedir, refname); 
			Com_Printf("Wrote %s reference file to %s\n", cl.mapname, refname );
		}
		Z_Free((void*)textures);
		Z_Free(sounds);
	}
}
开发者ID:ballju,项目名称:SpaceTrader-GPL-1.1.14,代码行数:35,代码来源:cl_cgame.c

示例5: LAN_SaveServersToCache

/*
====================
LAN_SaveServersToCache
====================
*/
void LAN_SaveServersToCache()
{
	int             size;
	fileHandle_t    fileOut;
	char            filename[MAX_QPATH];

	if(com_gameInfo.usesProfiles && cl_profile->string[0])
	{
		Com_sprintf(filename, sizeof(filename), "profiles/%s/servercache.dat", cl_profile->string);
	}
	else
	{
		Q_strncpyz(filename, "servercache.dat", sizeof(filename));
	}

	// Arnout: moved to mod/profiles dir
	//fileOut = FS_SV_FOpenFileWrite(filename);
	fileOut = FS_FOpenFileWrite(filename);
	FS_Write(&cls.numglobalservers, sizeof(int), fileOut);
	FS_Write(&cls.numfavoriteservers, sizeof(int), fileOut);
	size = sizeof(cls.globalServers) + sizeof(cls.favoriteServers);
	FS_Write(&size, sizeof(int), fileOut);
	FS_Write(&cls.globalServers, sizeof(cls.globalServers), fileOut);
	FS_Write(&cls.favoriteServers, sizeof(cls.favoriteServers), fileOut);
	FS_FCloseFile(fileOut);
}
开发者ID:TheDushan,项目名称:OpenWolf,代码行数:31,代码来源:cl_ui.cpp

示例6: Sys_WritePIDFile

qboolean Sys_WritePIDFile(void)
{
	fileHandle_t f;

	// First, check if the pid file is already there
	if (FS_FileInPathExists(com_pidfile->string))
	{
		// TODO: check if we are hijacking live pid file
		/*
		FS_FOpenFileRead(com_pidfile->string, &f, qtrue);

		if(Sys_PIDIsRunning(pid))
		{
		    Com_Printf("WARNING: another instance of ET:L is using this path!\n");
		    return qfalse;
		}
		*/
		FS_Delete(com_pidfile->string); // stale pid from previous run
	}

	f = FS_FOpenFileWrite(com_pidfile->string);
	if (f < 0)
	{
		return qfalse;
	}

	FS_Printf(f, "%d", com_pid->integer);

	FS_FCloseFile(f);

	// track profile changes
	Com_TrackProfile(com_pidfile->string);

	return qtrue;
}
开发者ID:scenna,项目名称:etlegacy,代码行数:35,代码来源:sys_main.c

示例7: Com_PrintLogfile

void Com_PrintLogfile( const char *msg )
{

	Sys_EnterCriticalSection(5);

	if ( com_logfile && com_logfile->integer ) {
        // TTimo: only open the qconsole.log if the filesystem is in an initialized state
        // also, avoid recursing in the qconsole.log opening (i.e. if fs_debug is on)
	    if ( !logfile && FS_Initialized()) {
			struct tm *newtime;
			time_t aclock;

			time( &aclock );
			newtime = localtime( &aclock );

			logfile = FS_FOpenFileWrite( "qconsole.log" );

			if ( com_logfile->integer > 1 && logfile ) {
				// force it to not buffer so we get valid
				// data even if we are crashing
				FS_ForceFlush(logfile);
			}
			if ( logfile ) FS_Write(va("\nLogfile opened on %s\n", asctime( newtime )), strlen(va("\nLogfile opened on %s\n", asctime( newtime ))), logfile);
	    }
	    if ( logfile && FS_Initialized()) 
	    {
	    	FS_Write(msg, strlen(msg), logfile);
	    }
	}
	Sys_LeaveCriticalSection(5);
}
开发者ID:Call-of-Duty-Scripts,项目名称:CoD4X17a_testing,代码行数:31,代码来源:common_logprint.c

示例8: CON_Hist_Save

/*
==================
CON_Hist_Save
==================
*/
static void CON_Hist_Save( void ) {
	fileHandle_t f = FS_FOpenFileWrite("conhist.log");
	for (int i = hist_count - 1; i >= 0; i--) {
		FS_Write(ttyEditLines[i].buffer, ttyEditLines[i].cursor, f);
		FS_Write("\n", 1, f);
	}
	FS_FCloseFile(f);
}
开发者ID:cagelight,项目名称:jaownt,代码行数:13,代码来源:con_tty.cpp

示例9: SV_DelBanFromList

static void SV_DelBanFromList(qboolean isexception)
{
	int index, count, todel;
	fileHandle_t writeto;
	
	if(Cmd_Argc() != 2)
	{
		Com_Printf ("Usage: %s <num>\n", Cmd_Argv(0));
		return;
	}

	todel = atoi(Cmd_Argv(1));

	if(todel < 0 || todel > serverBansCount)
		return;
	
	for(index = count = 0; index < serverBansCount; index++)
	{
		if(serverBans[index].isexception == isexception)
		{
			count++;
			
			if(count == todel)
				break;
		}
	}
	
	if(index == serverBansCount - 1)
		serverBansCount--;
	else if(index < sizeof(serverBans) / sizeof(*serverBans) - 1)
	{
		memmove(serverBans + index, serverBans + index + 1, (serverBansCount - index - 1) * sizeof(*serverBans));
		serverBansCount--;
	}
	else
	{
		Com_Printf("Error: No such entry #%d\n", todel);
		return;
	}
	
	// Write out the ban information.
	if((writeto = FS_FOpenFileWrite(SERVER_BANFILE)))
	{
		char writebuf[128];
		serverBan_t *curban;
		
		for(index = 0; index < serverBansCount; index++)
		{
			curban = &serverBans[index];
			
			Com_sprintf(writebuf, sizeof(writebuf), "%d %s %d\n",
				    curban->isexception, NET_AdrToString(curban->ip), curban->subnet);
			FS_Write(writebuf, strlen(writebuf), writeto);
		}

		FS_FCloseFile(writeto);
	}
}
开发者ID:shawnd,项目名称:urt-bumpy-engine,代码行数:58,代码来源:sv_ccmds.c

示例10: BotSaveOffMeshConnections

void BotSaveOffMeshConnections( NavData_t *nav )
{
	char mapname[ MAX_QPATH ];
	char filePath[ MAX_QPATH ];
	fileHandle_t f = 0;

	Cvar_VariableStringBuffer( "mapname", mapname, sizeof( mapname ) );
	Com_sprintf( filePath, sizeof( filePath ), "maps/%s-%s.navcon", mapname, nav->name );
	f = FS_FOpenFileWrite( filePath );

	if ( !f )
	{
		return;
	}

	int conCount = nav->process.con.offMeshConCount;
	OffMeshConnectionHeader header;
	header.version = LittleLong( NAVMESHCON_VERSION );
	header.numConnections = LittleLong( conCount );
	FS_Write( &header, sizeof( header ), f );

	size_t size = sizeof( float ) * 6 * conCount;
	float *verts = ( float * ) dtAlloc( size, DT_ALLOC_TEMP );
	memcpy( verts, nav->process.con.verts, size );
	SwapArray( verts, conCount * 6 );
	FS_Write( verts, size, f );
	dtFree( verts );

	size = sizeof( float ) * conCount;
	float *rad = ( float * ) dtAlloc( size, DT_ALLOC_TEMP );
	memcpy( rad, nav->process.con.rad, size );
	SwapArray( rad, conCount );
	FS_Write( rad, size, f );
	dtFree( rad );

	size = sizeof( unsigned short ) * conCount;
	unsigned short *flags = ( unsigned short * ) dtAlloc( size, DT_ALLOC_TEMP );
	memcpy( flags, nav->process.con.flags, size );
	SwapArray( flags, conCount );
	FS_Write( flags, size, f );
	dtFree( flags );

	FS_Write( nav->process.con.areas, sizeof( unsigned char ) * conCount, f );
	FS_Write( nav->process.con.dirs, sizeof( unsigned char ) * conCount, f );

	size = sizeof( unsigned int ) * conCount;
	unsigned int *userids = ( unsigned int * ) dtAlloc( size, DT_ALLOC_TEMP );
	memcpy( userids, nav->process.con.userids, size );
	SwapArray( userids, conCount );
	FS_Write( userids, size, f );
	dtFree( userids );

	FS_FCloseFile( f );
}
开发者ID:Gireen,项目名称:Unvanquished,代码行数:54,代码来源:bot_load.cpp

示例11: SV_RecordDemo

void SV_RecordDemo( client_t *cl, char *demoName ) {
	char		name[MAX_OSPATH];
	byte		bufData[MAX_MSGLEN];
	msg_t		msg;
	int			len;

	if ( cl->demo.demorecording ) {
		Com_Printf( "Already recording.\n" );
		return;
	}

	if ( cl->state != CS_ACTIVE ) {
		Com_Printf( "Client is not active.\n" );
		return;
	}

	// open the demo file
	Q_strncpyz( cl->demo.demoName, demoName, sizeof( cl->demo.demoName ) );
	Com_sprintf( name, sizeof( name ), "demos/%s.dm_%d", cl->demo.demoName, PROTOCOL_VERSION );
	Com_Printf( "recording to %s.\n", name );
	cl->demo.demofile = FS_FOpenFileWrite( name );
	if ( !cl->demo.demofile ) {
		Com_Printf ("ERROR: couldn't open.\n");
		return;
	}
	cl->demo.demorecording = qtrue;

	// don't start saving messages until a non-delta compressed message is received
	cl->demo.demowaiting = qtrue;

	cl->demo.isBot = ( cl->netchan.remoteAddress.type == NA_BOT ) ? qtrue : qfalse;
	cl->demo.botReliableAcknowledge = cl->reliableSent;

	// write out the gamestate message
	MSG_Init( &msg, bufData, sizeof( bufData ) );

	// NOTE, MRE: all server->client messages now acknowledge
	int tmp = cl->reliableSent;
	SV_CreateClientGameStateMessage( cl, &msg );
	cl->reliableSent = tmp;

	// finished writing the client packet
	MSG_WriteByte( &msg, svc_EOF );

	// write it to the demo file
	len = LittleLong( cl->netchan.outgoingSequence - 1 );
	FS_Write( &len, 4, cl->demo.demofile );

	len = LittleLong( msg.cursize );
	FS_Write( &len, 4, cl->demo.demofile );
	FS_Write( msg.data, msg.cursize, cl->demo.demofile );

	// the rest of the demo file will be copied from net messages
}
开发者ID:adnanfzafar,项目名称:OpenJK,代码行数:54,代码来源:sv_ccmds.cpp

示例12: SV_FlushBans_f

static void SV_FlushBans_f(void)
{
	fileHandle_t blankf;
	
	serverBansCount = 0;
	
	// empty the ban file.
	blankf = FS_FOpenFileWrite(SERVER_BANFILE);
	
	if(blankf)
		FS_FCloseFile(blankf);
}
开发者ID:shawnd,项目名称:urt-bumpy-engine,代码行数:12,代码来源:sv_ccmds.c

示例13: Con_Dump_f

/*
================
Con_Dump_f

Save the console contents out to a file
================
*/
void Con_Dump_f( void )
{
	int          l;
	fileHandle_t f;
	char         name[ MAX_STRING_CHARS ];

	l = Cmd_Argc();

	if ( l > 2 )
	{
		Cmd_PrintUsage(_("[<filename>]"), NULL);
		return;
	}

	if ( l == 1 )
	{
		time_t now = time( NULL );
		strftime( name, sizeof( name ), "condump/%Y%m%d-%H%M%S%z.txt",
		          localtime( &now ) );
	}
	else
	{
		Q_snprintf( name, sizeof( name ), "condump/%s", Cmd_Argv( 1 ) );
	}

	f = FS_FOpenFileWrite( name );

	if ( !f )
	{
		Com_Log(LOG_ERROR, _( "couldn't open." ));
		return;
	}

	Com_Printf(_( "Dumped console text to %s.\n"), name );

	// skip empty lines
	for ( l = consoleState.currentLine - consoleState.maxScrollbackLengthInLines + 1; l <= consoleState.currentLine; l++ )
	{
		if ( consoleState.text[ CON_LINE( l ) ].ch )
		{
			break;
		}
	}

	// write the remaining lines
	for ( ; l <= consoleState.currentLine; l++ )
	{
		const char *buffer = Con_LineToString( l, qtrue );
		FS_Write( buffer, strlen( buffer ), f );
	}

	FS_FCloseFile( f );
}
开发者ID:TWal,项目名称:Unvanquished,代码行数:60,代码来源:cl_console.cpp

示例14: Com_WriteConfigToFile

void Com_WriteConfigToFile( const char *filename ) {
	fileHandle_t	f;

	f = FS_FOpenFileWrite( filename );
	if ( !f ) {
		Com_Printf ("Couldn't write %s.\n", filename );
		return;
	}

	FS_Printf (f, "// generated by OpenJK SP, do not modify\n");
	Key_WriteBindings (f);
	Cvar_WriteVariables (f);
	FS_FCloseFile( f );
}
开发者ID:Aura15,项目名称:OpenJK,代码行数:14,代码来源:common.cpp

示例15: Com_PrintfAlways

void QDECL Com_PrintfAlways( const char *fmt, ... ) {
	va_list		argptr;
	char		msg[MAXPRINTMSG];

	va_start (argptr,fmt);
	vsprintf (msg,fmt,argptr);
	va_end (argptr);

#ifndef _XBOX
	if ( rd_buffer ) {
		if ((strlen (msg) + strlen(rd_buffer)) > (rd_buffersize - 1)) {
			rd_flush(rd_buffer);
			*rd_buffer = 0;
		}
		strcat (rd_buffer, msg);
		return;
	}
#endif

	CL_ConsolePrint( msg );

	// echo to dedicated console and early console
#ifndef FINAL_BUILD
	Sys_Print( msg );

#ifdef OUTPUT_TO_BUILD_WINDOW
	OutputDebugString(msg);
#endif
#endif

#ifndef _XBOX
	// logfile
	if ( com_logfile && com_logfile->integer ) {
		if ( !logfile ) {
			logfile = FS_FOpenFileWrite( "qconsole.log" );
			if ( com_logfile->integer > 1 ) {
				// force it to not buffer so we get valid
				// data even if we are crashing
				FS_ForceFlush(logfile);
			}
		}
		if ( logfile ) {
			FS_Write(msg, strlen(msg), logfile);
		}
	}
#endif
}
开发者ID:Drakesinger,项目名称:jediacademypc,代码行数:47,代码来源:common.cpp


注:本文中的FS_FOpenFileWrite函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。