示例#1
0
bool MemoryFileImpl::Write( void const* Src, size_t Size )
{
    mSize += Size;
    char const* p = ( char const* )Src;
    while( Size )
    {
        if( mActBufferId >= mBuffers.size() )
        {
            mBuffers.push_back( Buffer_t() );
        }
        const size_t W = mBuffers[mActBufferId].write( p, Size );
        Size -= W;
        p += W;
        if( Size )
        {
            mActBufferId++;
        }
    }
    return true;
}
示例#2
0
bool MemoryFileImpl::Read( void* Data, size_t Size )
{
    if( Size > GetSize() - GetPosition() )
    {
        return false;
    }
    char* p = ( char* )Data;
    while( Size )
    {
        const size_t R = mBuffers[mActBufferId].read( p, Size );
        Size -= R;
        p += R;
        if( Size )
        {
            mActBufferId++;
        }
        if( mActBufferId >= mBuffers.size() )
        {
            return false;
        }
    }
    return true;
}
示例#3
0
size_t MemoryFileImpl::GetPosition() const
{
    return mActBufferId * ONE_BUFFER_SIZE + ( ( mActBufferId < mBuffers.size() ) ? mBuffers[mActBufferId].pos : 0 );
}