本文整理汇总了C++中FS_FOpenFileRead函数的典型用法代码示例。如果您正苦于以下问题:C++ FS_FOpenFileRead函数的具体用法?C++ FS_FOpenFileRead怎么用?C++ FS_FOpenFileRead使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FS_FOpenFileRead函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: FS_FOpenFileRead
/*
=================
S_WAV_CodecLoad
=================
*/
void *S_WAV_CodecLoad(const char *filename, snd_info_t *info)
{
fileHandle_t file;
void *buffer;
// Try to open the file
FS_FOpenFileRead(filename, &file, qtrue);
if (!file)
{
if (com_developer->integer)
{
Com_Printf(S_COLOR_RED "ERROR: Could not open \"%s\"\n", filename);
}
return NULL;
}
// Read the RIFF header
if (!S_ReadRIFFHeader(file, info))
{
FS_FCloseFile(file);
if (com_developer->integer)
{
Com_Printf(S_COLOR_RED "ERROR: Incorrect/unsupported format in \"%s\"\n", filename);
}
return NULL;
}
// Allocate some memory
buffer = Z_Malloc(info->size);
if (!buffer)
{
FS_FCloseFile(file);
Com_Printf(S_COLOR_RED "ERROR: Out of memory reading \"%s\"\n", filename);
return NULL;
}
// Read, byteswap
FS_Read(buffer, info->size, file);
S_ByteSwapRawSamples(info->samples, info->width, info->channels, (byte *)buffer);
// Close and return
FS_FCloseFile(file);
return buffer;
}
开发者ID:Classixz,项目名称:etlegacy,代码行数:49,代码来源:snd_codec_wav.c
示例17: LoadJPG
void LoadJPG( const char *filename, unsigned char **pic, int *width, int *height )
{
*pic = NULL;
fileHandle_t h;
const int len = FS_FOpenFileRead( filename, &h, qfalse );
if(!h)
{
return;
}
//JPEG system reads 4K past input buffer so we tack on an additional 4k.
byte *pJPGData = (byte *)Z_Malloc(len + 4096, TAG_TEMP_WORKSPACE, qfalse);
FS_Read(pJPGData, len, h);
FS_FCloseFile( h );
Decompress_JPG( filename, pJPGData, pic, width, height );
Z_Free (pJPGData);
}
开发者ID:CairnTrenor,项目名称:OpenJK,代码行数:19,代码来源:tr_jpeg_interface.cpp
示例18: FS_ReadFile
int FS_ReadFile(const char* path, void** buffer)
{
fileHandle_t handle;
int length = FS_FOpenFileRead(path, &handle, true);
if (length < 0) {
if (buffer)
*buffer = nullptr;
return -1;
}
if (buffer) {
char* buf = new char[length + 1];
*buffer = buf;
FS_Read(buf, length, handle);
buf[length] = '\0';
}
FS_FCloseFile(handle);
return length;
}
开发者ID:Keziolio,项目名称:Unvanquished,代码行数:21,代码来源:files.cpp
示例19: 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;
}
// assume temporary....
byte* 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:Almightygir,项目名称:OpenJK,代码行数:48,代码来源:files_console.cpp
示例20: LAN_LoadCachedServers
/*
====================
LAN_LoadCachedServers
====================
*/
void LAN_LoadCachedServers( void )
{
int size;
fileHandle_t fileIn;
char filename[ MAX_QPATH ];
cls.numglobalservers = cls.numfavoriteservers = 0;
cls.numGlobalServerAddresses = 0;
if ( cl_profile->string[ 0 ] )
{
Com_sprintf( filename, sizeof( filename ), "profiles/%s/servercache.dat", cl_profile->string );
}
else
{
Q_strncpyz( filename, "servercache.dat", sizeof( filename ) );
}
// Arnout: moved to mod/profiles dir
//if (FS_SV_FOpenFileRead(filename, &fileIn)) {
if ( FS_FOpenFileRead( filename, &fileIn, qtrue ) )
{
FS_Read( &cls.numglobalservers, sizeof( int ), fileIn );
FS_Read( &cls.numfavoriteservers, sizeof( int ), fileIn );
FS_Read( &size, sizeof( int ), fileIn );
if ( size == sizeof( cls.globalServers ) + sizeof( cls.favoriteServers ) )
{
FS_Read( &cls.globalServers, sizeof( cls.globalServers ), fileIn );
FS_Read( &cls.favoriteServers, sizeof( cls.favoriteServers ), fileIn );
}
else
{
cls.numglobalservers = cls.numfavoriteservers = 0;
cls.numGlobalServerAddresses = 0;
}
FS_FCloseFile( fileIn );
}
}
开发者ID:ghostmod,项目名称:Unvanquished,代码行数:45,代码来源:cl_ui.c
注:本文中的FS_FOpenFileRead函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论