• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FS_FOpenFile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: WriteCache

static void WriteCache( void ) {
    char buffer[MAX_OSPATH];
    qhandle_t f;
    int i;
    char *map, *pov;
    demoEntry_t *e;
    size_t len;

    if( m_demos.list.numItems == m_demos.numDirs ) {
        return;
    }

    len = Q_concat( buffer, sizeof( buffer ), m_demos.browse, "/" COM_DEMOCACHE_NAME, NULL );
    if( len >= sizeof( buffer ) ) {
        return;
    }
    FS_FOpenFile( buffer, &f, FS_MODE_WRITE );
    if( !f ) {
        return;
    }

    for( i = 0; i < 16; i++ ) {
        FS_FPrintf( f, "%02x", m_demos.hash[i] );
    }
    FS_FPrintf( f, "\\" );

    for( i = m_demos.numDirs; i < m_demos.list.numItems; i++ ) {
        e = m_demos.list.items[i];
        map = UI_GetColumn( e->name, COL_MAP );
        pov = UI_GetColumn( e->name, COL_POV );
        FS_FPrintf( f, "%s\\%s\\", map, pov );
    }
    FS_FCloseFile( f );
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:34,代码来源:ui_demos.c


示例2: SV_RunGameFrame

/*
static qboolean SV_RunGameFrame( int msec )
{
int extraTime = 0;
static unsigned int accTime = 0;

accTime += msec;

// move autonomous things around if enough time has passed
if( svs.gametime < sv.nextSnapTime )
{
if( svs.gametime + svc.snapFrameTime < sv.nextSnapTime )
{
if( sv_showclamp->integer )
Com_Printf( "sv lowclamp\n" );
sv.nextSnapTime = svs.gametime + svc.snapFrameTime;
return qfalse;
}

// see if it's time to advance the world
if( accTime >= WORLDFRAMETIME )
{
if( host_speeds->integer )
time_before_game = Sys_Milliseconds();

ge->RunFrame( WORLDFRAMETIME, svs.gametime );

if( host_speeds->integer )
time_after_game = Sys_Milliseconds();

accTime = accTime - WORLDFRAMETIME;
}

if( !SV_SendClientsFragments() )
{
// FIXME: gametime might slower/faster than real time
if( dedicated->integer )
{
socket_t *sockets[] = { &svs.socket_udp, NULL };
NET_Sleep( min( WORLDFRAMETIME - accTime, sv.nextSnapTime - svs.gametime ), sockets );
}
}

return qfalse;
}

if( sv.nextSnapTime <= svs.gametime )
{
extraTime = (int)( svs.gametime - sv.nextSnapTime );
}
if( extraTime >= msec )
extraTime = msec - 1;

sv.nextSnapTime = ( svs.gametime + svc.snapFrameTime ) - extraTime;

// Execute all clients pending move commands
if( accTime )
{
ge->RunFrame( accTime, svs.gametime );
accTime = 0;
}

// update ping based on the last known frame from all clients
SV_CalcPings();

sv.framenum++;
ge->SnapFrame();

return qtrue;
}
*/
static void SV_CheckDefaultMap( void )
{
	if( svc.autostarted )
		return;

	svc.autostarted = qtrue;
	if( dedicated->integer )
	{
		if( sv.state == ss_dead && !strlen( sv.mapname ) )
        {
            int filehandle;
            if( sv_write_defaultmap && sv_write_defaultmap->integer && FS_FOpenFile( "defaultmap", &filehandle, FS_READ ) != -1 )
            {
                static char buffer[MAX_QPATH];
                buffer[0] = '\0';
                FS_Read( buffer, MAX_QPATH - 1, filehandle );
                FS_FCloseFile( filehandle );
                if( buffer[0] )
                {
                    Cbuf_ExecuteText( EXEC_APPEND, va( "map %s\n", buffer ) );
                    return;
                }
            }
            if( sv_defaultmap && strlen( sv_defaultmap->string ) )
                Cbuf_ExecuteText( EXEC_APPEND, va( "map %s\n", sv_defaultmap->string ) );
        }
	}
}
开发者ID:hettoo,项目名称:racesow,代码行数:99,代码来源:sv_main.c


示例3: Com_DPrintf

// returns static string of md5 contents
const char *MM_PasswordRead( const char *user )
{
	static char buffer[MAX_STRING_CHARS];
	const char *filename;
	int filenum;
	size_t bytes;

	Com_DPrintf( "MM_PasswordRead %s\n", user );

	filename = mm_passwordFilename( user );
	if( FS_FOpenFile( filename, &filenum, FS_READ ) == -1 )
	{
		Com_Printf( "MM_PasswordRead: Couldnt open file %s\n", filename);
		return NULL;
	}

	bytes = FS_Read(buffer, sizeof( buffer ) - 1,  filenum );
	FS_FCloseFile( filenum );

	if( bytes == 0 || bytes >= sizeof(buffer) - 1 )
		return NULL;

	buffer[bytes] = '\0';

	return buffer;
}
开发者ID:Turupawn,项目名称:DogeWarsow,代码行数:27,代码来源:mm_common.c


示例4: CL_CheckOrDownloadFile

/*
* CL_CheckOrDownloadFile
* 
* Returns true if the file exists or couldn't send download request
* Files with .pk3 or .pak extension have to have gamedir attached
* Other files must not have gamedir
*/
qboolean CL_CheckOrDownloadFile( const char *filename )
{
	const char *ext;

	if( !cl_downloads->integer )
		return qtrue;

	if( !COM_ValidateRelativeFilename( filename ) )
		return qtrue;

	ext = COM_FileExtension( filename );
	if( !ext || !*ext )
		return qtrue;

	if( FS_CheckPakExtension( filename ) )
	{
		if( FS_FOpenBaseFile( filename, NULL, FS_READ ) != -1 )
			return qtrue;
	}
	else
	{
		if( FS_FOpenFile( filename, NULL, FS_READ ) != -1 )
			return qtrue;
	}

	if( !CL_DownloadRequest( filename, qtrue ) )
		return qtrue;

	cls.download.requestnext = qtrue; // call CL_RequestNextDownload when done

	return qfalse;
}
开发者ID:Turupawn,项目名称:DogeWarsow,代码行数:39,代码来源:cl_parse.c


示例5: wswcurl_write

static size_t wswcurl_write(void *ptr, size_t size, size_t nmemb, void *stream)
{
    wswcurl_req *req = (wswcurl_req*)stream;
    if (!req->filename) {
        // Reallocate buffer
        req->rxdata = WREALLOC(req->rxdata, req->rxsize + (size * nmemb) + 1);
        // Set remaining data to 0
        memset(&(req->rxdata[req->rxsize]), 0, (size * nmemb));
        // Copy received data
        memcpy(&(req->rxdata[req->rxsize]), ptr, size*nmemb);
        // Recalculate size
        req->rxsize += size*nmemb;
        // Add trailing NULL byte at the end to prevent string overflow
        req->rxdata[req->rxsize] = '\0';
    } else {
        // Receive to the filename.
        // TODO: FILE RESUMING??
#ifndef WSWCURL_TEST_MAIN
        if ( (req->filenum < 0) && ( FS_FOpenFile( req->filename, &(req->filenum), FS_WRITE ) < 0 ) ) {
            return 0; // RETURN ERROR
        }
        FS_Write(ptr, size * nmemb, req->filenum);
#else
        // TODO: IMPLEMENT TEST
#endif
    }
    // Mark connection as having had activity.
    req->activity = 1;
    if (req->callback_progress) {
        // Execute progress callback
        // ??? What to return when expected size is unknown? - currently, return 0.0
        req->callback_progress(req, ( req->rx_expsize < 0 ) ? 0.0 : (req->rxsize / req->rx_expsize) * 100.0);
    }
    return size*nmemb;
}
开发者ID:Racenet,项目名称:racesow,代码行数:35,代码来源:wswcurl.c


示例6: FS_LoadFile

/*
 * Filename are reletive to the quake search path. A null buffer will just
 * return the file length without loading.
 */
int
FS_LoadFile(char *path, void **buffer)
{
	byte *buf; /* Buffer. */
	int size; /* File size. */
	fileHandle_t f; /* File handle. */

	buf = NULL;
	size = FS_FOpenFile(path, &f, FS_READ);

	if (size <= 0)
	{
		if (buffer)
		{
			*buffer = NULL;
		}

		return size;
	}

	if (buffer == NULL)
	{
		FS_FCloseFile(f);
		return size;
	}

	buf = Z_Malloc(size);
	*buffer = buf;

	FS_Read(buf, size, f);
	FS_FCloseFile(f);

	return size;
}
开发者ID:Jenco420,项目名称:yquake2,代码行数:38,代码来源:filesystem.c


示例7: SV_ReadLevelFile

void
SV_ReadLevelFile(void)
{
	char name[MAX_OSPATH];
	fileHandle_t f;

	Com_DPrintf("SV_ReadLevelFile()\n");

	Com_sprintf(name, sizeof(name), "save/current/%s.sv2", sv.name);
	FS_FOpenFile(name, &f, FS_READ);

	if (!f)
	{
		Com_Printf("Failed to open %s\n", name);
		return;
	}

	FS_Read(sv.configstrings, sizeof(sv.configstrings), f);
	CM_ReadPortalState(f);
	FS_FCloseFile(f);

	Com_sprintf(name, sizeof(name), "%s/save/current/%s.sav",
				FS_Gamedir(), sv.name);
	ge->ReadLevel(name);
}
开发者ID:bradc6,项目名称:yquake2,代码行数:25,代码来源:sv_save.c


示例8: FS_LoadFile

/*
============
FS_LoadFile

Filename are reletive to the quake search path
a null buffer will just return the file length without loading
============
*/
int FS_LoadFile(char *path, void **buffer)
{
	FILE	*h;
	byte	*buf;
	int		len;

	buf = NULL;	// quiet compiler warning

	// look for it in the filesystem or pack files
	len = FS_FOpenFile(path, &h);
	if (!h)
	{
		if (buffer)
			*buffer = NULL;
		return -1;
	}

	if (!buffer)
	{
		fclose(h);
		return len;
	}

	buf = Z_Malloc(len);
	*buffer = buf;

	FS_Read(buf, len, h);

	fclose(h);

	return len;
}
开发者ID:qbism,项目名称:qbq2,代码行数:40,代码来源:files.c


示例9: Prompt_LoadHistory

void Prompt_LoadHistory( commandPrompt_t *prompt, const char *filename ) {
    char buffer[MAX_FIELD_TEXT];
    qhandle_t f;
    int i;
    ssize_t len;

    FS_FOpenFile( filename, &f, FS_MODE_READ|FS_TYPE_REAL|FS_PATH_BASE );
    if( !f ) {
        return;
    }

    for( i = 0; i < HISTORY_SIZE; i++ ) {
        if( ( len = FS_ReadLine( f, buffer, sizeof( buffer ) ) ) < 1 ) {
            break;
        }
        if( prompt->history[i] ) {
            Z_Free( prompt->history[i] );
        }
        prompt->history[i] = memcpy( Z_Malloc( len + 1 ), buffer, len + 1 );
    }

    FS_FCloseFile( f );

    prompt->historyLineNum = i;
    prompt->inputLineNum = i;
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:26,代码来源:prompt.c


示例10: Prompt_SaveHistory

void Prompt_SaveHistory( commandPrompt_t *prompt, const char *filename, int lines ) {
    qhandle_t f;
    char *s;
    int i;

    FS_FOpenFile( filename, &f, FS_MODE_WRITE|FS_PATH_BASE );
    if( !f ) {
        return;
    }

    if( lines > HISTORY_SIZE ) {
        lines = HISTORY_SIZE;
    }

    i = prompt->inputLineNum - lines;
    if( i < 0 ) {
        i = 0;
    }
    for( ; i < prompt->inputLineNum; i++ ) {
        s = prompt->history[i & HISTORY_MASK];
        if( s ) {
            FS_FPrintf( f, "%s\n", s );
        }
    }

    FS_FCloseFile( f );
}
开发者ID:Bad-ptr,项目名称:q2pro,代码行数:27,代码来源:prompt.c


示例11: read_binary_file

static int read_binary_file(const char *name)
{
    qhandle_t f;
    size_t len;

    len = FS_FOpenFile(name, &f, FS_MODE_READ | FS_TYPE_REAL | FS_PATH_GAME);
    if (!f)
        return -1;

    if (len > MAX_MSGLEN)
        goto fail;

    if (FS_Read(msg_read_buffer, len, f) != len)
        goto fail;

    SZ_Init(&msg_read, msg_read_buffer, len);
    msg_read.cursize = len;

    FS_FCloseFile(f);
    return 0;

fail:
    FS_FCloseFile(f);
    return -1;
}
开发者ID:jdolan,项目名称:q2pro,代码行数:25,代码来源:save.c


示例12: SNAP_WriteDemoMetaData

/*
* SNAP_WriteDemoMetaData
*/
void SNAP_WriteDemoMetaData( const char *filename, const char *meta_data, size_t meta_data_realsize )
{
	unsigned i;
	unsigned v;
	char tmpn[256];
	int filenum, filelen;
	msg_t msg;
	uint8_t msg_buffer[MAX_MSGLEN];
	void *compressed_msg;

	MSG_Init( &msg, msg_buffer, sizeof( msg_buffer ) );

	// write to a temp file
	v = 0;
	for( i = 0; filename[i]; i++ ) {
		v = ( v + i ) * 37 + tolower( filename[i] ); // case insensitivity
	}
	Q_snprintfz( tmpn, sizeof( tmpn ), "%u.tmp", v );

	if( FS_FOpenFile( tmpn, &filenum, FS_WRITE|SNAP_DEMO_GZ ) == -1 ) {
		return;
	}

	SNAP_DemoMetaDataMessage( &msg, meta_data, meta_data_realsize );
	SNAP_RecordDemoMetaDataMessage( filenum, &msg );

	// now open the original file in update mode and overwrite metadata

	// important note: we need to the load the temp file before closing it
	// because in the case of gz compression, closing the file may actually
	// write some data we don't want to copy
	filelen = FS_LoadFile( tmpn, &compressed_msg, NULL, 0 );

	if( compressed_msg ) {
		int origfile;

		if( FS_FOpenFile( filename, &origfile, FS_READ|FS_UPDATE ) != -1 ) {
			FS_Write( compressed_msg, filelen, origfile );
			FS_FCloseFile( origfile );
		}
		FS_FreeFile( compressed_msg );
	}

	FS_FCloseFile( filenum );

	FS_RemoveFile( tmpn );
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:50,代码来源:snap_demos.c


示例13: CL_ReadServerCache

/*
* CL_ReadServerCache
*/
void CL_ReadServerCache( void )
{
	int filelen, filehandle;
	qbyte *buf = NULL;
	char *ptr, *token;
	netadr_t adr;
	char adrString[64];
	qboolean favorite = qfalse;

	filelen = FS_FOpenFile( SERVERSFILE, &filehandle, FS_READ );
	if( !filehandle || filelen < 1 )
	{
		FS_FCloseFile( filehandle );
	}
	else
	{
		buf = Mem_TempMalloc( filelen + 1 );
		filelen = FS_Read( buf, filelen, filehandle );
		FS_FCloseFile( filehandle );
	}

	if( !buf )
		return;

	ptr = ( char * )buf;
	while( ptr )
	{
		token = COM_ParseExt( &ptr, qtrue );
		if( !token[0] )
			break;

		if( !Q_stricmp( token, "master" ) )
		{
			favorite = qfalse;
			continue;
		}

		if( !Q_stricmp( token, "favorites" ) )
		{
			favorite = qtrue;
			continue;
		}

		if( NET_StringToAddress( token, &adr ) )
		{
			Q_strncpyz( adrString, token, sizeof( adrString ) );
			token = COM_ParseExt( &ptr, qfalse );
			if( !token[0] )
				continue;

			if( favorite )
				CL_AddServerToList( &favoritesList, adrString, (unsigned int)atoi( token ) );
			else
				CL_AddServerToList( &masterList, adrString, (unsigned int)atoi( token ) );
		}
	}

	Mem_TempFree( buf );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:62,代码来源:cl_serverlist.c


示例14: S_OpenBackgroundTrack

/*
=================
S_OpenBackgroundTrack
=================
*/
static qboolean S_OpenBackgroundTrack (char *name, bgTrack_t *track)
{
	OggVorbis_File	*vorbisFile;
	vorbis_info		*vorbisInfo;
	ov_callbacks	vorbisCallbacks = {ovc_read, ovc_seek, ovc_close, ovc_tell};
#ifdef OGG_DIRECT_FILE
	char	filename[1024];
	char	*path = NULL;
#endif

//	Com_Printf("Opening background track: %s\n", name);

#ifdef OGG_DIRECT_FILE
	do {
		path = FS_NextPath( path );
		Com_sprintf( filename, sizeof(filename), "%s/%s", path, name );
		if ( (track->file = fopen(filename, "rb")) != 0)
			break;
	} while ( path );
#else
	FS_FOpenFile(name, &track->file);
#endif
	if (!track->file)
	{
		Com_Printf("S_OpenBackgroundTrack: couldn't find %s\n", name);
		return false;
	}

	track->vorbisFile = vorbisFile = Z_Malloc(sizeof(OggVorbis_File));

//	Com_Printf("Opening callbacks for background track\n");

	// bombs out here- ovc_read, FS_Read 0 bytes error
	if (ov_open_callbacks(track, vorbisFile, NULL, 0, vorbisCallbacks) < 0)
	{
		Com_Printf("S_OpenBackgroundTrack: couldn't open OGG stream (%s)\n", name);
		return false;
	}

//	Com_Printf("Getting info for background track\n");

	vorbisInfo = ov_info(vorbisFile, -1);
	if (vorbisInfo->channels != 1 && vorbisInfo->channels != 2)
	{
		Com_Printf("S_OpenBackgroundTrack: only mono and stereo OGG files supported (%s)\n", name);
		return false;
	}

	track->start = ov_raw_tell(vorbisFile);
	track->rate = vorbisInfo->rate;
	track->width = 2;
	track->channels = vorbisInfo->channels; // Knightmare added
	track->format = (vorbisInfo->channels == 2) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16;

//	Com_Printf("Vorbis info: frequency: %i channels: %i bitrate: %i\n",
//		vorbisInfo->rate, vorbisInfo->channels, vorbisInfo->bitrate_nominal);

	return true;
}
开发者ID:qbism,项目名称:Quake2-colored-refsoft,代码行数:64,代码来源:snd_stream.c


示例15: SV_BeginDemoserver

/*
==================
SV_BeginDemoServer
==================
*/
void SV_BeginDemoserver(void){
	char	name[MAX_OSPATH];

	Com_sprintf(name, sizeof(name), "demos/%s", sv.name);
	FS_FOpenFile(name, &sv.demofile);
	if(!sv.demofile)
		Com_Error(ERR_DROP, "Couldn't open %s\n", name);
}
开发者ID:luaman,项目名称:qforge-2,代码行数:13,代码来源:sv_user.c


示例16: Con_Dump_f

/*
* Con_Dump_f
*
* Save the console contents out to a file
*/
static void Con_Dump_f( void )
{
    int file;
    size_t buffer_size;
    char *buffer;
    size_t name_size;
    char *name;
    const char *newline = "\r\n";

    if( !con_initialized )
        return;

    if( Cmd_Argc() != 2 )
    {
        Com_Printf( "usage: condump <filename>\n" );
        return;
    }

    name_size = sizeof( char ) * ( strlen( Cmd_Argv( 1 ) ) + strlen( ".txt" ) + 1 );
    name = Mem_TempMalloc( name_size );

    Q_strncpyz( name, Cmd_Argv( 1 ), name_size );
    COM_DefaultExtension( name, ".txt", name_size );
    COM_SanitizeFilePath( name );

    if( !COM_ValidateRelativeFilename( name ) )
    {
        Com_Printf( "Invalid filename.\n" );
        Mem_TempFree( name );
        return;
    }

    if( FS_FOpenFile( name, &file, FS_WRITE ) == -1 )
    {
        Com_Printf( "Couldn't open: %s\n", name );
        Mem_TempFree( name );
        return;
    }

    buffer_size = Con_BufferText( NULL, newline ) + 1;
    buffer = Mem_TempMalloc( buffer_size );

    Con_BufferText( buffer, newline );

    FS_Write( buffer, buffer_size - 1, file );

    FS_FCloseFile( file );

    Mem_TempFree( buffer );

    Com_Printf( "Dumped console text: %s\n", name );
    Mem_TempFree( name );
}
开发者ID:Turupawn,项目名称:DogeWarsow,代码行数:58,代码来源:console.c


示例17: strchr

struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base)
{
	int				n;
	char			*p;
	struct sfx_s	*sfx;
	FILE			*f;
	char			model[MAX_QPATH];
	char			sexedFilename[MAX_QPATH];
	char			maleFilename[MAX_QPATH];

	// determine what model the client is using
	model[0] = 0;
	n = CS_PLAYERSKINS + ent->number - 1;
	if (cl.configstrings[n][0])
	{
		p = strchr(cl.configstrings[n], '\\');
		if (p)
		{
			p += 1;
			strcpy(model, p);
			p = strchr(model, '/');
			if (p)
				*p = 0;
		}
	}
	// if we can't figure it out, they're male
	if (!model[0])
		strcpy(model, "male");

	// see if we already know of the model specific sound
	Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
	sfx = S_FindName (sexedFilename, false);

	if (!sfx)
	{
		// no, so see if it exists
		FS_FOpenFile (&sexedFilename[1], &f);
		if (f)
		{
			// yes, close the file and register it
			FS_FCloseFile (f);
			sfx = S_RegisterSound (sexedFilename);
		}
		else
		{
			// no, revert to the male sound in the pak0.pak
			Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1);
			sfx = S_AliasName (sexedFilename, maleFilename);
		}
	}

	return sfx;
}
开发者ID:qbism,项目名称:Quake2-colored-refsoft,代码行数:53,代码来源:snd_dma.c


示例18: ML_Restart

/*
* ML_Restart
* Restart map list stuff
*/
void ML_Restart( bool forcemaps )
{
	ML_Shutdown();
	if( forcemaps )
	{
		int filenum;
		if( FS_FOpenFile( MLIST_CACHE, &filenum, FS_WRITE|FS_CACHE ) != -1 )
			FS_FCloseFile( filenum );
	}
	FS_Rescan();
	ML_Init();
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:16,代码来源:mlist.c


示例19: CL_DownloadRequest

/*
* CL_DownloadRequest
* 
* Request file download
* return qfalse if couldn't request it for some reason
* Files with .pk3 or .pak extension have to have gamedir attached
* Other files must not have gamedir
*/
qboolean CL_DownloadRequest( const char *filename, qboolean requestpak )
{
	if( cls.download.requestname )
	{
		Com_Printf( "Can't download: %s. Download already in progress.\n", filename );
		return qfalse;
	}

	if( !COM_ValidateRelativeFilename( filename ) )
	{
		Com_Printf( "Can't download: %s. Invalid filename.\n", filename );
		return qfalse;
	}

	if( FS_CheckPakExtension( filename ) )
	{
		if( FS_FOpenBaseFile( filename, NULL, FS_READ ) != -1 )
		{
			Com_Printf( "Can't download: %s. File already exists.\n", filename );
			return qfalse;
		}

		if( !Q_strnicmp( COM_FileBase( filename ), "modules", strlen( "modules" ) ) )
		{
			if( !CL_CanDownloadModules() )
				return qfalse;
		}
	}
	else
	{
		if( FS_FOpenFile( filename, NULL, FS_READ ) != -1 )
		{
			Com_Printf( "Can't download: %s. File already exists.\n", filename );
			return qfalse;
		}
	}

	if( cls.socket->type == SOCKET_LOOPBACK )
	{
		Com_DPrintf( "Can't download: %s. Loopback server.\n", filename );
		return qfalse;
	}

	Com_Printf( "Asking to download: %s\n", filename );

	cls.download.requestpak = requestpak;
	cls.download.requestname = Mem_ZoneMalloc( sizeof( char ) * ( strlen( filename ) + 1 ) );
	Q_strncpyz( cls.download.requestname, filename, sizeof( char ) * ( strlen( filename ) + 1 ) );
	cls.download.timeout = Sys_Milliseconds() + 5000;
	CL_AddReliableCommand( va( "download %i \"%s\"", requestpak, filename ) );

	return qtrue;
}
开发者ID:Turupawn,项目名称:DogeWarsow,代码行数:61,代码来源:cl_parse.c


示例20: SV_ReadServerFile

void
SV_ReadServerFile(void)
{
	fileHandle_t f;
	char name[MAX_OSPATH], string[128];
	char comment[32];
	char mapcmd[MAX_TOKEN_CHARS];

	Com_DPrintf("SV_ReadServerFile()\n");

	Com_sprintf(name, sizeof(name), "save/current/server.ssv");
	FS_FOpenFile(name, &f, FS_READ);

	if (!f)
	{
		Com_Printf("Couldn't read %s\n", name);
		return;
	}

	/* read the comment field */
	FS_Read(comment, sizeof(comment), f);

	/* read the mapcmd */
	FS_Read(mapcmd, sizeof(mapcmd), f);

	/* read all CVAR_LATCH cvars
	   these will be things like 
	   coop, skill, deathmatch, etc */
	while (1)
	{
		char cvarname[LATCH_CVAR_SAVELENGTH] = {0};
		if (!FS_FRead(cvarname, 1, sizeof(cvarname), f))
		{
			break;
		}

		FS_Read(string, sizeof(string), f);
		Com_DPrintf("Set %s = %s\n", cvarname, string);
		Cvar_ForceSet(cvarname, string);
	}

	FS_FCloseFile(f);

	/* start a new game fresh with new cvars */
	SV_InitGame();

	strcpy(svs.mapcmd, mapcmd);

	/* read game state */
	Com_sprintf(name, sizeof(name), "%s/save/current/game.ssv", FS_Gamedir());
	ge->ReadGame(name);
}
开发者ID:bradc6,项目名称:yquake2,代码行数:52,代码来源:sv_save.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FS_FOpenFileByMode函数代码示例发布时间:2022-05-30
下一篇:
C++ FS_FCloseFile函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap