本文整理汇总了C++中FS_FOpenFileByMode函数的典型用法代码示例。如果您正苦于以下问题:C++ FS_FOpenFileByMode函数的具体用法?C++ FS_FOpenFileByMode怎么用?C++ FS_FOpenFileByMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FS_FOpenFileByMode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FS_FOpenFileByMode
CGenericParser2 *Com_ParseTextFile(const char *file, bool cleanFirst, bool writeable)
{
fileHandle_t f;
int length = 0;
char *buf = 0, *bufParse = 0;
CGenericParser2 *parse;
length = FS_FOpenFileByMode( file, &f, FS_READ );
if (!f || !length)
{
return 0;
}
buf = new char [length + 1];
FS_Read( buf, length, f );
FS_FCloseFile( f );
buf[length] = 0;
bufParse = buf;
parse = new CGenericParser2;
if (!parse->Parse(&bufParse, cleanFirst, writeable))
{
delete parse;
parse = 0;
}
delete[] buf;
return parse;
}
示例2: ME_LoadOverviewAndEntities
static bool ME_LoadOverviewAndEntities( char *filename,
mission_overview_t* overview,
mission_vehicle_t* vehs,
mission_groundInstallation_t* gis)
{
int len;
fileHandle_t f;
char inbuffer[MAX_MISSION_TEXT];
// open the file, fill it into buffer and close it, afterwards parse it
len = FS_FOpenFileByMode( filename, &f, FS_READ );
if ( !f )
{
Com_Printf( va( S_COLOR_RED "file not found: %s\n", filename ) );
return false;
}
if ( len >= MAX_MISSION_TEXT )
{
Com_Printf( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_MISSION_TEXT ) );
FS_FCloseFile( f );
return false;
}
FS_Read2( inbuffer, len, f );
inbuffer[len] = 0;
FS_FCloseFile( f );
Com_Printf( va(S_COLOR_GREEN "Successfully opened mission script: %s\n", filename) );
MF_ParseMissionScripts(inbuffer, overview, vehs, gis);
return true;
}
示例3: getNumberOfFrames
int
Md3Utils::getNumberOfFrames( std::string const& fileName )
{
fileHandle_t file;
if( FS_FOpenFileByMode( fileName.c_str(), &file, FS_READ ) >= 0 )
{
int frames = getNumberOfFrames( file );
FS_FCloseFile( file );
return frames;
}
Com_Printf( "Unable to open file %s\n", fileName.c_str() );
return 0;
}
示例4: getTagInfo
bool
Md3Utils::getTagInfo( std::string const& filename,
std::string const& tagname,
md3Tag_t& tag )
{
bool success = false;
fileHandle_t file;
if( FS_FOpenFileByMode(filename.c_str(), &file, FS_READ) >= 0 )
success = getTagInfo( file, tagname, tag );
else
Com_Error(ERR_FATAL, "Unable to open file %s\n", filename.c_str() );
FS_FCloseFile(file);
return success;
}
示例5: getTagsContaining
int
Md3Utils::getTagsContaining( std::string const& filename,
std::string const& str,
std::vector<md3Tag_t>& tagList )
{
int found = 0;
fileHandle_t file;
if( FS_FOpenFileByMode(filename.c_str(), &file, FS_READ) >= 0 )
found = getTagsContaining( file, str, tagList );
else
Com_Error(ERR_FATAL, "Unable to open file %s\n", filename.c_str() );
FS_FCloseFile(file);
return found;
}
示例6: SV_SetExpectedHunkUsage
/*
====================
SV_SetExpectedHunkUsage
Sets com_expectedhunkusage, so the client knows how to draw the percentage bar
====================
*/
void SV_SetExpectedHunkUsage( char *mapname )
{
int handle;
char *memlistfile = "hunkusage.dat";
char *buf;
char *buftrav;
char *token;
int len;
len = FS_FOpenFileByMode( memlistfile, &handle, FS_READ );
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;
}
示例7: SV_LogPrintf
/////////////////////////////////////////////////////////////////////
// SV_LogPrintf
/////////////////////////////////////////////////////////////////////
void QDECL SV_LogPrintf(const char *fmt, ...) {
va_list argptr;
fileHandle_t file;
fsMode_t mode;
char *logfile;
char buffer[MAX_STRING_CHARS];
int min, tens, sec;
int logsync;
// retrieve the logfile name
logfile = Cvar_VariableString("g_log");
if (!logfile[0]) {
return;
}
// retrieve the writing mode
logsync = Cvar_VariableIntegerValue("g_logSync");
mode = logsync ? FS_APPEND_SYNC : FS_APPEND;
// opening the log file
FS_FOpenFileByMode(logfile, &file, mode);
if (!file) {
return;
}
// get current level time
sec = sv.time / 1000;
min = sec / 60;
sec -= min * 60;
tens = sec / 10;
sec -= tens * 10;
// prepend current level time
Com_sprintf(buffer, sizeof(buffer), "%3i:%i%i ", min, tens, sec);
// get the arguments
va_start(argptr, fmt);
vsprintf(buffer + 7, fmt, argptr);
va_end(argptr);
// write in the log file
FS_Write(buffer, strlen(buffer), file);
FS_FCloseFile(file);
}
示例8: getModelDimensions
bool
Md3Utils::getModelDimensions( std::string const& filename,
vec3_t& mins,
vec3_t& maxs,
int checkFrame )
{
bool success = false;
fileHandle_t file;
if( FS_FOpenFileByMode(filename.c_str(), &file, FS_READ) >= 0 )
success = getModelDimensions( file, mins, maxs, checkFrame );
else
Com_Error(ERR_FATAL, "Unable to open file %s\n", filename.c_str() );
FS_FCloseFile(file);
return success;
}
示例9: RunFrame
void RunFrame( void )
{
try
{
// run the game
Com_Frame();
}
catch ( CWolfException *we )
{
char buffer[ 2048 ];
fileHandle_t handle;
/* *buffer = '\0';
we->BuildErrorMessage( buffer, sizeof( buffer ) );
MessageBox( g_hWnd, buffer, "Error!", MB_OK | MB_ICONEXCLAMATION );*/
*buffer = '\0';
Q_strcat( buffer, sizeof( buffer ), g_Version );
Q_strcat( buffer, sizeof( buffer ), "\r\n" );
we->BuildDump( buffer, sizeof( buffer ) );
we->BuildRegisters( buffer, sizeof( buffer ) );
we->BuildStackTrace( buffer, sizeof( buffer ) );
Q_strcat( buffer, sizeof( buffer ), "\r\n" );
FS_FOpenFileByMode( "crash.log", &handle, FS_APPEND );
if ( handle )
{
FS_Write( buffer, strlen( buffer ), handle );
FS_FCloseFile( handle );
}
delete we;
throw;
}
}
示例10: LoadScriptFile
script_t* LoadScriptFile( const char* filename ) {
char pathname[ MAX_QPATH ];
if ( String::Length( basefolder ) ) {
String::Sprintf( pathname, sizeof ( pathname ), "%s/%s", basefolder, filename );
} else {
String::Sprintf( pathname, sizeof ( pathname ), "%s", filename );
}
fileHandle_t fp;
int length = FS_FOpenFileByMode( pathname, &fp, FS_READ );
if ( !fp ) {
return NULL;
}
void* buffer = Mem_ClearedAlloc( sizeof ( script_t ) + length + 1 );
script_t* script = ( script_t* )buffer;
Com_Memset( script, 0, sizeof ( script_t ) );
String::Cpy( script->filename, filename );
script->buffer = ( char* )buffer + sizeof ( script_t );
script->buffer[ length ] = 0;
script->length = length;
//pointer in script buffer
script->script_p = script->buffer;
//pointer in script buffer before reading token
script->lastscript_p = script->buffer;
//pointer to end of script buffer
script->end_p = &script->buffer[ length ];
//set if there's a token available in script->token
script->tokenavailable = 0;
script->line = 1;
script->lastline = 1;
SetScriptPunctuations( script, NULL );
FS_Read( script->buffer, length, fp );
FS_FCloseFile( fp );
return script;
}
示例11: Com_ParseTextFile
bool Com_ParseTextFile(const char *file, class CGenericParser2 &parser, bool cleanFirst)
{
fileHandle_t f;
int length = 0;
char *buf = 0, *bufParse = 0;
length = FS_FOpenFileByMode( file, &f, FS_READ );
if (!f || !length)
{
return false;
}
buf = new char [length + 1];
FS_Read( buf, length, f );
buf[length] = 0;
bufParse = buf;
parser.Parse(&bufParse, cleanFirst);
delete[] buf;
FS_FCloseFile( f );
return true;
}
示例12: SV_InitAttackLog
void SV_InitAttackLog()
{
if (sv_protectLog->string[0] == '\0')
{
Com_Printf("Not logging server attacks to disk.\n");
}
else
{
// in sync so admins can check this at runtime
FS_FOpenFileByMode(sv_protectLog->string, &attHandle, FS_APPEND_SYNC);
if (attHandle <= 0)
{
Com_Printf("WARNING: Couldn't open server attack logfile %s\n", sv_protectLog->string);
}
else
{
Com_Printf("Logging server attacks to %s\n", sv_protectLog->string);
SV_WriteAttackLog("-------------------------------------------------------------------------------\n");
SV_WriteAttackLog("Start server attack log\n");
SV_WriteAttackLog("-------------------------------------------------------------------------------\n");
}
}
}
示例13: CL_CgameSystemCalls
intptr_t CL_CgameSystemCalls(intptr_t *args)
{
switch (args[0])
{
case CG_PRINT:
Com_Printf("%s", (char *)VMA(1));
return 0;
case CG_ERROR:
Com_Error(ERR_DROP, "%s", (char *)VMA(1));
return 0;
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
Cvar_Register(VMA(1), VMA(2), VMA(3), args[4]);
return 0;
case CG_CVAR_UPDATE:
Cvar_Update(VMA(1));
return 0;
case CG_CVAR_SET:
Cvar_SetSafe(VMA(1), VMA(2));
return 0;
case CG_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer(VMA(1), VMA(2), args[3]);
return 0;
case CG_CVAR_LATCHEDVARIABLESTRINGBUFFER:
Cvar_LatchedVariableStringBuffer(VMA(1), VMA(2), args[3]);
return 0;
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
Cmd_ArgvBuffer(args[1], VMA(2), args[3]);
return 0;
case CG_ARGS:
Cmd_ArgsBuffer(VMA(1), args[2]);
return 0;
case CG_FS_FOPENFILE:
return FS_FOpenFileByMode(VMA(1), VMA(2), args[3]);
case CG_FS_READ:
FS_Read(VMA(1), args[2], args[3]);
return 0;
case CG_FS_WRITE:
return FS_Write(VMA(1), args[2], args[3]);
case CG_FS_FCLOSEFILE:
FS_FCloseFile(args[1]);
return 0;
case CG_FS_GETFILELIST:
return FS_GetFileList(VMA(1), VMA(2), VMA(3), args[4]);
case CG_FS_DELETEFILE:
return FS_Delete(VMA(1));
case CG_SENDCONSOLECOMMAND:
Cbuf_AddText(VMA(1));
return 0;
case CG_ADDCOMMAND:
CL_AddCgameCommand(VMA(1));
return 0;
case CG_REMOVECOMMAND:
Cmd_RemoveCommandSafe(VMA(1));
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand(VMA(1));
return 0;
case CG_UPDATESCREEN:
SCR_UpdateScreen();
return 0;
case CG_CM_LOADMAP:
CL_CM_LoadMap(VMA(1));
return 0;
case CG_CM_NUMINLINEMODELS:
return CM_NumInlineModels();
case CG_CM_INLINEMODEL:
return CM_InlineModel(args[1]);
case CG_CM_TEMPBOXMODEL:
return CM_TempBoxModel(VMA(1), VMA(2), qfalse);
case CG_CM_TEMPCAPSULEMODEL:
return CM_TempBoxModel(VMA(1), VMA(2), qtrue);
case CG_CM_POINTCONTENTS:
return CM_PointContents(VMA(1), args[2]);
case CG_CM_TRANSFORMEDPOINTCONTENTS:
return CM_TransformedPointContents(VMA(1), args[2], VMA(3), VMA(4));
case CG_CM_BOXTRACE:
CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse);
return 0;
case CG_CM_CAPSULETRACE:
CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue);
return 0;
case CG_CM_TRANSFORMEDBOXTRACE:
CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qfalse);
return 0;
case CG_CM_TRANSFORMEDCAPSULETRACE:
CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qtrue);
return 0;
case CG_CM_MARKFRAGMENTS:
return re.MarkFragments(args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7));
case CG_R_PROJECTDECAL:
re.ProjectDecal(args[1], args[2], VMA(3), VMA(4), VMA(5), args[6], args[7]);
return 0;
case CG_R_CLEARDECALS:
re.ClearDecals();
return 0;
//.........这里部分代码省略.........
示例14: variation
/*
====================
CL_UpdateLevelHunkUsage
This updates the "hunkusage.dat" file with the current map and it's hunk usage count
This is used for level loading, so we can show a percentage bar dependant on the amount
of hunk memory allocated so far
This will be slightly inaccurate if some settings like sound quality are changed, but these
things should only account for a small variation (hopefully)
====================
*/
void CL_UpdateLevelHunkUsage(void)
{
int handle;
char *memlistfile = "hunkusage.dat";
char outstr[256];
int len, memusage;
memusage = Cvar_VariableIntegerValue("com_hunkused");
len = FS_FOpenFileByMode(memlistfile, &handle, FS_READ);
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
{
char *buftrav, *outbuftrav;
char *outbuf;
char *token;
char *buf = (char *)Z_Malloc(len + 1);
memset(buf, 0, len + 1);
outbuf = (char *)Z_Malloc(len + 1);
memset(outbuf, 0, len + 1);
FS_Read((void *)buf, len, handle);
FS_FCloseFile(handle);
// now parse the file, filtering out the current map
buftrav = buf;
outbuftrav = outbuf;
outbuftrav[0] = '\0';
while ((token = COM_Parse(&buftrav)) != NULL && token[0])
{
if (!Q_stricmp(token, cl.mapname))
{
// found a match
token = COM_Parse(&buftrav); // read the size
if (token && token[0])
{
if (atoi(token) == memusage) // if it is the same, abort this process
{
Z_Free(buf);
Z_Free(outbuf);
return;
}
}
}
else // send it to the outbuf
{
Q_strcat(outbuftrav, len + 1, token);
Q_strcat(outbuftrav, len + 1, " ");
token = COM_Parse(&buftrav); // read the size
if (token && token[0])
{
Q_strcat(outbuftrav, len + 1, token);
Q_strcat(outbuftrav, len + 1, "\n");
}
else
{
Com_Error(ERR_DROP, "hunkusage.dat file is corrupt");
}
}
}
handle = FS_FOpenFileWrite(memlistfile);
if (handle < 0)
{
Com_Error(ERR_DROP, "cannot create %s", memlistfile);
}
// input file is parsed, now output to the new file
len = strlen(outbuf);
if (FS_Write((void *)outbuf, len, handle) != len)
{
Com_Error(ERR_DROP, "cannot write to %s", memlistfile);
}
FS_FCloseFile(handle);
Z_Free(buf);
Z_Free(outbuf);
}
// now append the current map to the current file
FS_FOpenFileByMode(memlistfile, &handle, FS_APPEND);
if (handle < 0)
{
Com_Error(ERR_DROP, "cannot write to hunkusage.dat, check disk full");
}
Com_sprintf(outstr, sizeof(outstr), "%s %i\n", cl.mapname, memusage);
FS_Write(outstr, strlen(outstr), handle);
FS_FCloseFile(handle);
//.........这里部分代码省略.........
示例15: CL_UISystemCalls
/*
====================
CL_UISystemCalls
The ui module is making a system call
====================
*/
int CL_UISystemCalls( int *args ) {
switch( args[0] ) {
case UI_ERROR:
Com_Error( ERR_DROP, "%s", VMA(1) );
return 0;
case UI_PRINT:
Com_Printf( "%s", VMA(1) );
return 0;
case UI_MILLISECONDS:
return Sys_Milliseconds();
case UI_CVAR_REGISTER:
Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] );
return 0;
case UI_CVAR_UPDATE:
Cvar_Update( VMA(1) );
return 0;
case UI_CVAR_SET:
Cvar_Set( VMA(1), VMA(2) );
return 0;
case UI_CVAR_VARIABLEVALUE:
return FloatAsInt( Cvar_VariableValue( VMA(1) ) );
case UI_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] );
return 0;
case UI_CVAR_SETVALUE:
Cvar_SetValue( VMA(1), VMF(2) );
return 0;
case UI_CVAR_RESET:
Cvar_Reset( VMA(1) );
return 0;
case UI_CVAR_CREATE:
Cvar_Get( VMA(1), VMA(2), args[3] );
return 0;
case UI_CVAR_INFOSTRINGBUFFER:
Cvar_InfoStringBuffer( args[1], VMA(2), args[3] );
return 0;
case UI_ARGC:
return Cmd_Argc();
case UI_ARGV:
Cmd_ArgvBuffer( args[1], VMA(2), args[3] );
return 0;
case UI_CMD_EXECUTETEXT:
Cbuf_ExecuteText( args[1], VMA(2) );
return 0;
case UI_FS_FOPENFILE:
return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] );
case UI_FS_READ:
FS_Read2( VMA(1), args[2], args[3] );
return 0;
case UI_FS_WRITE:
FS_Write( VMA(1), args[2], args[3] );
return 0;
case UI_FS_FCLOSEFILE:
FS_FCloseFile( args[1] );
return 0;
case UI_FS_GETFILELIST:
return FS_GetFileList( VMA(1), VMA(2), VMA(3), args[4] );
case UI_FS_SEEK:
return FS_Seek( args[1], args[2], args[3] );
case UI_R_REGISTERMODEL:
#ifdef IOS_NOTYET
GLimp_AcquireGL();
return re.RegisterModel( VMA(1) );
GLimp_ReleaseGL();
#else
return re.RegisterModel( VMA(1) );
#endif // IOS
case UI_R_REGISTERSKIN:
#ifdef IOS_NOTYET
GLimp_AcquireGL();
return re.RegisterSkin( VMA(1) );
//.........这里部分代码省略.........