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

C++ FS_FreeFile函数代码示例

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

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



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

示例1: S_LoadSound

/*
==============
S_LoadSound

The filename may be different than sfx->name in the case
of a forced fallback of a player specific sound
==============
*/
bool S_LoadSound( sfx_t *sfx )
{
	byte	*data;
	short	*samples;
	wavinfo_t	info;
	int		size;

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

	// load it in
	size = FS_ReadFile( sfx->soundName, (void **)&data );
	if ( !data ) 
		return false;

	info = GetWavinfo( sfx->soundName, data, size );
	if ( info.channels != 1 ) 
	{
		Com_Printf ("%s is a stereo wav file\n", sfx->soundName);
		FS_FreeFile (data);
		return false;
	}

	if ( info.width == 1 ) 
		Com_DPrintf(S_COLOR_YELLOW "WARNING: %s is a 8 bit wav file\n", sfx->soundName);

	if ( info.rate != 22050 ) 
		Com_DPrintf(S_COLOR_YELLOW "WARNING: %s is not a 22kHz wav file\n", sfx->soundName);

	samples = reinterpret_cast<short*>(Hunk_AllocateTempMemory(info.samples * sizeof(short) * 2));

	sfx->lastTimeUsed = Com_Milliseconds()+1;

	// each of these compression schemes works just fine
	// but the 16bit quality is much nicer and with a local
	// install assured we can rely upon the sound memory
	// manager to do the right thing for us and page
	// sound in as needed

	if( sfx->soundCompressed == true) 
	{
		sfx->soundCompressionMethod = 1;
		sfx->soundData = NULL;
		sfx->soundLength = ResampleSfxRaw( samples, info.rate, info.width, info.samples, (data + info.dataofs) );
		S_AdpcmEncodeSound(sfx, samples);
	} 
	else 
	{
		sfx->soundCompressionMethod = 0;
		sfx->soundLength = info.samples;
		sfx->soundData = NULL;
		ResampleSfx( sfx, info.rate, info.width, data + info.dataofs, false );
	}
	
	Hunk_FreeTempMemory(samples);
	FS_FreeFile( data );

	return true;
}
开发者ID:MilitaryForces,项目名称:MilitaryForces,代码行数:68,代码来源:snd_mem.c


示例2: PHandler_OpenTempFile

const char* PHandler_OpenTempFile(char* name, char* fullfilepath, int fplen){ // Load a plugin, safe for use

    void *buf;
    int len;
    int wlen;
    char* file;
    char tmpfile[MAX_QPATH];
    char filepath[MAX_QPATH];
	
    Com_sprintf(filepath, sizeof(filepath),"plugins/%s" DLL_EXT, name);

    len = FS_ReadFile(filepath, &buf);

    if(len < 100)
        len = FS_SV_ReadFile( filepath, &buf );

    if(len < 100)
    {
        Com_Printf("No such file found: %s. Can not load this plugin.\n", filepath);
        return NULL;

    }
	
	if(PHandler_VerifyPlugin(buf, len) == qfalse)
	{
	    Com_Printf("%s is not a plugin file or is corrupt or contains disallowed functions.\n", filepath);
		FS_FreeFile(buf);
		return NULL;
	}
	Com_sprintf(tmpfile, sizeof(tmpfile), "plugin.%s.tmp", name);
    /* If there is already such a file remove it now */
    file = FS_SV_GetFilepath( tmpfile, fullfilepath, fplen );
    if(file)
    {
        FS_RemoveOSPath(file);
        file = FS_SV_GetFilepath( tmpfile, fullfilepath, fplen );
        if(file)
        {
            FS_RemoveOSPath(file);
        }
    }
    wlen = FS_SV_HomeWriteFile( tmpfile, buf, len);
    if(wlen != len)
    {
            Com_PrintError("fs_homepath is readonly. Can not load this plugin.\n");
            FS_FreeFile(buf);
            return NULL;
    }
    //Additional test if a file is there and creation of full filepath
    FS_FreeFile(buf);
    return FS_SV_GetFilepath( tmpfile, fullfilepath, fplen );
}
开发者ID:BraXi,项目名称:CoD4X18-Server,代码行数:52,代码来源:plugin_handler.c


