• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FS_Open函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: nandread

void nandread()
{
	if(*((u32*)0x02ffe230) != 0x4b344445 && *((u32*)0x02ffe230) != 0x484e4145)return;
	void (*FS_InitCtx)(u8*);
	int (*FS_Open)(u8*, char*, u32);
	int (*FS_Close)(u8*);
	int (*FS_Read)(u8*, u8*, u32);
	u8 ctx[0x48];

	if(*((u32*)0x02ffe230) == 0x4b344445)
	{
		FS_InitCtx = (void*)0x20a1c6c;
		FS_Open = (void*)0x20a1ea4;
		FS_Close = (void*)0x20a1f28;
	}
	else if(*((u32*)0x02ffe230) == 0x484e4145)//launcher. note that this launcher stuff is for on-the-fly patching stuff, no nand-based only hax.
	{
		FS_InitCtx = (void*)0x26baf99;
		FS_Open = (void*)0x26bb4c5;
		FS_Close = (void*)0x26bb511;
		FS_Read = (void*)0x26bb581;
	}

	if(*((u32*)0x02ffe230) == 0x4b344445)
	{
		nandread_asm();
		DC_FlushAll();

		REG_IME = 1;
		FS_InitCtx(ctx);
		if(FS_Open(ctx, "nand:/<tmpjump>", 1)==1)FS_Close(ctx);
		REG_IME = 0;
	}
	else if(*((u32*)0x02ffe230) == 0x484e4145)
	{
		REG_IME = 1;
		FS_InitCtx(ctx);
		if(FS_Open(ctx, "nand:/sys/arm7hax.bin", 1)==1)
		{
			FS_Read(ctx, (void*)0x3780260, 0x40);//this is the beginning of the nand_read_sectors func. since this data won't get written there until after that func returns, another read is triggered below.
			FS_Close(ctx);
			FS_InitCtx(ctx);
			if(FS_Open(ctx, "nand:/<tmpjump>", 1)==1)FS_Close(ctx);//unless the arm7hax code returns,(my local code doesn't) this will hang.
		}
		REG_IME = 0;
	}
}
开发者ID:yellows8,项目名称:dsi,代码行数:47,代码来源:exploit.c


示例17: 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;
}
开发者ID:DavidKnight247,项目名称:xash3d,代码行数:58,代码来源:hpak.c


示例18: 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;
}
开发者ID:Adidasman1,项目名称:rehlds,代码行数:59,代码来源:hashpak.cpp


示例19: VERIFY_DATA_TO_DSP_START

void VERIFY_DATA_TO_DSP_START( void )
{
   if( fs_handle )
      FS_Close( fs_handle );
   fs_handle = FS_Open( (const kal_wchar*)fname, FS_CREATE_ALWAYS );
   ASSERT( fs_handle > 0 );
   uDSPBufferSize = 8192;
   uDSPBufferRead = 0;
   uDSPBufferWrite = 0;
}
开发者ID:WayWingsDev,项目名称:testmywatch,代码行数:10,代码来源:audio_service.c


示例20: jma_audio_recorder_timer_expired

/*****************************************************************************
 * FUNCTION
 *  jma_audio_recorder_timer_expired
 * DESCRIPTION
 *  This function handles if audio recorder timer is expired
 * PARAMETERS
 *  mma_type            [IN]
 *  java_recorder       [IN]
 *  int reocrder(?)
 * RETURNS
 *  void
 *****************************************************************************/
void jma_audio_recorder_timer_expired(kal_int32 vm_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint32 record_size = 0;
    kal_int32 ticks = kal_milli_secs_to_ticks(200); /* 200 ms */
    FS_HANDLE file_handle;
    kal_int32 result;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_4, FUNC_J2ME_JMA_AUDIO_RECORDER_TIMER_EXPIRED, vm_id, audio_recorder[vm_id].id, audio_recorder[vm_id].state);
    JMA_CS_ENTER(vm_id, JMA_VOID);

    if (audio_recorder[vm_id].state != JAVA_MEDIA_STATE_RECORDING)
    {
        JMA_CS_LEAVE(JMA_VOID);
    }

    EXT_ASSERT(audio_recorder[vm_id].state == JAVA_MEDIA_STATE_RECORDING, 0, 0, 0);

    /* Get file size */
    file_handle = FS_Open(audio_recorder[vm_id].filename, FS_READ_ONLY | FS_OPEN_SHARED);
    if (file_handle <= 0)
    {
        kal_trace(TRACE_GROUP_4, INFO_J2ME_MMA_MARKER_FAIL);
        kal_trace(TRACE_GROUP_4, INFO_J2ME_MMA_D, file_handle);
        JMA_CS_LEAVE(JMA_VOID);
    }
    result = FS_GetFileSize(file_handle, &record_size);
    result = FS_Close(file_handle);
    if(1 == result)
    {
        kal_trace(TRACE_GROUP_4, INFO_J2ME_MMA_D, record_size+1);
    }
    kal_trace(TRACE_GROUP_4, INFO_J2ME_MMA_D, record_size);

    /* Reach record size limit */
    if (record_size >= audio_recorder[vm_id].record_size_limit)
    {
        /* State will be changed */
        jma_mvm_audio_recorder_commit(vm_id, audio_recorder[vm_id].id);

        jvm_post_mma_event(MMA_EVENT_RECORD_STOPPED,
                           audio_recorder[vm_id].id, audio_recorder[vm_id].current_time);
    }
    else /* re-start timer */
    {
        kal_trace(TRACE_GROUP_4, INFO_J2ME_MMA_STACK_START_TIMER);
        stack_start_timer(&java_media_timer, JAVA_MEDIA_TIMER_AUDIO_RECORDER + vm_id, ticks);
    }
    JMA_CS_LEAVE(JMA_VOID);
}
开发者ID:WayWingsDev,项目名称:testmywatch,代码行数:67,代码来源:jma_audio_recorder.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FS_Printf函数代码示例发布时间:2022-05-30
下一篇:
C++ FS_GetFileList函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap