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

@@ -4,6 +4,7 @@
#include <Nazara/Core/Stream.hpp>
#include <Nazara/Core/Error.hpp>
#include <cassert>
#include <Nazara/Core/Debug.hpp>
namespace Nz
@@ -140,29 +141,6 @@ namespace Nz
return (m_openMode & OpenMode::WriteOnly) != 0;
}
inline bool Stream::SetCursorPos(UInt64 offset)
{
if (m_bufferCapacity == 0)
return SeekStreamCursor(offset);
else
{
if (offset >= m_bufferCursor && offset - m_bufferCursor < m_bufferSize)
m_bufferOffset += offset - m_bufferCursor;
else
{
// Out of buffer
if (!SeekStreamCursor(offset))
return false;
m_bufferCursor = offset;
m_bufferOffset = 0;
m_bufferSize = 0;
}
return true;
}
}
/*!
* \brief Writes in the stream the content of a buffer
* \return Size of the writing