コード例 #1
0
ファイル: Texture.cpp プロジェクト: ServerGame/Bohge_Engine
	//-------------------------------------------------------------------
	static void png_rw(png_structp png_ptr, png_bytep data, png_size_t length) 
	{
		IFile* file = static_cast<IFile*>(png_ptr->io_ptr);
		file->ReadFile(data, length);
		//File::Instance().ReadFile(data, length, 1, file);
	}
コード例 #2
0
ファイル: Checking.cpp プロジェクト: bohge/Bohge_Engine
	//---------------------------------------------------------------------------------------------------------
	void Checking::OnRequestResourceList( BohgeEngine::IBaseHandle* h )
	{
		if ( IWebProperty::HS_OK != h->GetStatusCode() )
		{
			DEBUGLOG("Can not connect server!\r\n");
		}
		else
		{
			ResourceList Reslist;
			ASSERT( IWebProperty::JS_FINISH == h->GetState() );
			JsonReader webreader;
			webreader.Parse( static_cast<IPostHandle*>(h)->GetResult() );
			JsonEntryInfo webinfo;
			webreader.Read( webinfo );
			m_LocalPath = string( DefaultResource::RESOURCE_PATH ) + webinfo.m_Bundle + PLANTFORMDELIMITER;
			string infopath = m_LocalPath + DefaultResource::LITE_INFO_FILE;
			if ( webinfo.m_isValid )
			{
				IFile* file = IIOSystem::Instance()->FileFactory( infopath );
				file->OpenFile( IFile::AT_READ );
				if ( !file->isOpen() )//如果没打卡,则从新下载相应资源
				{
					_AllResource( Reslist, webinfo );
				}
				else//如果打开了则对比一下
				{
					eastl::string locallif;
					locallif.resize( file->GetSize() );
					file->ReadFile( &locallif[0], file->GetSize() );
					file->CloseFile();
					IIOSystem::Instance()->RecycleBin( file );
					JsonReader loacalreader;
					if( loacalreader.Parse( locallif ) )//可能本地json被损坏导致无法读取
					{
						loacalreader.Read( m_LocalResourceList );
						_CompareResource( Reslist, webinfo );
					}
					else
					{
						DEBUGLOG("Resource list is invaild");
						_AllResource( Reslist, webinfo );
					}
				}
			}
			else
			{
				ASSERT( false && "Application's version is not valiable!\n" );
			}
			if ( !Reslist.empty() )
			{
				DEBUGLOG("Need download resource\n");
				m_pJsonWriter->Open( DefaultResource::APP_VERSION_INT, infopath );
				_DownloadResources( Reslist );
			}
			else
			{
				m_pMutex->Lock();
				m_isFinish = true;
				m_ReleaseList.push_back( h );
				m_pMutex->Unlock();
			}
		}
	}