您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FS_FreeFile函数代码示例

51自学网 2021-06-01 20:43:38
  C++
这篇教程C++ FS_FreeFile函数代码示例写得很实用,希望能帮到您。

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

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

示例1: S_LoadSound

/*==============S_LoadSoundThe filename may be different than sfx->name in the caseof 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,


示例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,


示例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,


示例4: OGG_Check

/* * Check if the file is a valid Ogg Vorbis file. */qbooleanOGG_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,


示例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,


示例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,


示例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,


示例8: OGG_Stop

/* * Stop playing the current file. */voidOGG_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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例20: file

/*==========OGG_OpenPlay 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,


示例21: LoadBSPFile

/** * @sa WriteBSPFile */dMapTile_t* LoadBSPFile (const char* filename){    dBspHeader_t* header;    /* Create this shortcut to mapTiles[0] */    curTile = &mapTiles.mapTiles[0];    /* Set the number of tiles to 1. */    mapTiles.numTiles = 1;    /* load the file header */    int size = FS_LoadFile(filename, (byte**)&header);    if (size == -1)        Sys_Error("'%s' doesn't exist", filename);    /* swap the header */    BSP_SwapHeader(header, filename);    if (header->ident != IDBSPHEADER)        Sys_Error("%s is not a IBSP file", filename);    if (header->version != BSPVERSION)        Sys_Error("%s is version %i, not %i", filename, header->version, BSPVERSION);    curTile->nummodels = CopyLump(header, LUMP_MODELS, curTile->models, sizeof(dBspModel_t));    curTile->numvertexes = CopyLump(header, LUMP_VERTEXES, curTile->vertexes, sizeof(dBspVertex_t));    curTile->numplanes = CopyLump(header, LUMP_PLANES, curTile->planes, sizeof(dBspPlane_t));    curTile->numleafs = CopyLump(header, LUMP_LEAFS, curTile->leafs, sizeof(dBspLeaf_t));    curTile->numnormals = CopyLump(header, LUMP_NORMALS, curTile->normals, sizeof(dBspNormal_t));    curTile->numnodes = CopyLump(header, LUMP_NODES, curTile->nodes, sizeof(dBspNode_t));    curTile->numtexinfo = CopyLump(header, LUMP_TEXINFO, curTile->texinfo, sizeof(dBspTexinfo_t));    curTile->numfaces = CopyLump(header, LUMP_FACES, curTile->faces, sizeof(dBspSurface_t));    curTile->numleafbrushes = CopyLump(header, LUMP_LEAFBRUSHES, curTile->leafbrushes, sizeof(curTile->leafbrushes[0]));    curTile->numsurfedges = CopyLump(header, LUMP_SURFEDGES, curTile->surfedges, sizeof(curTile->surfedges[0]));    curTile->numedges = CopyLump(header, LUMP_EDGES, curTile->edges, sizeof(dBspEdge_t));    curTile->numbrushes = CopyLump(header, LUMP_BRUSHES, curTile->dbrushes, sizeof(dBspBrush_t));    curTile->numbrushsides = CopyLump(header, LUMP_BRUSHSIDES, curTile->brushsides, sizeof(dBspBrushSide_t));    curTile->routedatasize = CopyLump(header, LUMP_ROUTING, curTile->routedata, 1);    curTile->lightdatasize[LIGHTMAP_NIGHT] = CopyLump(header, LUMP_LIGHTING_NIGHT, curTile->lightdata[LIGHTMAP_NIGHT], 1);    curTile->lightdatasize[LIGHTMAP_DAY] = CopyLump(header, LUMP_LIGHTING_DAY, curTile->lightdata[LIGHTMAP_DAY], 1);    curTile->entdatasize = CopyLump(header, LUMP_ENTITIES, curTile->entdata, 1);    /* Because the tracing functions use cBspBrush_t and not dBspBrush_t,     * copy data from curTile->dbrushes into curTile->cbrushes */    OBJZERO(curTile->brushes);    for (int i = 0; i < curTile->numbrushes; i++) {        dBspBrush_t* dbrush = &curTile->dbrushes[i];        cBspBrush_t* brush = &curTile->brushes[i];        brush->firstbrushside = dbrush->firstbrushside;        brush->numsides = dbrush->numsides;        brush->brushContentFlags = dbrush->brushContentFlags;    }    /* everything has been copied out */    FS_FreeFile(header);    /* swap everything */    SwapBSPFile();    return curTile;}
开发者ID:AresAndy,项目名称:ufoai,代码行数:62,


示例22: JK2SP_Register

