25 #include <tqptrlist.h>
26 #include <tqcstring.h>
27 #include "kbufferedio.h"
90 inBufIndex(0), outBufIndex(0)
92 inBuf.setAutoDelete(
true);
93 outBuf.setAutoDelete(
true);
106 if (wsize != -2 && wsize != -1)
108 if (rsize != -2 && rsize != -1)
115 int KBufferedIO::bytesAvailable() const
118 qint64 KBufferedIO::bytesAvailable() const
121 return readBufferSize();
125 int KBufferedIO::bytesToWrite() const
128 qint64 KBufferedIO::bytesToWrite() const
131 return writeBufferSize();
137 if (bytesAvailable() == 0)
143 TQPtrList<TQByteArray> &buflist = ((
KBufferedIO*)
this)->inBuf;
144 buf = buflist.first();
152 buf = buflist.next();
187 while (nbytes && buf)
190 unsigned to_copy = buf->size() - index;
191 if (to_copy > nbytes)
195 memcpy(destbuffer + copied, buf->data() + index, to_copy);
199 if (buf->size() - index > to_copy)
226 TQByteArray *buf =
outBuf.first();
239 while ((buf =
outBuf.current()) != NULL)
240 if (buf->size() <= nbytes)
242 nbytes -= buf->size();
258 TQByteArray *a =
new TQByteArray(nbytes);
259 a->duplicate(buffer, nbytes);
274 TQByteArray *a =
new TQByteArray(nbytes);
275 a->duplicate(buffer, nbytes);
283 TQByteArray *buf = ((
KBufferedIO*)
this)->inBuf.first();
286 count += buf->size();
296 TQByteArray *buf = ((
KBufferedIO*)
this)->outBuf.first();
299 count += buf->size();
300 buf = (
const_cast<KBufferedIO*
>(
this))->outBuf.next();
306 void KBufferedIO::virtual_hook(
int id,
void* data )
307 { KAsyncIO::virtual_hook(
id, data ); }
309 #include "kbufferedio.moc"