Fix buffering issues

This commit is contained in:
SirLynix
2022-04-19 13:38:44 +02:00
parent d9ab6720d8
commit 138f2b88b3
14 changed files with 99 additions and 112 deletions

View File

@@ -26,16 +26,6 @@ namespace Nz
m_pos = 0;
}
/*!
* \brief Checks whether the stream reached the end of the stream
* \return true if cursor is at the end of the stream
*/
bool MemoryStream::EndOfStream() const
{
return m_pos >= m_buffer->size();
}
/*!
* \brief Gets the size of the raw memory
* \return Size of the memory
@@ -82,7 +72,7 @@ namespace Nz
std::size_t MemoryStream::ReadBlock(void* buffer, std::size_t size)
{
if (EndOfStream())
if (TestStreamEnd())
return 0;
std::size_t readSize = std::min<std::size_t>(size, static_cast<std::size_t>(m_buffer->GetSize() - m_pos));
@@ -116,6 +106,15 @@ namespace Nz
return m_pos;
}
/*!
* \brief Checks whether the stream reached the end of the stream
* \return true if cursor is at the end of the stream
*/
bool MemoryStream::TestStreamEnd() const
{
return m_pos >= m_buffer->size();
}
/*!
* \brief Writes blocks
* \return Number of blocks written