示例3: AS_ParseSets

void AS_ParseSets( void ) {
	union {
		char	*c;
		void	*v;
	} as_file;
	char *text_p, *token;

	FS_ReadFile( SOUNDSET_FILE, &as_file.v );

	if ( !as_file.c ) {
		Com_Printf( S_COLOR_RED "ERROR: Couldn't load ambient sound sets from \"%s\"\n", SOUNDSET_FILE );
		return;
	}

	text_p = as_file.c;

	do {
		token = AS_Parse( &text_p );
		if ( !token || !token[0] ) {
			break;
		}
		if ( !strcmp( "type", token ) ) {
			token = AS_Parse( &text_p );
			if( Q_stricmp( token, "ambientset" ) ) {
				Com_Printf( S_COLOR_RED "AS_ParseHeader: Set type \"%s\" is not a valid set type!\n", token );
				FS_FreeFile( as_file.v );
				return;
			}
			continue;
		}
		if ( !strcmp( "amsdir", token ) ) {
			//token = AS_Parse( &text_p );
			AS_SkipRestOfLine( &text_p );
			continue;
		}
		if ( !strcmp( "outdir", token ) ) {
			//token = AS_Parse( &text_p );
			AS_SkipRestOfLine( &text_p );
			continue;
		}
		if ( !strcmp( "basedir", token ) ) {
			//token = AS_Parse( &text_p );
			AS_SkipRestOfLine( &text_p );
			continue;
		}
		//generalSet localSet bmodelSet
	} while ( token );

	FS_FreeFile( as_file.v );
}
开发者ID:Lrns123,项目名称:jkaq3,代码行数:50,代码来源:snd_as.c


示例4: OGG_Check

/*
 * Check if the file is a valid Ogg Vorbis file.
 */
qboolean
OGG_Check(char *name)
{
	qboolean res;        /* Return value. */
	byte *buffer;        /* File buffer. */
	int size;            /* File size. */
	OggVorbis_File ovf;  /* Ogg Vorbis file. */

	if (ogg_check->value == 0)
	{
		return true;
	}

	res = false;

	if ((size = FS_LoadFile(name, (void **)&buffer)) > 0)
	{
		if (ov_test(NULL, &ovf, (char *)buffer, size) == 0)
		{
			res = true;
			ov_clear(&ovf);
		}

		FS_FreeFile(buffer);
	}

	return res;
}
开发者ID:tomgreen66,项目名称:yquake2,代码行数:31,代码来源:ogg.c


示例5: qboolean

////---------------------
/// FFConfigParser::Parse
//-------------------------
//
//
//	Parameters:
//
//	Returns:
//
qboolean FFConfigParser::Parse( void *file )
{
	qboolean result = qboolean( file != NULL );

	if ( file )
	{
		const char *token = 0, *pos = (const char*)file;
		for
		(	token = COM_ParseExt( &pos, qtrue )
		;	token[ 0 ]
		&&	result // fail if any problem
		;	token = COM_ParseExt( &pos, qtrue )
		){
			if ( !stricmp( token, "ffdefaults" ) )
			{
				result &= ParseDefaults( &pos );
			}
			else
			if ( !stricmp( token, "ffsets" ) )
			{
				result &= ParseSets( &pos );
			}
			else
			{
				// unexpected field
				result = qfalse;
			}
		}

		FS_FreeFile( file );
	}

	return result;
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:43,代码来源:ff_ConfigParser.cpp


示例6: Cmd_Exec_f

/*
===============
Cmd_Exec_f
===============
*/
void Cmd_Exec_f( void ) {
	char	*f;
	int		len;
	char	filename[MAX_QPATH];

	if (Cmd_Argc () != 2) {
		Com_Printf ("exec <filename> : execute a script file\n");
		return;
	}

	Q_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );
	COM_DefaultExtension( filename, sizeof( filename ), ".cfg" ); 
	len = FS_ReadFile( filename, (void **)&f);
	if (!f) {
		Com_Printf ("couldn't exec %s\n",Cmd_Argv(1));
		return;
	}
#ifndef FINAL_BUILD
	Com_Printf ("execing %s\n",Cmd_Argv(1));
#endif

	Cbuf_InsertText (f);

	FS_FreeFile (f);
}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:30,代码来源:cmd_common.cpp


