From 3d763e58b40bea66b77aa4eae7855f2f8c4e103a Mon Sep 17 00:00:00 2001 From: Reece Wilson Date: Mon, 9 Jan 2023 07:02:06 +0000 Subject: [PATCH] [*] ByteBuffer::WriteFromEx flagExpandable awareness [*] ByteBuffer::WriteFrom updates flagWriteError on failure --- Include/Aurora/Memory/ByteBuffer_WriteFrom.inl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Include/Aurora/Memory/ByteBuffer_WriteFrom.inl b/Include/Aurora/Memory/ByteBuffer_WriteFrom.inl index b0149a8f..bb77f52e 100644 --- a/Include/Aurora/Memory/ByteBuffer_WriteFrom.inl +++ b/Include/Aurora/Memory/ByteBuffer_WriteFrom.inl @@ -18,6 +18,12 @@ namespace Aurora::Memory do { auto readView = buffer.GetNextLinearRead(); + + if (this->flagExpandable && !this->CanWrite(readView.length)) + { + this->Resize((this->writePtr - this->base) + readView.length); + } + auto writeView = this->GetNextLinearWrite(); auto uReadNext = AuMin(readView.length, writeView.length); @@ -46,6 +52,8 @@ namespace Aurora::Memory bool ByteBuffer::WriteFrom(ByteBuffer &buffer) { auto readable = buffer.RemainingBytes(); - return this->WriteFromEx(buffer, readable) == readable; + bool bStatus = this->WriteFromEx(buffer, readable) == readable; + this->flagWriteError |= !bStatus; + return bStatus; } } \ No newline at end of file