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; }
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; }
size_t MemoryFileImpl::GetPosition() const { return mActBufferId * ONE_BUFFER_SIZE + ( ( mActBufferId < mBuffers.size() ) ? mBuffers[mActBufferId].pos : 0 ); }