示例7: Cmd_Exec_f

/*
===============
Cmd_Exec_f
===============
*/
void Cmd_Exec_f (void)
{
	char	*f, *f2;
	int		len;

	if (Cmd_Argc () != 2)
	{
		Com_Printf ("exec <filename> : execute a script file\n");
		return;
	}

	len = FS_LoadFile (Cmd_Argv(1), (void **)&f);
	if (!f)
	{
		Com_Printf ("couldn't exec %s\n",Cmd_Argv(1));
		return;
	}
	Com_Printf ("execing %s\n",Cmd_Argv(1));
	
	// the file doesn't have a trailing 0, so we need to copy it off
	f2 = (char *) Z_Malloc(len+1);
	memcpy (f2, f, len);
	f2[len] = 0;

	Cbuf_InsertText (f2);

	Z_Free (f2);
	FS_FreeFile (f);
}
开发者ID:raynorpat,项目名称:quake2,代码行数:34,代码来源:cmd.c


示例8: OGG_Stop

/*
 * Stop playing the current file.
 */
void
OGG_Stop(void)
{
	if (ogg_status == STOP)
	{
		return;
	}

#ifdef USE_OPENAL
	if (sound_started == SS_OAL)
	{
		AL_UnqueueRawSamples();
	}
#endif

	ov_clear(&ovFile);
	ogg_status = STOP;
	ogg_info = NULL;
	ogg_numbufs = 0;

	if (ogg_buffer != NULL)
	{
		FS_FreeFile(ogg_buffer);
		ogg_buffer = NULL;
	}
}
开发者ID:tomgreen66,项目名称:yquake2,代码行数:29,代码来源:ogg.c


示例9: Cmd_Exec_f

/*
===============
Cmd_Exec_f
===============
*/
void Cmd_Exec_f( void ) {
    union {
        char	*c;
        void	*v;
    } f;
    int		len;
    char	filename[MAX_QPATH];

    if (Cmd_Argc () != 2) {
        Com_Printf ("exec <filename> : execute a script file\n");
        return;
    }

    Q_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );
    COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
    len = FS_ReadFile( filename, &f.v);
    if (!f.c) {
        Com_Printf ("couldn't exec %s\n",Cmd_Argv(1));
        return;
    }
    Com_Printf ("execing %s\n",Cmd_Argv(1));

    Cbuf_InsertText (f.c);

    FS_FreeFile (f.v);
}
开发者ID:norfenstein,项目名称:umbra,代码行数:31,代码来源:cmd.c


示例10: DoFileFindReplace

