本文整理汇总了C++中FS_Close函数的典型用法代码示例。如果您正苦于以下问题:C++ FS_Close函数的具体用法?C++ FS_Close怎么用?C++ FS_Close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FS_Close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cached_io_get_state_and_close
kal_int32 cached_io_get_state_and_close(cached_io_t* io, cached_io_file_state_t* state)
{
kal_int32 ret;
FS_HANDLE fh = io->file_h;
if (fh < 0) {
return -1;
}
ret = cached_io_detach(io);
if (ret < 0) /* there may not be enough space to flush buffers */
{
FS_Close(fh); /* close the file handle anyway */
return ret; /* return error code */
}
if (state) {
cached_io_get_state(fh, state);
}
ret = FS_Close(fh);
ASSERT(ret >= 0);
return ret;
}
示例2: HPAK_ResourceForIndex
qboolean HPAK_ResourceForIndex( const char *filename, int index, resource_t *pRes )
{
file_t *f;
hpak_header_t hdr;
hpak_container_t hpakcontainer;
string pakname;
if( !filename || !filename[0] )
return false;
Q_strncpy( pakname, filename, sizeof( pakname ));
FS_StripExtension( pakname );
FS_DefaultExtension( pakname, ".hpk" );
f = FS_Open( pakname, "rb", false );
FS_Read( f, &hdr, sizeof( hdr ));
if( hdr.ident != IDCUSTOMHEADER )
{
MsgDev( D_ERROR, "HPAK_ResourceForIndex: %s it's not a HPK file.\n", pakname );
FS_Close( f );
return false;
}
if( hdr.version != IDCUSTOM_VERSION )
{
MsgDev( D_ERROR, "HPAK_ResourceForIndex: %s has invalid version (%i should be %i).\n", pakname, hdr.version, IDCUSTOM_VERSION );
FS_Close( f );
return false;
}
FS_Seek( f, hdr.seek, SEEK_SET );
FS_Read( f, &hpakcontainer.count, sizeof( hpakcontainer.count ));
if( hpakcontainer.count < 1 || hpakcontainer.count > MAX_FILES_IN_WAD )
{
MsgDev( D_ERROR, "HPAK_ResourceForIndex: %s has too many lumps %u.\n", pakname, hpakcontainer.count );
FS_Close( f );
return false;
}
if( index < 1 || index > hpakcontainer.count )
{
MsgDev( D_ERROR, "HPAK_ResourceForIndex: %s, lump with index %i doesn't exist.\n", pakname, index );
FS_Close( f );
return false;
}
hpakcontainer.dirs = Z_Malloc( sizeof( hpak_dir_t ) * hpakcontainer.count );
// we could just seek the right data...
FS_Read( f, hpakcontainer.dirs, sizeof( hpak_dir_t ) * hpakcontainer.count );
*pRes = hpakcontainer.dirs[index-1].DirectoryResource;
Mem_Free( hpakcontainer.dirs );
FS_Close( f );
return true;
}
示例3: HPAK_ResourceForIndex
/* <2aac9> ../engine/hashpak.c:772 */
qboolean HPAK_ResourceForIndex(char *pakname, int nIndex, struct resource_s *pResource)
{
hash_pack_header_t header;
hash_pack_directory_t directory;
hash_pack_entry_t *entry;
char name[MAX_PATH];
FileHandle_t fp;
if (cmd_source != src_command)
return FALSE;
Q_snprintf(name, ARRAYSIZE(name), "%s", pakname);
#ifdef REHLDS_FIXES
name[ARRAYSIZE(name) - 1] = 0;
#endif // REHLDS_FIXES
COM_DefaultExtension(name, HASHPAK_EXTENSION);
fp = FS_Open(name, "rb");
if (!fp)
{
Con_Printf("ERROR: couldn't open %s.\n", name);
return FALSE;
}
FS_Read(&header, sizeof(hash_pack_header_t), 1, fp);
if (Q_strncmp(header.szFileStamp, "HPAK", sizeof(header.szFileStamp)))
{
Con_Printf("%s is not an HPAK file\n", name);
FS_Close(fp);
return FALSE;
}
if (header.version != HASHPAK_VERSION)
{
Con_Printf("HPAK_List: version mismatch\n");
FS_Close(fp);
return FALSE;
}
FS_Seek(fp, header.nDirectoryOffset, FILESYSTEM_SEEK_HEAD);
FS_Read(&directory.nEntries, 4, 1, fp);
if (directory.nEntries < 1 || (unsigned int)directory.nEntries > MAX_FILE_ENTRIES)
{
Con_Printf("ERROR: HPAK had bogus # of directory entries: %i\n", directory.nEntries);
FS_Close(fp);
return FALSE;
}
if (nIndex < 1 || nIndex > directory.nEntries)
{
Con_Printf("ERROR: HPAK bogus directory entry request: %i\n", nIndex);
FS_Close(fp);
return FALSE;
}
directory.p_rgEntries = (hash_pack_entry_t *)Mem_Malloc(sizeof(hash_pack_entry_t) * directory.nEntries);
FS_Read(directory.p_rgEntries, sizeof(hash_pack_entry_t) * directory.nEntries, 1, fp);
entry = &directory.p_rgEntries[nIndex - 1];
Q_memcpy(pResource, &entry->resource, sizeof(resource_t));
FS_Close(fp);
Mem_Free(directory.p_rgEntries);
return TRUE;
}
示例4: Host_WriteConfig
/*
===============
Host_WriteConfig
Writes key bindings and archived cvars to config.cfg
===============
*/
void Host_WriteConfig( void )
{
kbutton_t *mlook, *jlook;
file_t *f;
// if client not loaded, client cvars will lost
if( !clgame.hInstance )
{
MsgDev( D_NOTE, "Client not loaded, skipping config save!\n" );
return;
}
MsgDev( D_NOTE, "Host_WriteConfig()\n" );
f = FS_Open( "config.cfg", "w", true );
if( f )
{
FS_Printf( f, "//=======================================================================\n");
FS_Printf( f, "//\t\t\tCopyright XashXT Group %s ©\n", Q_timestamp( TIME_YEAR_ONLY ));
FS_Printf( f, "//\t\t\tconfig.cfg - archive of cvars\n" );
FS_Printf( f, "//=======================================================================\n" );
Cmd_WriteVariables( f );
FS_Printf( f, "exec keyboard.cfg\n" );
FS_Printf( f, "exec userconfig.cfg\n" );
FS_Close( f );
}
else MsgDev( D_ERROR, "Couldn't write config.cfg.\n" );
if( cls.initialized && ( cls.keybind_changed || !FS_FileExists( "keyboard.cfg", true ) ) )
{
f = FS_Open( "keyboard.cfg", "w", true );
if( f )
{
FS_Printf( f, "//=======================================================================\n");
FS_Printf( f, "//\t\t\tCopyright XashXT Group %s ©\n", Q_timestamp( TIME_YEAR_ONLY ));
FS_Printf( f, "//\t\t\tkeyboard.cfg - archive of keybindings\n" );
FS_Printf( f, "//=======================================================================\n" );
Key_WriteBindings( f );
mlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_mlook" );
jlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_jlook" );
if( mlook && ( mlook->state & 1 ))
FS_Printf( f, "+mlook\n" );
if( jlook && ( jlook->state & 1 ))
FS_Printf( f, "+jlook\n" );
FS_Close( f );
}
else MsgDev( D_ERROR, "Couldn't write keyboard.cfg.\n" );
}
else
MsgDev( D_NOTE, "Keyboard configuration not changed\n" );
}
示例5: HPAK_FlushHostQueue
/* <2ae8e> ../engine/hashpak.c:1599 */
NOXREF char *HPAK_GetItem(int item)
{
NOXREFCHECK;
int nCurrent;
hash_pack_header_t header;
hash_pack_directory_t directory;
hash_pack_entry_t *entry;
static char name[MAX_PATH];
char szFileName[MAX_PATH];
FileHandle_t fp;
HPAK_FlushHostQueue();
Q_snprintf(name, ARRAYSIZE(name), "%s", "custom");
COM_DefaultExtension(name, HASHPAK_EXTENSION);
fp = FS_Open(name, "rb");
if (!fp)
return "";
FS_Read(&header, sizeof(hash_pack_header_t), 1, fp);
if (Q_strncmp(header.szFileStamp, "HPAK", sizeof(header.szFileStamp)))
{
Con_Printf("%s is not an HPAK file\n", name);
FS_Close(fp);
return "";
}
if (header.version != HASHPAK_VERSION)
{
Con_Printf("HPAK_List: version mismatch\n");
FS_Close(fp);
return "";
}
FS_Seek(fp, header.nDirectoryOffset, FILESYSTEM_SEEK_HEAD);
FS_Read(&directory.nEntries, 4, 1, fp);
if (directory.nEntries < 1 || (unsigned int)directory.nEntries > MAX_FILE_ENTRIES)
{
Con_Printf("ERROR: HPAK had bogus # of directory entries: %i\n", directory.nEntries);
FS_Close(fp);
return "";
}
directory.p_rgEntries = (hash_pack_entry_t *)Mem_Malloc(sizeof(hash_pack_entry_t) * directory.nEntries);
FS_Read(directory.p_rgEntries, sizeof(hash_pack_entry_t) * directory.nEntries, 1, fp);
nCurrent = directory.nEntries - 1;
if (nCurrent > item)
nCurrent = item;
entry = &directory.p_rgEntries[nCurrent];
COM_FileBase(entry->resource.szFileName, szFileName);
Q_snprintf(name, sizeof(name), "!MD5%s", MD5_Print(entry->resource.rgucMD5_hash));
FS_Close(fp);
Mem_Free(directory.p_rgEntries);
return name;
}
示例6: xml_generate_inline_element
/*****************************************************************************
* FUNCTION
* xml_generate_inline_element
* DESCRIPTION
* This function is for application to generate a whole element without child element
* and attribute, only content. just as following: <a> test </a>.
* PARAMETERS
* hd [IN] handle of generator
* el [IN] element name
* data [IN] Filename or buffer with data.
* datalen [IN] if with buffer, datalen is the length of buffer,
* if with file, datalen should be 0
* RETURNS
* <0: means failed, returns error code;
* 0 : means succeed;
*****************************************************************************/
kal_int32 xml_generate_inline_element(XG_HANDLE hd, const kal_char* el, kal_char* data, kal_uint32 datalen)
{
kal_int32 ret;
kal_uint32 len_read, len;
FS_HANDLE fhandle = -1;
kal_char tempbuf[TEMP_BUF_LEN];
if ((ret = xml_generate_stag(hd, el, NULL, 0)) < 0)
{
return ret;
}
if (datalen == 0)
{
fhandle = FS_Open((WCHAR*)data, FS_READ_ONLY);
if (fhandle < 0)
{
return XG_E_FAIL;
}
ret = FS_GetFileSize(fhandle, &len);
if (ret < 0)
{
FS_Close(fhandle);
return XG_E_FAIL;
}
while ((ret = FS_Read(fhandle, tempbuf, TEMP_BUF_LEN-1, &len_read)) >= FS_NO_ERROR)
{
if (len_read == 0)
{
break;
}
if ((ret=xml_generate_converted_data(hd, tempbuf, len_read)) < 0)
{
return ret;
}
}
FS_Close(fhandle);
}
else
{
if ((ret = xml_generate_converted_data(hd, data, datalen)) < 0)
{
return ret;
}
}
/*
if ((ret = xml_generate_data(hd, data, datalen)) < 0)
{
return ret;
}
*/
return xml_generate_etag(hd, el);
}
示例7: vid_create_dummy_video_file
/*****************************************************************************
* FUNCTION
* vid_create_dummy_video_file
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void vid_create_dummy_video_file(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FS_HANDLE fd = -1;
kal_uint32 len;
kal_int32 result;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
#ifdef __NVRAM_IN_USB_MS__
if (stack_query_boot_mode() == USBMS_BOOT)
{
return;
}
#endif /* __NVRAM_IN_USB_MS__ */
/* creat folder */
fd = FS_Open((kal_uint16*)VID_SYSTEM_FOLDER, FS_OPEN_DIR | FS_READ_ONLY);
if (fd >= 0)
{
/* path already exist */
FS_Close(fd);
}
else
{
/* file not exist */
fd = FS_CreateDir((kal_uint16*)VID_SYSTEM_FOLDER);
}
if ((fd = FS_Open((kal_wchar*) VID_DUMMY_INIT_FILE, FS_READ_ONLY)) >= 0)
{
FS_Close(fd);
return;
}
else if ((fd = FS_Open((kal_wchar*) VID_INIT_FILE, FS_READ_ONLY)) >= 0)
{
FS_Close(fd);
/* FS_Rename((kal_wchar*)VID_INIT_FILE, (kal_wchar*)VID_DUMMY_INIT_FILE); */
return;
}
fd = FS_Open((kal_wchar*) VID_DUMMY_INIT_FILE, FS_CREATE | FS_READ_WRITE);
if (fd >= 0)
{
result = FS_Write(fd, DUMMY_VIDEO_FILE_CONTENT, kal_wstrlen(DUMMY_VIDEO_FILE_CONTENT) * ENCODE_BYTE, &len);
FS_Close(fd);
}
}
示例8: GPSLocateNvramStoreData
static kal_bool GPSLocateNvramStoreData(void)
{
FS_HANDLE file_handle;
int result;
unsigned int len;
if (app_ucs2_strlen((const kal_int8*)gGPSLocateNvramFullPathFileName) == 0)
{
//empty file name
return KAL_FALSE;
}
//open file
file_handle = FS_Open(gGPSLocateNvramFullPathFileName, FS_READ_WRITE);
if (file_handle < FS_NO_ERROR)
{
//fail to open
return KAL_FALSE;
}
//write
result = FS_Write(file_handle, &(gGPSLocateNvramDataCache.Cache), sizeof(GPSLocateNvramDataStruct_t), &len);
FS_Close(file_handle);
if (result != FS_NO_ERROR || len != sizeof(GPSLocateNvramDataStruct_t))
{
return KAL_FALSE;
}
else
{
return KAL_TRUE;
}
}
示例9: GPSLocateNvramLoadData
static kal_bool GPSLocateNvramLoadData(void)
{
FS_HANDLE file_handle;
int result;
unsigned int len;
GPSLocateNvramDataStruct_t tmpCache;
if (app_ucs2_strlen((const kal_int8*)gGPSLocateNvramFullPathFileName) == 0)
{
//empty file name
return KAL_FALSE;
}
//open file
file_handle = FS_Open(gGPSLocateNvramFullPathFileName, FS_READ_ONLY);
if (file_handle < FS_NO_ERROR)
{
//fail to open
return KAL_FALSE;
}
//read
result = FS_Read(file_handle, &tmpCache, sizeof(GPSLocateNvramDataStruct_t), &len);
FS_Close(file_handle);
if (result != FS_NO_ERROR || len != sizeof(GPSLocateNvramDataStruct_t))
{
//read fail
return KAL_FALSE;
}
//copy data to global cache
memcpy(&(gGPSLocateNvramDataCache.Cache), &tmpCache, sizeof(GPSLocateNvramDataStruct_t));
gGPSLocateNvramDataCache.Valid = KAL_TRUE;
return KAL_TRUE;
}
示例10: CL_StopPlayback
/*
==============
CL_StopPlayback
Called when a demo file runs out, or the user starts a game
==============
*/
void CL_StopPlayback( void )
{
if( !cls.demoplayback ) return;
// release demofile
FS_Close( cls.demofile );
cls.demoplayback = false;
demo.framecount = 0;
cls.demofile = NULL;
cls.olddemonum = max( -1, cls.demonum - 1 );
Mem_Free( demo.directory.entries );
demo.directory.numentries = 0;
demo.directory.entries = NULL;
demo.entry = NULL;
cls.demoname[0] = '\0'; // clear demoname too
menu.globals->demoname[0] = '\0';
S_StopAllSounds();
S_StopBackgroundTrack();
if( !cls.changedemo )
{
// let game known about demo state
Cvar_FullSet( "cl_background", "0", CVAR_READ_ONLY );
cls.state = ca_disconnected;
cl.background = 0;
cls.demonum = -1;
}
}
示例11: applib_get_file_size
/*****************************************************************************
* FUNCTION
* applib_get_file_size
* DESCRIPTION
* This function is used to get the size of one file.
* PARAMETERS
* filename [IN] The filename
* RETURNS
* file size.
*****************************************************************************/
kal_uint32 applib_get_file_size(kal_wchar *filename)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 fileHandle;
kal_uint32 fileSize = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (filename == NULL)
{
return 0;
}
fileHandle = FS_Open(filename, APPLIB_ASYNC_FILE_READ | FS_NONBLOCK_MODE | FS_OPEN_SHARED);
if (fileHandle < 0)
{
return 0;
}
FS_GetFileSize(fileHandle, &fileSize);
FS_Close(fileHandle);
return fileSize;
}
示例12: Host_WriteConfig
/*
===============
Host_WriteConfig
Writes key bindings and archived cvars to config.cfg
===============
*/
void Host_WriteConfig( void )
{
kbutton_t *mlook, *jlook;
file_t *f;
if( !clgame.hInstance ) return;
MsgDev( D_NOTE, "Host_WriteConfig()\n" );
f = FS_Open( "config.cfg", "w", false );
if( f )
{
FS_Printf( f, "//=======================================================================\n");
FS_Printf( f, "//\t\t\tCopyright XashXT Group %s ©\n", Q_timestamp( TIME_YEAR_ONLY ));
FS_Printf( f, "//\t\t\tconfig.cfg - archive of cvars\n" );
FS_Printf( f, "//=======================================================================\n" );
Key_WriteBindings( f );
Cmd_WriteVariables( f );
mlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_mlook" );
jlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_jlook" );
if( mlook && ( mlook->state & 1 ))
FS_Printf( f, "+mlook\n" );
if( jlook && ( jlook->state & 1 ))
FS_Printf( f, "+jlook\n" );
FS_Printf( f, "exec userconfig.cfg" );
FS_Close( f );
}
else MsgDev( D_ERROR, "Couldn't write config.cfg.\n" );
}
示例13: R_CreateDetailTexturesList
void R_CreateDetailTexturesList( const char *filename )
{
file_t *detail_txt = NULL;
const char *detail_name, *texname;
int i;
for( i = 0; i < cl.worldmodel->numtextures; i++ )
{
texname = cl.worldmodel->textures[i]->name;
detail_name = R_DetailTextureForName( texname );
if( !detail_name ) continue;
// detailtexture detected
if( detail_name )
{
if( !detail_txt ) detail_txt = FS_Open( filename, "w", false );
if( !detail_txt )
{
MsgDev( D_ERROR, "Can't write %s\n", filename );
break;
}
// store detailtexture description
FS_Printf( detail_txt, "%s detail/%s 10.0 10.0\n", texname, detail_name );
}
}
if( detail_txt ) FS_Close( detail_txt );
}
示例14: PmgCheckImyMidFileSize
/*****************************************************************************
* FUNCTION
* PmgCheckImyMidFileSize
* DESCRIPTION
*
* PARAMETERS
* path [?]
* RETURNS
*
*****************************************************************************/
PMG_ADDFILE_ERRNO PmgCheckImyMidFileSize(S8 *path)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S8 *file_ext_p;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
file_ext_p = PmgGetFileExt(path);
if (mmi_ucs2ncmp(file_ext_p, (S8*) L"mid", 3) == 0 || mmi_ucs2ncmp(file_ext_p, (S8*) L"MID", 3) == 0
|| mmi_ucs2ncmp(file_ext_p, (S8*) L"imy", 3) == 0 || mmi_ucs2ncmp(file_ext_p, (S8*) L"IMY", 3) == 0)
{
FS_HANDLE h;
kal_uint32 file_size = 0; /* U32 file_size=0; */
h = FS_Open((U16*) path, FS_READ_ONLY);
if (h)
{
FS_GetFileSize(h, &file_size);
FS_Close(h);
}
else
{
return PMG_ADDFILE_ERR_UNKNOWN;
}
if (file_size > mdi_audio_get_midi_size_limit() )
{
return PMG_ADDFILE_ERR_FILE_TOO_LARGE;
}
}
return PMG_ADDFILE_ERR_SUCCESS;
}
示例15: PmgQueryFileExistBySlot
/*****************************************************************************
* FUNCTION
* PmgQueryFileExistBySlot
* DESCRIPTION
*
* PARAMETERS
* slot [IN]
* RETURNS
*
*****************************************************************************/
BOOL PmgQueryFileExistBySlot(U8 slot)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S8 buf[MAX_EXT_MELODY_FULLNAME_WIDTH];
FS_HANDLE h;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (slot > MAXIMUM_EXT_MELODY_NUM)
{
return MMI_FALSE;
}
PmgConstructPathFileName(
buf,
sizeof(buf),
(S8*) gPmgExtMelodyInfo.info[slot].filepath,
(S8*) gPmgExtMelodyInfo.info[slot].filename);
h = FS_Open((WCHAR*)buf, FS_READ_ONLY);
if (h > 0)
{
FS_Close(h);
return MMI_TRUE;
}
else
{
return MMI_FALSE;
}
}