当前位置: 首页>>代码示例>>C++>>正文


C++ FS_Open函数代码示例

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


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

示例1: Cbuf_AddText

void CServerRemoteAccess::SetValue(const char *variable, const char *value)
{
	FileHandle_t f;
	struct cvar_s *var;

	if (!Q_stricmp(variable, "map"))
	{
		Cbuf_AddText("changelevel ");
		Cbuf_AddText((char*)value);
		Cbuf_AddText("\n");
		Cbuf_Execute();
	}
	else if (!Q_stricmp(variable, "mapcycle"))
	{
		f = FS_Open(mapcyclefile.string, "wt");
		if (!f)
		{
			Con_Printf("Couldn't write to read-only file %s, using file _dev_mapcycle.txt instead.\n", mapcyclefile.string);
			Cvar_DirectSet(&mapcyclefile, "_temp_mapcycle.txt");
			f = FS_Open(mapcyclefile.string, "wt");
		}

		if (f)
		{
			FS_Write(value, Q_strlen(value) + 1, 1, f);
			FS_Close(f);
		}
	}
	else
	{
		var = Cvar_FindVar(variable);
		if (var)
			Cvar_DirectSet(var, value);
	}
}
开发者ID:ChunHungLiu,项目名称:rehlds,代码行数:35,代码来源:sv_remoteaccess.cpp

示例2: 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" );
}
开发者ID:GAMELASTER,项目名称:xash3d,代码行数:64,代码来源:con_utils.c

示例3: 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);
    }

}
开发者ID:12019,项目名称:mtktest,代码行数:62,代码来源:vid_main.c

示例4: 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;
}
开发者ID:WayWingsDev,项目名称:testmywatch,代码行数:35,代码来源:app_asyncfile.c

示例5: SDS_ReadNvramFileInRecord_sim

kal_int32 SDS_ReadNvramFileInRecord_sim(const kal_uint16 *pFilename, kal_uint8* pBuf, kal_uint32 bufLen)
{
   kal_int32 status;
   kal_uint32 readLen, fileLen;
   
   kal_int32 fd = FS_Open(pFilename, FS_OPEN_NO_DIR | FS_READ_ONLY);
   ASSERT(fd >= 0);
   
   status = FS_GetFileSize(fd, &fileLen);
   ASSERT(status >= 0);

   if(pBuf == NULL && bufLen == 0)
   {
      return fileLen;
   }

   if(bufLen < fileLen)
   {
      return SDS_BUF_TOO_SMALL;
   }
   
   status = FS_Read(fd, pBuf, fileLen, &readLen);
   ASSERT(status >= 0 && readLen == fileLen);
   
   FS_Close(fd);

   return readLen;
}
开发者ID:SSizemore,项目名称:MediaTek-HelioX10-Baseband,代码行数:28,代码来源:sds_nvram_support.c

示例6: GPSAppDataBackupWriteAttrFile

static GPSAppDataBackupError_t GPSAppDataBackupWriteAttrFile(kal_bool bNewCreate)
{
	FS_HANDLE file_handle;
	int result;
	kal_uint32 len;
	
	//create file
	file_handle = FS_Open((kal_uint16*)gGPSAppDataBackupAttrFileName, (bNewCreate == KAL_TRUE ? FS_CREATE : 0) | FS_READ_WRITE);
	if (file_handle < FS_NO_ERROR)
	{
		//fail to create
		return GPSAPP_DATABACKUP_ERROR_OPEN_FAIL;
	}
	//write
	result = FS_Write(file_handle, gGPSAppDataBackAttrCache, sizeof(gGPSAppDataBackAttrCache), &len);
	FS_Close(file_handle);
	if (result != FS_NO_ERROR || len != sizeof(gGPSAppDataBackAttrCache))
	{
		return GPSAPP_DATABACKUP_ERROR_WRITE_FAIL;
	}
	else
	{
		return GPSAPP_DATABACKUP_ERROR_NONE;
	}
}
开发者ID:robbie-cao,项目名称:tracker,代码行数:25,代码来源:gps_app_databackup.c