/************************************************************************************************ * JK2SP_Register : Load given string package file. Register it. * * Inputs: *	Package File name *	Registration flag * * Return: *	success/fail * ************************************************************************************************/qboolean JK2SP_Register(const char *inPackage, unsigned char Registration){	char											*buffer;	char											Package[MAX_QPATH];	int												size;	cStringPackageSingle							*new_sp;	std::map<std::string, cStringPackageSingle *>::iterator	i;	assert(JK2SP_ListByName.size() == JK2SP_ListByID.size());	Q_strncpyz(Package, inPackage, MAX_QPATH);	Q_strupr(Package);	i = JK2SP_ListByName.find(Package);	if (i != JK2SP_ListByName.end())	{		new_sp = (*i).second;	}	else	{		size = FS_ReadFile(va("strip/%s.sp", Package), (void **)&buffer);		if (size == -1)		{			if ( Registration & SP_REGISTER_REQUIRED )			{				Com_Error(ERR_FATAL, "Could not open string package '%s'", Package);			}			return qfalse;		}		// Create the new string package		new_sp = new cStringPackageSingle(Package);		new_sp->Load(buffer, size );		FS_FreeFile(buffer);		if (Registration & SP_REGISTER_CLIENT)		{			Com_DPrintf(S_COLOR_YELLOW "JK2SP_Register: Registered client string package '%s' with ID %02x/n", Package, (int)new_sp->GetID());		}		else		{			Com_DPrintf(S_COLOR_YELLOW "JK2SP_Register: Registered string package '%s' with ID %02x/n", Package, (int)new_sp->GetID());		}		// Insert into the name vs package map		JK2SP_ListByName[Package] = new_sp;		// Insert into the id vs package map		JK2SP_ListByID[new_sp->GetID()] = new_sp;	}	// Or in the new registration data	new_sp->Register(Registration);//	return new_sp;	return qtrue;}
开发者ID:AlexXT,项目名称:OpenJK,代码行数:68,


示例23: CM_LoadShaderFiles

void CM_LoadShaderFiles( void ){	if( !shaderText )	{		char	**shaderFiles1;		int		numShaders1;		char	*buffers[MAX_SHADER_FILES];		int		numShaders;		int		i;		int		sum = 0;		// scan for shader files		shaderFiles1 = FS_ListFiles( "shaders", ".shader", &numShaders1 );		if ( !shaderFiles1 || !numShaders1 )		{			Com_Printf( S_COLOR_YELLOW "WARNING: no shader files found/n" );			return;		}		numShaders = numShaders1;		if ( numShaders > MAX_SHADER_FILES ) 		{			numShaders = MAX_SHADER_FILES;		}		// load and parse shader files		for ( i = 0; i < numShaders1; i++ )		{			char filename[MAX_QPATH];			Com_sprintf( filename, sizeof( filename ), "shaders/%s", shaderFiles1[i] );			Com_DPrintf( "...loading '%s'/n", filename );			FS_ReadFile( filename, (void **)&buffers[i] );			if ( !buffers[i] ) 			{				Com_Error( ERR_FATAL, "Couldn't load %s", filename );			}			sum += COM_Compress( buffers[i] );		}		// build single large buffer		shaderText = (char *)Z_Malloc( sum + numShaders * 2, TAG_SHADERTEXT, qtrue);		// free in reverse order, so the temp files are all dumped		for ( i = numShaders - 1; i >= 0 ; i-- ) 		{			strcat( shaderText, "/n" );			strcat( shaderText, buffers[i] );			FS_FreeFile( buffers[i] );		}		// free up memory		FS_FreeFileList( shaderFiles1 );	}}
开发者ID:3ddy,项目名称:Jedi-Academy,代码行数:56,


示例24: LoadSTB

/* * origname: the filename to be opened, might be without extension * type: extension of the type we wanna open ("jpg", "png" or "tga") * pic: pointer RGBA pixel data will be assigned to */qbooleanLoadSTB(const char *origname, const char* type, byte **pic, int *width, int *height){	char filename[256];	Q_strlcpy(filename, origname, sizeof(filename));	/* Add the extension */	if (strcmp(COM_FileExtension(filename), type) != 0)	{		Q_strlcat(filename, ".", sizeof(filename));		Q_strlcat(filename, type, sizeof(filename));	}	*pic = NULL;	byte* rawdata = NULL;	int rawsize = FS_LoadFile(filename, (void **)&rawdata);	if (rawdata == NULL)	{		return false;	}	int w, h, bytesPerPixel;	byte* data = NULL;	data = stbi_load_from_memory(rawdata, rawsize, &w, &h, &bytesPerPixel, STBI_rgb_alpha);	if (data == NULL)	{		VID_Printf(PRINT_ALL, "stb_image couldn't load data from %s: %s!/n", filename, stbi_failure_reason());		FS_FreeFile(rawdata);		return false;	}	FS_FreeFile(rawdata);	VID_Printf(PRINT_DEVELOPER, "LoadSTB() loaded: %s/n", filename);	*pic = data;	*width = w;	*height = h;	return true;}
开发者ID:Clever-Boy,项目名称:yquake2,代码行数:47,


示例25: S_LoadSampleChunk

static Mix_Chunk* S_LoadSampleChunk (const char *sound){	size_t len;	byte *buf;	const char *soundExtensions[] = SAMPLE_TYPES;	const char **extension = soundExtensions;	SDL_RWops *rw;	Mix_Chunk *chunk;	if (!sound || sound[0] == '*')		return NULL;	len = strlen(sound);	if (len + 4 >= MAX_QPATH) {		Com_Printf("S_LoadSound: MAX_QPATH exceeded for: '%s'/n", sound);		return NULL;	}	while (*extension) {		if ((len = FS_LoadFile(va("sound/%s.%s", sound, *extension++), &buf)) == -1)			continue;		if (!(rw = SDL_RWFromMem(buf, len))){			FS_FreeFile(buf);			continue;		}		if (!(chunk = Mix_LoadWAV_RW(rw, qfalse)))			Com_Printf("S_LoadSound: %s./n", Mix_GetError());		FS_FreeFile(buf);		SDL_FreeRW(rw);		if (chunk)			return chunk;	}	Com_Printf("S_LoadSound: Could not find sound file: '%s'/n", sound);	return NULL;}
开发者ID:chrisglass,项目名称:ufoai,代码行数:41,


示例26: ParseUMP

/** * @brief Parses an ump file that contains the random map definition * @param[in] name The basename of the ump file (without extension) * @param[in] inherit When @c true, this is called to inherit tile definitions * @param[out] entityString An entity string that is used for all map tiles. Parsed from the ump. * from another ump file (no assemblies) */static void ParseUMP (const char* name, char* entityString, bool inherit){	char filename[MAX_QPATH];	byte* buf;	const char* text;	*entityString = '/0';	/* load the map info */	Com_sprintf(filename, sizeof(filename), "maps/%s.ump", name);	FS_LoadFile(filename, &buf);	if (!buf)		return;	/* parse it */	text = (const char*)buf;	do {		const char* token = Com_Parse(&text);		if (!text)			break;		if (Q_streq(token, "extends")) {			token = Com_Parse(&text);			if (inherit)				Com_Printf("ParseUMP: Too many extends in %s 'extends %s' ignored/n", filename, token);			else				ParseUMP(token, entityString, true);		} else if (Q_streq(token, "worldspawn")) {			const char* start = nullptr;			const int length = Com_GetBlock(&text, &start);			if (length == -1) {				Com_Printf("ParseUMP: Not a valid worldspawn block in '%s'/n", filename);			} else {				if (length >= MAX_TOKEN_CHARS) {					Com_Printf("worldspawn is too big - only %i characters are allowed", MAX_TOKEN_CHARS);				} else if (length == 0) {					Com_Printf("no worldspawn settings in ump file/n");				} else {					Q_strncpyz(entityString, start, length);					Com_Printf("use worldspawn settings from ump file/n");				}			}		} else if (token[0] == '{') {			/* ignore unknown block */			text = strchr(text, '}') + 1;			if (!text)				break;		}	} while (text);	/* free the file */	FS_FreeFile(buf);}
开发者ID:nicogiraldi,项目名称:ufoai,代码行数:60,


示例27: OGG_LoadPlaylist

/* * Load playlist. */voidOGG_LoadPlaylist(char *playlist){	byte *buffer; /* Buffer to read the file. */	char *ptr;    /* Pointer for parsing the file. */	int i;		  /* Loop counter. */	int size;     /* Length of buffer and strings. */	/* Open playlist. */	if ((size = FS_LoadFile(va("%s/%s.lst", OGG_DIR, 				  ogg_playlist->string), (void **)&buffer)) < 0)	{		Com_Printf("OGG_LoadPlaylist: could not open playlist: %s./n",				strerror(errno));		return;	}	/* Count the files in playlist. */	for (ptr = strtok((char *)buffer, "/n");		 ptr != NULL;		 ptr = strtok(NULL, "/n"))	{		if ((byte *)ptr != buffer)		{			ptr[-1] = '/n';		}		if (OGG_Check(va("%s/%s", OGG_DIR, ptr)))		{			ogg_numfiles++;		}	}	/* Allocate file list. */	ogg_filelist = malloc(sizeof(char *) * ogg_numfiles);	i = 0;	for (ptr = strtok((char *)buffer, "/n");		 ptr != NULL;		 ptr = strtok(NULL, "/n"))	{		if (OGG_Check(va("%s/%s", OGG_DIR, ptr)))		{			ogg_filelist[i++] = strdup(va("%s/%s", OGG_DIR, ptr));		}	}	/* Free file buffer. */	FS_FreeFile(buffer);}
开发者ID:tomgreen66,项目名称:yquake2,代码行数:54,


示例28: OGG_Stop

/*==========OGG_StopStop playing the current file.==========*/void OGG_Stop(void){	if (ogg_status == STOP)		return;	ov_clear(&ovFile);	ogg_status = STOP;	if (ogg_buffer != NULL) {		FS_FreeFile(ogg_buffer);		ogg_buffer = NULL;	}}
开发者ID:ZwS,项目名称:qudos,代码行数:21,



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


C++ FS_Gamedir函数代码示例
C++ FS_FOpenFileWrite函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。