Esempio n. 1
0
	virtual bool on_eof_event(abort_callback & p_abort) {
		if (get_no_looping() && m_current == &m_body)
			return false;
		switch_to(m_body);
		raw_seek((t_uint64)0,p_abort);
		return true;
	}
Esempio n. 2
0
ChEXPORT void SsrwOOCacheStream::seek (long in_offset, SsrwOOSeekPos in_pos)
{
    ChLOG_DEBUG_START_FN;

	long offset = in_offset;

	if (in_pos == STG_CUR)
	{
		// the position of the underlying stream is actually m_bytesCached ahead of where the caller thinks it is
		// adjust for this so that the new position is correct
		in_offset -= m_bytesCached;
	}
	else if (in_pos == STG_START)
	{
		// calculate how far (relatively) we are moving in a offset-from-start seek to see if we can just adjust the cache
		offset = in_offset - getPos();
	}
	else
	{
		// seek-from-end will never try to just adjust the cache
		offset = INT_MIN;
	}

	// we have to have some bytes cached to do this, otherwise we don't know that the real underlying stream pos 
	// is in sync with the end of the cache
	if ((offset < (long)m_bytesCached) && (offset >= (m_cache - m_pCurrent)) && (m_bytesCached>0))
	{
		// in this case the offset we are attempting to reach is already in the cache - adjust the cache offset to 
		// point to it and *do not* seek on the underlying stream or clear the cache
		m_pCurrent += offset;
		m_bytesCached -= offset;
		return;
	}

	raw_seek(in_offset, in_pos);

	ClearCache();
}