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


C++ FS_FOpenFileRead函数代码示例

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


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

示例1: FS_FOpenFileRead

/*
=================
S_CodecUtilOpen
=================
*/
snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec)
{
    snd_stream_t *stream;
    fileHandle_t hnd;
    int length;

    // Try to open the file
    length = FS_FOpenFileRead(filename, &hnd, qtrue);
    if(!hnd)
    {
        Com_Printf(_("Can't read sound file %s\n"), filename);
        return NULL;
    }

    // Allocate a stream
    stream = Z_Malloc(sizeof(snd_stream_t));
    if(!stream)
    {
        FS_FCloseFile(hnd);
        return NULL;
    }

    // Copy over, return
    stream->codec = codec;
    stream->file = hnd;
    stream->length = length;
    return stream;
}
开发者ID:ZdrytchX,项目名称:obstacle,代码行数:33,代码来源:snd_codec.c

示例2: SV_TouchFile

/*
================
SV_TouchFile
================
*/
static void SV_TouchFile( const char *filename ) {
	fileHandle_t	f;

	FS_FOpenFileRead( filename, &f, qfalse );
	if ( f ) {
		FS_FCloseFile( f );
	}
}
开发者ID:MAN-AT-ARMS,项目名称:ioq3,代码行数:13,代码来源:sv_init.c

示例3: SV_TouchCGame

/*
================
SV_TouchCGame

Touch the cgame.qvm and ui.qvm so that a pure client can load it if it's in a seperate pk3, and so it gets on the download list
================
*/
static void SV_TouchCGame(void) {
	fileHandle_t	f;

	FS_FOpenFileRead( "vm/cgame.qvm", &f, qfalse );
	if ( f ) {
		FS_FCloseFile( f );
	} else if ( sv_pure->integer ) {
		Com_Printf( "WARNING: No cgame.qvm found on pure server\n" );
	}

	FS_FOpenFileRead( "vm/ui.qvm", &f, qfalse );
	if ( f ) {
		FS_FCloseFile( f );
	} else if ( sv_pure->integer ) {
		Com_Printf( "WARNING: No ui.qvm found on pure server\n" );
	}
}
开发者ID:Amanieu,项目名称:tremfusion,代码行数:24,代码来源:sv_init.c

示例4: S_FileExists

qboolean S_FileExists(char *fileName) {
	fileHandle_t f;
	COM_StripExtension(fileName, fileName);
	COM_DefaultExtension(fileName, MAX_QPATH, ".wav");
	FS_FOpenFileRead(fileName, &f, qtrue);
	if (!f) {
#ifdef HAVE_LIBMAD
		COM_StripExtension(fileName, fileName);
		COM_DefaultExtension(fileName, MAX_QPATH, ".mp3");
		FS_FOpenFileRead(fileName, &f, qtrue);
		if (!f)
#endif
			return qfalse;
	}
	FS_FCloseFile(f);
	return qtrue;
}
开发者ID:entdark,项目名称:q3mme,代码行数:17,代码来源:snd_mem.c

示例5: SV_TouchCGame

/*
================
SV_TouchCGame

  touch cgame so that a pure client can load it if it's in a seperate pk3
================
*/
void SV_TouchCGame( void )
{
	fileHandle_t f;

	FS_FOpenFileRead( "vm/cgame.qvm", &f, qfalse );

	if ( f )
	{
		FS_FCloseFile( f );
	}

	// LLVM - even if the server doesn't use llvm itself, it should still add the references.
	FS_FOpenFileRead( "cgamellvm.bc", &f, qfalse );

	if ( f )
	{
		FS_FCloseFile( f );
	}
}
开发者ID:SHOVELL,项目名称:Unvanquished,代码行数:26,代码来源:sv_init.c

示例6: SV_TouchCGame

/*
================
SV_TouchCGame

  touch the cgame.vm so that a pure client can load it if it's in a seperate pk3
================
*/
void SV_TouchCGame(void) {
    fileHandle_t	f;
    char filename[MAX_QPATH];

    Com_sprintf( filename, sizeof(filename), "vm/%s.qvm", "cgame" );
    FS_FOpenFileRead( filename, &f, qfalse );
    if ( f ) {
        FS_FCloseFile( f );
    }
}
开发者ID:Avatarchik,项目名称:Quake-III-Arena-D3D11,代码行数:17,代码来源:sv_init.c

示例7: BotLoadOffMeshConnections

