summaryrefslogtreecommitdiffstats
path: root/src/ByteBuffer.cpp
diff options
context:
space:
mode:
authorTycho Bickerstaff <work.tycho@gmail.com>2013-12-11 00:01:35 +0100
committerTycho Bickerstaff <work.tycho@gmail.com>2013-12-11 00:01:35 +0100
commitdd633d5a947771cd37f8a853ceb44660752a7e3c (patch)
tree0141233cb7025eaca681513b6670b325c76f57c1 /src/ByteBuffer.cpp
parentadded tolua++ command and removed stackwalker from build (diff)
parentMerge branch 'master' of https://github.com/mc-server/MCServer (diff)
downloadcuberite-dd633d5a947771cd37f8a853ceb44660752a7e3c.tar
cuberite-dd633d5a947771cd37f8a853ceb44660752a7e3c.tar.gz
cuberite-dd633d5a947771cd37f8a853ceb44660752a7e3c.tar.bz2
cuberite-dd633d5a947771cd37f8a853ceb44660752a7e3c.tar.lz
cuberite-dd633d5a947771cd37f8a853ceb44660752a7e3c.tar.xz
cuberite-dd633d5a947771cd37f8a853ceb44660752a7e3c.tar.zst
cuberite-dd633d5a947771cd37f8a853ceb44660752a7e3c.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;