static qboolean DoFileFindReplace( LPCSTR psMenuFile, LPCSTR psFind, LPCSTR psReplace )
{
	char *buffer;

	OutputDebugString(va("Loading: \"%s\"\n",psMenuFile));

	int iLen = FS_ReadFile( psMenuFile,(void **) &buffer);
	if (iLen<1) 
	{
		OutputDebugString("Failed!\n");
		assert(0);
		return qfalse;
	}
	

	// find/rep...
	//
	string	str(buffer);
			str += "\r\n";	// safety for *(char+1) stuff


	FS_FreeFile( buffer );	// let go of the buffer

	// originally this kept looping for replacements, but now it only does one (since the find/replace args are repeated
	//	and this is called again if there are >1 replacements of the same strings to be made...
	//
//	int iReplacedCount = 0;
	char *pFound;
	int iSearchPos = 0;
	while ( (pFound = strstr(str.c_str()+iSearchPos,psFind)) != NULL)
	{
		// special check, the next char must be whitespace or carriage return etc, or we're not on a whole-word position...
		//
		int iFoundLoc = pFound - str.c_str();
		char cAfterFind = pFound[strlen(psFind)];
		if (cAfterFind > 32)
		{
			// ... then this string was part of a larger one, so ignore it...
			//
			iSearchPos = iFoundLoc+1;
			continue;
		}		

		str.replace(iFoundLoc, strlen(psFind), psReplace);
//		iSearchPos = iFoundLoc+1;
//		iReplacedCount++;
		break;
	}

//	assert(iReplacedCount);
//	if (iReplacedCount>1)
//	{
//		int z=1;
//	}
	FS_WriteFile( psMenuFile, str.c_str(), strlen(str.c_str()));

	OutputDebugString("Ok\n");

	return qtrue;
}
开发者ID:Agustinlv,项目名称:BlueHarvest,代码行数:60,代码来源:ui_debug.cpp


示例11: CM_LoadQ2BrushModel

/*
* CM_LoadQ2BrushModel
*/
void CM_LoadQ2BrushModel( cmodel_state_t *cms, void *parent, void *buf, bspFormatDesc_t *format ) {
	int i;
	q2dheader_t header;

	cms->cmap_bspFormat = format;

	header = *( q2dheader_t * )buf;
	for( i = 0; i < sizeof( header ) / 4; i++ )
		( (int *)&header )[i] = LittleLong( ( (int *)&header )[i] );
	cms->cmod_base = ( uint8_t * )buf;

	// load into heap
	CMod_LoadTexinfo( cms, &header.lumps[Q2_LUMP_TEXINFO] );
	CMod_LoadPlanes( cms, &header.lumps[Q2_LUMP_PLANES] );
	CMod_LoadBrushSides( cms, &header.lumps[Q2_LUMP_BRUSHSIDES] );
	CMod_LoadBrushes( cms, &header.lumps[Q2_LUMP_BRUSHES] );
	CMod_LoadMarkBrushes( cms, &header.lumps[Q2_LUMP_LEAFBRUSHES] );
	CMod_LoadLeafs( cms, &header.lumps[Q2_LUMP_LEAFS] );
	CMod_LoadNodes( cms, &header.lumps[Q2_LUMP_NODES] );
	CMod_LoadSubmodels( cms, &header.lumps[Q2_LUMP_MODELS] );
	CMod_LoadVisibility( cms, &header.lumps[Q2_LUMP_VISIBILITY] );
	CMod_LoadEntityString( cms, &header.lumps[Q2_LUMP_ENTITIES] );

	FS_FreeFile( buf );
}
开发者ID:Picmip,项目名称:qfusion,代码行数:28,代码来源:cm_q2bsp.c


示例12: Java_xreal_Engine_readFile

/*
 * Class:     xreal_Engine
 * Method:    readFile
 * Signature: (Ljava/lang/String;)[B
 */
jbyteArray JNICALL Java_xreal_Engine_readFile(JNIEnv *env, jclass cls, jstring jfileName)
{
	char           *fileName;
	jbyteArray		array;
	int				length;
	byte           *buf;

	fileName = (char *)((*env)->GetStringUTFChars(env, jfileName, 0));

	length = FS_ReadFile(fileName, (void **)&buf);
	if(!buf)
	{
		return NULL;
	}

	//Com_Printf("Java_xreal_Engine_readFile: file '%s' has length = %i\n", filename, length);

	array = (*env)->NewByteArray(env, length);
	(*env)->SetByteArrayRegion(env, array, 0, length, buf);

	(*env)->ReleaseStringUTFChars(env, jfileName, fileName);

	FS_FreeFile(buf);

	return array;
}
开发者ID:redrumrobot,项目名称:dretchstorm,代码行数:31,代码来源:vm_java.c