void BotLoadOffMeshConnections( const char *filename, 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, filename );
	FS_FOpenFileRead( filePath, &f, qtrue );

	if ( !f )
	{
		return;
	}

	OffMeshConnectionHeader header;
	FS_Read( &header, sizeof( header ), f );

	header.version = LittleLong( header.version );
	header.numConnections = LittleLong( header.numConnections );

	if ( header.version != NAVMESHCON_VERSION )
	{
		FS_FCloseFile( f );
		return;
	}

	int conCount = header.numConnections;

	if ( conCount > nav->process.con.MAX_CON )
	{
		FS_FCloseFile( f );
		return;
	}

	nav->process.con.offMeshConCount = conCount;

	FS_Read( nav->process.con.verts, sizeof( float ) * 6 * conCount, f );
	SwapArray( nav->process.con.verts, conCount * 6 );

	FS_Read( nav->process.con.rad, sizeof( float ) * conCount, f );
	SwapArray( nav->process.con.rad, conCount );

	FS_Read( nav->process.con.flags, sizeof( unsigned short ) * conCount, f );
	SwapArray( nav->process.con.flags, conCount );

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

	FS_Read( nav->process.con.userids, sizeof( unsigned int ) * conCount, f );
	SwapArray( nav->process.con.userids, conCount );

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

示例8: FS_FOpenFileByMode

