StreamingInstance* FileSystemZip::GetStreaming( std::string fileName, int *pSizeOut )
{
	StreamingInstanceZip* pStream;
	zipCacheMap::iterator itor = m_cache.find(m_rootDir+fileName);

	if (itor == m_cache.end())
	{
		return NULL; //not found in this zip
	}

	pStream = new StreamingInstanceZip;

	if (!pStream->Init(m_zipFileName))
	{
		LogMsg("Error opening zip %s for stream", m_zipFileName.c_str());
		delete pStream;
		return NULL;
	}

	if (!m_rootDir.empty())
	{
		pStream->SetRootDirectory(m_rootDir.substr(0, m_rootDir.length()-1));
	}

	if (!pStream->OpenWithCacheEntry(&itor->second))
	{
		LogMsg("Error opening the file %s from the zip %s.", fileName.c_str(), m_zipFileName.c_str());
		delete pStream;
		return NULL;
	}
	
	return pStream;
}
Beispiel #2
0
StreamingInstance * FileSystemZip::GetStreaming( string fileName, int *pSizeOut )
{
	zipCacheMap::iterator itor = m_cache.find(m_rootDir+fileName);

	if (itor == m_cache.end())
	{
		return NULL; //not found in this zip
	}

	
	//ok, we now now that it exists.  Let's create a streaming zip reader and return it.
	//To be able to properly handle multiple file access on the same zip, we have to create a new object that tracks the
	//zip itself.


//	int err = UNZ_OK;

//	err = unzGoToFilePos(m_uf, &itor->second.m_filepos);

	

	StreamingInstanceZip *pStream = new StreamingInstanceZip;

	if (!pStream->Init(m_zipFileName))
	{
		LogMsg("Error opening zip %s for stream", m_zipFileName.c_str());
		delete pStream;
		return NULL;
	}

	if (!m_rootDir.empty())
	{
		pStream->SetRootDirectory(m_rootDir.substr(0, m_rootDir.length()-1));
	}
	if (!pStream->OpenWithCacheEntry(&itor->second))
	{
		LogMsg("Error opening the file %s from the zip %s.", fileName.c_str(), m_zipFileName.c_str());
		delete pStream;
		return NULL;
	}
	
	return pStream;
}