Exemple #1
0
wxInputStream& wxBufferedInputStream::Read(void *buf, size_t size)
{
    // reset the error flag
    Reset();

    // first read from the already cached data
    m_lastcount = GetWBack(buf, size);

    // do we have to read anything more?
    if ( m_lastcount < size )
    {
        size -= m_lastcount;
        buf = (char *)buf + m_lastcount;

        // the call to wxStreamBuffer::Read() below will reset our m_lastcount,
        // so save it
        size_t countOld = m_lastcount;

        m_i_streambuf->Read(buf, size);

        m_lastcount += countOld;
    }

    return *this;
}
Exemple #2
0
wxInputStream& wxBufferedInputStream::Read(void *buf, size_t size)
{
    // reset the error flag
    Reset();

    // first read from the already cached data
    m_lastcount = GetWBack(buf, size);

    // do we have to read anything more?
    if ( m_lastcount < size )
    {
        size -= m_lastcount;
        buf = (char *)buf + m_lastcount;

        // the call to wxStreamBuffer::Read() below may reset our m_lastcount
        // (but it also may not do it if the buffer is associated to another
        // existing stream and wasn't created by us), so save it
        size_t countOld = m_lastcount;

        // the new count of the bytes read is the count of bytes read this time
        m_lastcount = m_i_streambuf->Read(buf, size);

        // plus those we had read before
        m_lastcount += countOld;
    }

    return *this;
}
wxInputStream& wxInputStream::Read(void *buf, size_t size)
{
    char *p = (char *)buf;
    m_lastcount = 0;

    size_t read = GetWBack(buf, size);
    for ( ;; )
    {
        size -= read;
        m_lastcount += read;
        p += read;

        if ( !size )
        {
            // we read the requested amount of data
            break;
        }

        if ( p != buf && !CanRead() )
        {
            // we have already read something and we would block in OnSysRead()
            // now: don't do it but return immediately
            break;
        }

        read = OnSysRead(p, size);
        if ( !read )
        {
            // no more data available
            break;
        }
    }

    return *this;
}
Exemple #4
0
I_IStream& Binary_Stream::get(
	void* 		inBuffer, 
	vuint32 		inHowMuch )
{
	char *p = (char *)inBuffer;
	mLastCount = 0;

	vuint32 read = GetWBack(inBuffer, inHowMuch);
	for( ;; )
	{
/*		if( (vint32)inHowMuch - (vint32)read < 0l )
		{
			int i = 1;
			i;
		}*/

		inHowMuch -= read;
		mLastCount += read;
		p += read;

		if ( !inHowMuch )
		{
			// we read the requested amount of data
			break;
		}

		if ( p != inBuffer && !CanRead() )
		{
			// we have already read something and we would block in DoGet()
			// now: don't do it but return immediately
			break;
		}

		read = DoGet(p, inHowMuch);
		if ( !read )
		{
			// no more data available
			break;
		}
	}

	return * (I_IStream*) this;
}