void closeFile(PlatformFileHandle& handle) { if (isHandleValid(handle)) { IFILE_Release(handle); handle = invalidPlatformFileHandle; } }
/** * 关闭文件 * @return 文件的引用数 */ int File::close() { if (!good()) return -1; IFILE_SetCacheSize(_File, 0); int ref = IFILE_Release(_File); _File = 0; return ref; }
/*======================================================================= Function: Loc_InitGPSSettings() Description: Initializes the GPS configuration to the default values. =======================================================================*/ uint32 Loc_InitGPSSettings(IShell *pIShell, AEEGPSConfig *gpsConfig) { IFileMgr *pIFileMgr = NULL; IFile *pIConfigFile = NULL; uint32 nResult = 0; if (pIShell == NULL || gpsConfig == NULL) return EFAILED; // Create the instance of IFileMgr nResult = ISHELL_CreateInstance( pIShell, AEECLSID_FILEMGR, (void**)&pIFileMgr ); if ( SUCCESS != nResult ) { return nResult; } // If the config file exists, open it and read the settings. Otherwise, we need to // create a new config file. nResult = IFILEMGR_Test( pIFileMgr, LOC_CONFIG_FILE ); if ( SUCCESS == nResult ) { pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, LOC_CONFIG_FILE, _OFM_READ ); if ( !pIConfigFile ) { nResult = EFAILED; } else { nResult = Loc_ReadGPSSettings( pIConfigFile, gpsConfig ); } } else { pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, LOC_CONFIG_FILE, _OFM_CREATE ); if ( !pIConfigFile ) { nResult = EFAILED; } else { // Setup the default GPS settings gpsConfig->optim = AEEGPS_OPT_DEFAULT; gpsConfig->qos = LOC_QOS_DEFAULT; gpsConfig->server.svrType = AEEGPS_SERVER_DEFAULT; nResult = Loc_WriteGPSSettings( pIConfigFile , gpsConfig); } } // Free the IFileMgr and IFile instances IFILE_Release( pIConfigFile ); IFILEMGR_Release( pIFileMgr ); return nResult; }
/*======================================================================= Function: SamplePosDet_InitGPSSettings() Description: Initializes the GPS configuration to the default values. Prototype: uint32 SamplePosDet_InitGPSSettings( CSamplePosDet *pMe ); Parameters: pMe: [in]. CSamplePosDet instance. Return Value: SUCCESS - If the settings were initialized successfully. Returns error code otherwise. Comments: None Side Effects: None See Also: None =======================================================================*/ uint32 SamplePosDet_InitGPSSettings(CSamplePosDet *pMe) { IFileMgr *pIFileMgr = NULL; IFile *pIConfigFile = NULL; uint32 nResult = 0; // Create the instance of IFileMgr nResult = ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_FILEMGR, (void**)&pIFileMgr ); if ( SUCCESS != nResult ) { return nResult; } // If the config file exists, open it and read the settings. Otherwise, we need to // create a new config file. nResult = IFILEMGR_Test( pIFileMgr, SPD_CONFIG_FILE ); if ( SUCCESS == nResult ) { pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, SPD_CONFIG_FILE, _OFM_READ ); if ( !pIConfigFile ) { nResult = EFAILED; } else { nResult = SamplePosDet_ReadGPSSettings( pMe, pIConfigFile ); } } else { pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, SPD_CONFIG_FILE, _OFM_CREATE ); if ( !pIConfigFile ) { nResult = EFAILED; } else { // Setup the default GPS settings pMe->gpsSettings.optim = AEEGPS_OPT_DEFAULT; pMe->gpsSettings.qos = SPD_QOS_DEFAULT; pMe->gpsSettings.server.svrType = AEEGPS_SERVER_DEFAULT; nResult = SamplePosDet_WriteGPSSettings( pMe, pIConfigFile ); } } // Free the IFileMgr and IFile instances IFILE_Release( pIConfigFile ); IFILEMGR_Release( pIFileMgr ); return nResult; }
/*======================================================================= Function: SamplePosDet_SaveGPSSettings() Description: Opens the configuration file and saves the settings. Prototype: uint32 SamplePosDet_SaveGPSSettings(CSamplePosDet *pMe); Parameters: pMe: [in]. CSamplePosDet instance. Return Value: SUCCESS - If the settings were written successfully. Error code otherwise. Comments: None Side Effects: None See Also: None =======================================================================*/ uint32 SamplePosDet_SaveGPSSettings( CSamplePosDet *pMe ) { IFileMgr *pIFileMgr = NULL; IFile *pIConfigFile = NULL; uint32 nResult = 0; // Create the instance of IFileMgr nResult = ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_FILEMGR, (void**)&pIFileMgr ); if ( SUCCESS != nResult ) { return nResult; } // If the config file exists, open it and read the settings. Otherwise, we need to // create a new config file. nResult = IFILEMGR_Test( pIFileMgr, SPD_CONFIG_FILE ); if ( SUCCESS == nResult ) { pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, SPD_CONFIG_FILE, _OFM_READWRITE ); if ( !pIConfigFile ) { nResult = EFAILED; } else { nResult = SamplePosDet_WriteGPSSettings( pMe, pIConfigFile ); } } else { pIConfigFile = IFILEMGR_OpenFile( pIFileMgr, SPD_CONFIG_FILE, _OFM_CREATE ); if ( !pIConfigFile ) { nResult = EFAILED; } else { nResult = SamplePosDet_WriteGPSSettings( pMe, pIConfigFile ); } } // Free the IFileMgr and IFile instances IFILE_Release( pIConfigFile ); IFILEMGR_Release( pIFileMgr ); return nResult; }
template <> void freeOwnedPtrBrew<IFile>(IFile* ptr) { if (ptr) IFILE_Release(ptr); }
void sk_fclose(SkFILE* f) { SkASSERT(f); IFILE_Release((IFile*)f); }
int AEEStaticMod_New(int16 nSize, IShell *pIShell, void *ph, IModule **ppMod,PFNMODCREATEINST pfnMC,PFNFREEMODDATA pfnMF) { IFileMgr *pFileMgr = NULL; IFile *pFile = NULL; byte *pData = NULL; FileInfo fileinfo ; RunLoadMod pFun = NULL; int nResult = 0; char name[128]; char path[128]; DBGPRINTF( "+++++++++++++++++++++++++++++++++++++++++"); MEMSET(name,0,128*sizeof(char)); MEMSET(path,0,128*sizeof(char)); if(!(SUCCESS == ISHELL_CreateInstance( pIShell , AEECLSID_FILEMGR, (void **) &pFileMgr)) ) goto TagFailModLoader; /* pFile = IFILEMGR_OpenFile( pFileMgr , AEEFS_SHARED_DIR"run.app" ,_OFM_READWRITE); if ( NULL == pFile ){ DBGPRINTF( "Open run.app EFAILED"); IFILEMGR_Release( pFileMgr ); goto TagFailModLoader;} else{ DBGPRINTF( "Open run.app OK"); } IFILE_Read(pFile, name, 128); IFILE_Release(pFile); STRCPY(path,AEEFS_SHARED_DIR); STRCAT(path,name); DBGPRINTF("Load Mod Path:%s",path); DBGPRINTF("Load Mod Name:%s",name);*/ //pFile = IFILEMGR_OpenFile( pFileMgr , "helloworld.bin" ,_OFM_READWRITE);//打开读 和写。 pFile = IFILEMGR_OpenFile( pFileMgr , "flyvideo.mod" ,_OFM_READWRITE);//打开读 和写。 if ( NULL == pFile ){ DBGPRINTF( "Open Mod File EFAILED"); IFILEMGR_Release( pFileMgr ); goto TagFailModLoader;} else{ DBGPRINTF( "Open Mod File OK"); } IFILE_GetInfo(pFile, &fileinfo); pData = (byte *)MALLOC( 4 * fileinfo.dwSize + 5);//pData不用释放,由AEE环境释放 MEMSET( pData , 0x00 , 4 * fileinfo.dwSize + 5); MEMCPY( pData , &ph , 4 ); DBGPRINTF( "Open File OK:%d" , fileinfo.dwSize ); IFILE_Read( pFile , pData + 4 , fileinfo.dwSize ); DBGPRINTF( "Read File OK" ); IFILE_Release( pFile ); IFILEMGR_Release( pFileMgr ); DBGPRINTF("Before RunLoadMod"); pFun = (RunLoadMod)(pData + 4); nResult = pFun(pIShell,ph,ppMod); (*ppMod)->pvt->FreeResources = AEEMod_FreeResources; DBGPRINTF("After RunLoadMod"); DBGPRINTF( "+++++++++++++++++++++++++++++++++++++++++"); return nResult; TagFailModLoader: DBGPRINTF("AEEMod_Load EFAILED"); DBGPRINTF( "+++++++++++++++++++++++++++++++++++++++++"); return EFAILED; }
void deleteOwnedPtr(IFile* ptr) { if (ptr) IFILE_Release(ptr); }