示例7: 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" );
}
开发者ID:ShaunNoWay,项目名称:xash3d,代码行数:40,代码来源:con_utils.c

示例8: Key_EnumCmds_f

void Key_EnumCmds_f( void )
{
	file_t	*f;

	FS_AllowDirectPaths( true );
	if( FS_FileExists( "../help.txt", false ))
	{
		Msg( "help.txt already exist\n" );
		FS_AllowDirectPaths( false );
		return;
	}

	f = FS_Open( "../help.txt", "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\thelp.txt - xash commands and console variables\n");
		FS_Printf( f, "//=======================================================================\n");

		FS_Printf( f, "\n\n\t\t\tconsole variables\n\n");
		Cvar_LookupVars( 0, NULL, f, Cmd_WriteHelp ); 
		FS_Printf( f, "\n\n\t\t\tconsole commands\n\n");
		Cmd_LookupCmds( NULL, f, Cmd_WriteHelp ); 
  		FS_Printf( f, "\n\n");
		FS_Close( f );
		Msg( "help.txt created\n" );
	}
	else MsgDev( D_ERROR, "Couldn't write help.txt.\n");
	FS_AllowDirectPaths( false );
}
开发者ID:ShaunNoWay,项目名称:xash3d,代码行数:31,代码来源:con_utils.c

示例9: 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;
	}
}
开发者ID:robbie-cao,项目名称:tracker,代码行数:30,代码来源:gps_app_nvram_mgr.c

示例10: _fsTraceFileOpen

PRIVATE INT32 _fsTraceFileOpen(CONST CHAR *name,  UINT32 iFlag, UINT32 iMode)
{
    INT32 result;
    INT32 fd = -1;
    UINT32 uni_len = 0;
    UINT8* uni_name = NULL;                
    if((result = ML_LocalLanguage2UnicodeBigEnding(name,  DSM_StrLen(name),&uni_name,&uni_len,NULL) )!= ERR_SUCCESS){
	if(uni_name){
	    CSW_Free(uni_name);
	    uni_name = NULL;
	}                       
	CSW_TRACE(BASE_BAL_TS_ID,"fstrace:%s:%u:ML_LocalLanguage2UnicodeBigEnding ret %d",__FUNCTION__, __LINE__,result);
	return -1;
    }
    
    fd = FS_Open(uni_name,iFlag,iMode);
    
    if(uni_name){
        CSW_Free(uni_name);
        uni_name = NULL;
    }
    
    return fd;
            
}
开发者ID:BarryChen,项目名称:RDA,代码行数:25,代码来源:bal_fstrace.c

示例11: 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 );
}
开发者ID:Xash3DLinux,项目名称:xash3dlinux,代码行数:29,代码来源:gl_rmisc.c

示例12: 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;
}
开发者ID:robbie-cao,项目名称:tracker,代码行数:32,代码来源:gps_app_nvram_mgr.c

示例13: vm_log_init

void vm_log_init(char* filename, int log_level) {
	
	char wfilename[MAX_APP_NAME_LEN];

   	
	def_log_level = log_level;
	log_init = 0;
	strcpy(logModule, MRE_DEFAULT_LOG_MODULE);
	_modFile[0] = 0;
	_cache_file_ = NULL;
	_lineNo = 0;
	_logAllModule = TRUE;
	
	mmi_chset_convert(
				MMI_CHSET_ASCII, 
				MMI_CHSET_UCS2, 				
				(VMCHAR *)filename, 
				(VMCHAR *)wfilename, 
				MAX_APP_NAME_LEN);

	if ((log_file = FS_Open((WCHAR *)wfilename,FS_CREATE_ALWAYS)) < 0) 
	{
		return;
	}

	log_init = 1;
	
}
开发者ID:WayWingsDev,项目名称:testmywatch,代码行数:28,代码来源:vmlog.c

示例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;
}
开发者ID:12019,项目名称:mtktest,代码行数:45,代码来源:ProfileMgr.c

示例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;
    }
}
开发者ID:12019,项目名称:mtktest,代码行数:43,代码来源:ProfileMgr.c


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