示例13: SV_MOTD_LoadFromFile

/*
* SV_MOTD_LoadFromFile
* 
* Attempts to load the MOTD from sv_MOTDFile, on success sets
* sv_MOTDString.
*/
void SV_MOTD_LoadFromFile( void )
{
	char *f;

	FS_LoadFile( sv_MOTDFile->string, (void **)&f, NULL, 0 );
	if( !f )
	{
		Com_Printf( "Couldn't load MOTD file: %s\n", sv_MOTDFile->string );
		Cvar_ForceSet( "sv_MOTDFile", "" );
		SV_MOTD_SetMOTD( "" );
		return;
	}

	if( strchr( f, '"' ) ) // FIXME: others?
	{
		Com_Printf( "Warning: MOTD file contains illegal characters.\n" );
		Cvar_ForceSet( "sv_MOTDFile", "" );
		SV_MOTD_SetMOTD( "" );
	}
	else
	{
		SV_MOTD_SetMOTD( f );
	}

	FS_FreeFile( f );
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:32,代码来源:sv_motd.c


示例14: FS_LoadFile

/*
================
R_LoadWal
================
*/
image_t *R_LoadWal(char *name)
{
  miptex_t *mt;
  int ofs;
  image_t *image;
  int size;

  FS_LoadFile(name, (void **) &mt);
  if (!mt) {
    R_Printf(PRINT_ALL, "R_LoadWal: can't load %s\n", name);
    return r_notexture_mip;
  }

  image = R_FindFreeImage();
  strcpy(image->name, name);
  image->width = LittleLong(mt->width);
  image->height = LittleLong(mt->height);
  image->type = it_wall;
  image->registration_sequence = registration_sequence;

  size = image->width * image->height * (256 + 64 + 16 + 4) / 256;
  image->pixels[0] = malloc(size);
  image->pixels[1] = image->pixels[0] + image->width * image->height;
  image->pixels[2] = image->pixels[1] + image->width * image->height / 4;
  image->pixels[3] = image->pixels[2] + image->width * image->height / 16;

  ofs = LittleLong(mt->offsets[0]);
  memcpy(image->pixels[0], (byte *) mt + ofs, size);

  FS_FreeFile((void *) mt);

  return image;
}
开发者ID:greck2908,项目名称:qengine,代码行数:38,代码来源:sw_image.c


示例15: Cmd_Exec_f

static void Cmd_Exec_f (void)
{
	byte *f;
	char *f2;
	int len;

	if (Cmd_Argc() != 2) {
		Com_Printf("Usage: %s <filename> : execute a script file\n", Cmd_Argv(0));
		return;
	}

	len = FS_LoadFile(Cmd_Argv(1), &f);
	if (!f) {
		Com_Printf("couldn't execute %s\n", Cmd_Argv(1));
		return;
	}
	Com_Printf("executing %s\n", Cmd_Argv(1));

	/* the file doesn't have a trailing 0, so we need to copy it off */
	f2 = (char *)Mem_Alloc(len + 2);
	memcpy(f2, f, len);
	/* make really sure that there is a newline */
	f2[len] = '\n';
	f2[len + 1] = 0;

	Cbuf_InsertText(f2);

	Mem_Free(f2);
	FS_FreeFile(f);
}
开发者ID:chrisglass,项目名称:ufoai,代码行数:30,代码来源:cmd.c


示例16: TEST_F

TEST_F(GameTest, SpawnAndConnect)
{
	char userinfo[MAX_INFO_STRING];
	player_t* player;
	const char* name = "name";
	bool day = true;
	byte* buf;
	/* this entity string may not contain any inline models, we don't have the bsp tree loaded here */
	const int size = FS_LoadFile("game/entity.txt", &buf);
	Edict* e = nullptr;
	int cnt = 0;

	ASSERT_NE(size, -1) << "could not load game/entity.txt.";
	ASSERT_TRUE(size > 0) << "game/entity.txt is empty.";

	SV_InitGameProgs();
	/* otherwise we can't link the entities */
	SV_ClearWorld();

	player = G_PlayerGetNextHuman(0);
	svs.ge->SpawnEntities(name, day, (const char*)buf);
	ASSERT_TRUE(svs.ge->ClientConnect(player, userinfo, sizeof(userinfo))) << "Failed to connect the client";
	ASSERT_FALSE(svs.ge->RunFrame()) << "Failed to run the server logic frame tick";

	while ((e = G_EdictsGetNextInUse(e))) {
		Com_Printf("entity %i: %s\n", cnt, e->classname);
		cnt++;
	}

	ASSERT_EQ(cnt, 43);

	FS_FreeFile(buf);
}
开发者ID:Attect,项目名称:ufoai,代码行数:33,代码来源:test_game.cpp


示例17: R_LoadModel

/**
 * @brief Loads in a model for the given name
 * @param[in] filename Filename relative to base dir and with extension (models/model.md2)
 * @param[inout] mod Structure to initialize
 * @return True if the loading was succeed. True or false structure mod was edited.
 */
static bool R_LoadModel (model_t *mod, const char *filename)
{
	byte *buf;
	int modfilelen;
	char animname[MAX_QPATH];

	if (filename[0] == '\0')
		Com_Error(ERR_FATAL, "R_ModForName: NULL name");

	/* load the file */
	modfilelen = FS_LoadFile(filename, &buf);
	if (!buf)
		return false;

	OBJZERO(*mod);
	Q_strncpyz(mod->name, filename, sizeof(mod->name));

	/* call the appropriate loader */
	switch (LittleLong(*(unsigned *) buf)) {
	case IDALIASHEADER:
		/* MD2 header */
		R_ModLoadAliasMD2Model(mod, buf, modfilelen, true);
		break;

	case DPMHEADER:
		R_ModLoadAliasDPMModel(mod, buf, modfilelen);
		break;

	case IDMD3HEADER:
		/* MD3 header */
		R_ModLoadAliasMD3Model(mod, buf, modfilelen);
		break;

	case IDBSPHEADER:
		Com_Error(ERR_FATAL, "R_ModForName: don't load BSPs with this function");
		break;

	default:
	{
		const char* ext = Com_GetExtension(filename);
		if (ext != NULL && !Q_strcasecmp(ext, "obj"))
			R_LoadObjModel(mod, buf, modfilelen);
		else
			Com_Error(ERR_FATAL, "R_ModForName: unknown fileid for %s", mod->name);
	}
	}

	/* load the animations */
	Com_StripExtension(mod->name, animname, sizeof(animname));
	Com_DefaultExtension(animname, sizeof(animname), ".anm");

	/* try to load the animation file */
	if (FS_CheckFile("%s", animname) != -1) {
		R_ModLoadAnims(&mod->alias, animname);
	}

	FS_FreeFile(buf);

	return true;
}
开发者ID:MyWifeRules,项目名称:ufoai-1,代码行数:66,代码来源:r_model.cpp


示例18: SV_NextDownload_f

/*
==================
SV_NextDownload_f
==================
*/
void SV_NextDownload_f(void){
	int	percent, size, r;

	if(!sv_client->download)
		return;

	r = sv_client->downloadsize - sv_client->downloadcount;
	if(r > 1024)
		r = 1024;

	MSG_WriteByte(&sv_client->netchan.message, svc_download);
	MSG_WriteShort(&sv_client->netchan.message, r);

	sv_client->downloadcount += r;
	size = sv_client->downloadsize;
	if(!size)
		size = 1;
	percent = sv_client->downloadcount * 100 / size;
	MSG_WriteByte(&sv_client->netchan.message, percent);
	SZ_Write(&sv_client->netchan.message,
			  sv_client->download + sv_client->downloadcount - r, r);

	if(sv_client->downloadcount != sv_client->downloadsize)
		return;

	FS_FreeFile(sv_client->download);
	sv_client->download = NULL;
}
开发者ID:luaman,项目名称:qforge-2,代码行数:33,代码来源:sv_user.c


示例19: Cmd_Exec_f

/*
===============
Cmd_Exec_f
===============
*/
void Cmd_Exec_f( void ) {
	qboolean quiet;
	union {
		char	*c;
		void	*v;
	} f;
	char	filename[MAX_QPATH];

	quiet = !Q_stricmp(Cmd_Argv(0), "execq");

	if (Cmd_Argc () != 2) {
		Com_Printf ("exec%s <filename> : execute a script file%s\n",
		            quiet ? "q" : "", quiet ? " without notification" : "");
		return;
	}

	Q_strncpyz( filename, Cmd_Argv(1), sizeof( filename ) );
	COM_DefaultExtension( filename, sizeof( filename ), ".cfg" );
	FS_ReadFile( filename, &f.v);
	if (!f.c) {
		Com_Printf ("couldn't exec %s\n", filename);
		return;
	}
	if (!quiet)
		Com_Printf ("execing %s\n", filename);
	
	Cbuf_InsertText (f.c);

	FS_FreeFile (f.v);
}
开发者ID:darklegion,项目名称:tremulous,代码行数:35,代码来源:cmd.c


示例20: file

/*
==========
OGG_Open

Play Ogg Vorbis file (with absolute or relative index).
==========
*/
qboolean OGG_Open(ogg_seek_t type, int offset)
{
	int		 size;		/* File size. */
	int		 pos;		/* Absolute position. */
	int		 res;		/* Error indicator. */

	pos = -1;

	switch (type) {
	case ABS:
		/* Absolute index. */
		if (offset < 0 || offset >= ogg_numfiles) {
			Com_Printf("OGG_Open: %d out of range.\n", offset+1);
			return (false);
		} else
			pos = offset;
		break;
	case REL:
		/* Simulate a loopback. */
		if (ogg_curfile == -1 && offset < 0)
			offset++;
		while (ogg_curfile + offset < 0)
			offset += ogg_numfiles;
		while (ogg_curfile + offset >= ogg_numfiles)
			offset -= ogg_numfiles;
		pos = ogg_curfile + offset;
		break;
	}

	/* Check running music. */
	if (ogg_status == PLAY) {
		if (ogg_curfile == pos)
			return (true);
		else
			OGG_Stop();
	}

	/* Find file. */
	if ((size = FS_LoadFile(ogg_filelist[pos], (void **)&ogg_buffer)) == -1) {
		Com_Printf("OGG_Open: could not open %d (%s): %s.\n", pos, ogg_filelist[pos], strerror(errno));
		return (false);
	}

	/* Open ogg vorbis file. */
	if ((res = ov_open(NULL, &ovFile, (char *)ogg_buffer, size)) < 0) {
		Com_Printf("OGG_Open: '%s' is not a valid Ogg Vorbis file (error %i).\n", ogg_filelist[pos], res);
		FS_FreeFile(ogg_buffer);
		return (false);
	}

	/* Play file. */
	ovSection = 0;
	ogg_curfile = pos;
	ogg_status = PLAY;

	Com_Printf("Playing file %d '%s'\n", pos, ogg_filelist[pos]);

	return (true);
}
开发者ID:ZwS,项目名称:qudos,代码行数:66,代码来源:snd_ogg.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FS_Gamedir函数代码示例发布时间:2022-05-30
下一篇:
C++ FS_FOpenFileWrite函数代码示例发布时间: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