int	FS_FOpenFileByMode( const char *qpath, fileHandle_t *f, fsMode_t mode )
{
	FS_CheckInit();

	if (mode != FS_READ)
	{
		Com_Error( ERR_FATAL, "FSH_FOpenFile: bad mode" );
		return -1;
	}
	
	return FS_FOpenFileRead( qpath, f, qtrue );
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:12,代码来源:files_console.cpp

示例9: FS_FOpenFileRead

static openSound_t *S_StreamOpen( const char *fileName, int dataSize ) {
	fileHandle_t fileHandle = 0;
	int fileSize = 0;
	openSound_t *open;

	fileSize = FS_FOpenFileRead( fileName, &fileHandle, qtrue );
	if ( fileSize <= 0 || fileHandle <= 0)
		return 0;
	open = Z_Malloc( sizeof( openSound_t ) + dataSize );
	open->fileSize = fileSize;
	open->fileHandle = fileHandle;
	return open;
}
开发者ID:entdark,项目名称:q3mme,代码行数:13,代码来源:snd_mem.c

示例10: CL_WalkDemoExt

/*
====================
CL_WalkDemoExt
====================
*/
static int CL_WalkDemoExt(char *arg, char *name, int *demofile)
{
	int i = 0;
	*demofile = 0;

	Com_sprintf(name, MAX_OSPATH, "demos/%s.%s%d", arg, DEMOEXT, PROTOCOL_VERSION);
	FS_FOpenFileRead(name, demofile, qtrue);

	if (*demofile)
	{
		Com_FuncPrinf("Demo file: %s\n", name);
		return PROTOCOL_VERSION;
	}

	Com_FuncPrinf("Not found: %s\n", name);

	while (demo_protocols[i])
	{
		if (demo_protocols[i] == PROTOCOL_VERSION)
		{
			continue;
		}

		Com_sprintf(name, MAX_OSPATH, "demos/%s.%s%d", arg, DEMOEXT, demo_protocols[i]);
		FS_FOpenFileRead(name, demofile, qtrue);
		if (*demofile)
		{
			Com_FuncPrinf("Demo file: %s\n", name);
			return demo_protocols[i];
		}
		else
		{
			Com_FuncPrinf("Not found: %s\n", name);
		}
		i++;
	}

	return -1;
}
开发者ID:dstaesse,项目名称:etlegacy,代码行数:44,代码来源:cl_demo.c

示例11: dmaHD_LoadSound

qboolean dmaHD_LoadSound(sfx_t *sfx)
{
	byte *data;
	snd_info_t info;
	char dmahd_soundName[MAX_QPATH];
	char *lpext;

	// Player specific sounds are never directly loaded.
	if (sfx->soundName[0] == '*') return qfalse;

	strcpy(dmahd_soundName, sfx->soundName);
	if ((lpext = strrchr(sfx->soundName, '.')) != NULL)
	{
		strcpy(dmahd_soundName, sfx->soundName);
		*(strrchr(dmahd_soundName, '.')) = '\0'; // for sure there is a '.'
	}
	strcat(dmahd_soundName, "_dmahd");
	if (lpext != NULL) strcat(dmahd_soundName, lpext);

	// Just check if file exists
	if (FS_FOpenFileRead(dmahd_soundName, NULL, qtrue) == qtrue)
	{
		// Load it in.
		if (!(data = S_CodecLoad(dmahd_soundName, &info))) return qfalse;
	}
	else
	{
		// Load it in.
		if (!(data = S_CodecLoad(sfx->soundName, &info))) return qfalse;
	}

	// Information
	Com_DPrintf("Loading sound: %s", sfx->soundName);
	if (info.width == 1) Com_DPrintf(" [8 bit -> 16 bit]");
	if (info.rate != dma.speed) Com_DPrintf(" [%d Hz -> %d Hz]", info.rate, dma.speed);
	Com_DPrintf("\n");

	sfx->lastTimeUsed = Com_Milliseconds() + 1;

	// Do not compress.
	sfx->soundCompressionMethod = 0;
	sfx->soundLength = info.samples;
	sfx->soundData = NULL;
	dmaHD_ResampleSfx(sfx, info.rate, info.width, data + info.dataofs, qfalse);
	
	// Free data allocated by Codec
	Z_Free(data);

	return qtrue;
}
开发者ID:trusteed,项目名称:ioq3-for-UrbanTerror-5,代码行数:50,代码来源:snd_dmahd.c

示例12: FS_ReadFile

/*
============
FS_ReadFile

Filename are relative to the quake search path
a null buffer will just return the file length without loading
============
*/
int FS_ReadFile( const char *qpath, void **buffer )
{
	FS_CheckInit();
	
	if ( !qpath || !qpath[0] ) {
		Com_Error( ERR_FATAL, "FS_ReadFile with empty name\n" );
	}

	// stop sounds from repeating
	S_ClearSoundBuffer();

	fileHandle_t h;
	int len = FS_FOpenFileRead( qpath, &h, qfalse );
	if ( h == 0 )
	{
		if ( buffer ) *buffer = NULL;
		return -1;
	}
	
	if ( !buffer )
	{
		FS_FCloseFile(h);
		return len;
	}

	byte *buf;
	// Try to TempAlloc if we've got the hint that this could fail:
	if( sbLargeRead )
		buf = (byte *)BonePoolTempAlloc( len+1 );

	// If that didn't work, or wasn't suggested:
	if( !sbLargeRead || !buf )
		buf = (byte*)Z_Malloc( len+1, TAG_TEMP_WORKSPACE, qfalse, 32);

	buf[len]='\0';

//	Z_Label(buf, qpath);

	FS_Read(buf, len, h);

	// guarantee that it will have a trailing 0 for string operations
	buf[len] = 0;
	FS_FCloseFile( h );

	*buffer = buf;
	return len;
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:55,代码来源:files_console.cpp

示例13: SV_SetExpectedHunkUsage

/*
====================
SV_SetExpectedHunkUsage

  Sets com_expectedhunkusage, so the client knows how to draw the percentage bar
====================
*/
void SV_SetExpectedHunkUsage( char *mapname )
{
	int  handle;
	const char *memlistfile = "hunkusage.dat";
	char *buf;
	char *buftrav;
	char *token;
	int  len;

	len = FS_FOpenFileRead( memlistfile, &handle, qfalse );

	if ( len >= 0 )
	{
		// the file exists, so read it in, strip out the current entry for this map, and save it out, so we can append the new value
		buf = ( char * ) Z_Malloc( len + 1 );
		memset( buf, 0, len + 1 );

		FS_Read( ( void * ) buf, len, handle );
		FS_FCloseFile( handle );

		// now parse the file, filtering out the current map
		buftrav = buf;

		while ( ( token = COM_Parse( &buftrav ) ) != NULL && token[ 0 ] )
		{
			if ( !Q_stricmp( token, mapname ) )
			{
				// found a match
				token = COM_Parse( &buftrav );  // read the size

				if ( token && token[ 0 ] )
				{
					// this is the usage
					com_expectedhunkusage = atoi( token );
					Z_Free( buf );
					return;
				}
			}
		}

		Z_Free( buf );
	}

	// just set it to a negative number,so the cgame knows not to draw the percent bar
	com_expectedhunkusage = -1;
}
开发者ID:prodigeni,项目名称:Unvanquished,代码行数:53,代码来源:sv_init.cpp

示例14: SV_TouchCGame

/*
================
SV_TouchCGame

  touch the cgame.vm so that a pure client can load it if it's in a seperate pk3
================
*/
void SV_TouchCGame(void) {
	fileHandle_t	f;
	char filename[MAX_QPATH];

	if (Cvar_VariableValue( "vm_cgame" ))
	{
		Com_sprintf( filename, sizeof(filename), "vm/%s.qvm", "cgame" );
	}
	else
	{
		Com_sprintf( filename, sizeof(filename), "cgamex86.dll" );
	}
	FS_FOpenFileRead( filename, &f, qfalse );
	if ( f ) {
		FS_FCloseFile( f );
	}
}
开发者ID:eezstreet,项目名称:JediKnightGalaxies,代码行数:24,代码来源:sv_init.cpp

示例15: CON_Hist_Load

/*
==================
CON_Hist_Load
==================
*/
void CON_Hist_Load( void ) {
	fileHandle_t f;
	long len = FS_FOpenFileRead("conhist.log", &f, qtrue);
	if (f) {
		field_t tf {};
		for (long i = 0; i < len; i++) {
			char c;
			FS_Read(&c, 1, f);
			if (c == '\n') {
				Hist_Add(&tf);
				tf = {};
			} else {
				tf.buffer[tf.cursor++] = c;
			}
		}
		FS_FCloseFile(f);
	}
}
开发者ID:cagelight,项目名称:jaownt,代码行数:23,代码来源:con_tty.cpp


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