summaryrefslogtreecommitdiffstats
path: root/src/ByteBuffer.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-12-13 17:53:00 +0100
committermadmaxoft <github@xoft.cz>2013-12-13 17:53:26 +0100
commit33c6bcc2f43d2b8556b88a00984f6361b300285a (patch)
tree072632fec5c7abfb9183c1e764406e145484cea5 /src/ByteBuffer.cpp
parentUsing "a_ClosestPlayer != NULL" in cExpOrb. (diff)
downloadcuberite-33c6bcc2f43d2b8556b88a00984f6361b300285a.tar
cuberite-33c6bcc2f43d2b8556b88a00984f6361b300285a.tar.gz
cuberite-33c6bcc2f43d2b8556b88a00984f6361b300285a.tar.bz2
cuberite-33c6bcc2f43d2b8556b88a00984f6361b300285a.tar.lz
cuberite-33c6bcc2f43d2b8556b88a00984f6361b300285a.tar.xz
cuberite-33c6bcc2f43d2b8556b88a00984f6361b300285a.tar.zst
cuberite-33c6bcc2f43d2b8556b88a00984f6361b300285a.zip
Diffstat (limited to '')
-rw-r--r--src/ByteBuffer.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp
index 29f3afbfc..64c03d0d3 100644
--- a/src/ByteBuffer.cpp
+++ b/src/ByteBuffer.cpp
@@ -773,6 +773,28 @@ void cByteBuffer::ReadAll(AString & a_Data)
+bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, int a_NumBytes)
+{
+ if (!a_Dst.CanWriteBytes(a_NumBytes) || !CanReadBytes(a_NumBytes))
+ {
+ // There's not enough source bytes or space in the dest BB
+ return false;
+ }
+ char buf[1024];
+ while (a_NumBytes > 0)
+ {
+ int num = (a_NumBytes > sizeof(buf)) ? sizeof(buf) : a_NumBytes;
+ VERIFY(ReadBuf(buf, num));
+ VERIFY(a_Dst.Write(buf, num));
+ a_NumBytes -= num;
+ }
+ return true;
+}
+
+
+
+
+
void cByteBuffer::CommitRead(void)
{
CHECK_THREAD;