summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2004-12-21 22:40:24 +0000
committerpixel <pixel>2004-12-21 22:40:24 +0000
commitcb2a6d2b78ad13977fbc4342344abeb8d6a503c0 (patch)
treea25e5c3c5b2cf0256812050f74e1a8b038f299ca /lib
parent713344c7acc276be11261b8584ac176905d9278b (diff)
Huh... Buffers should emulate closing when hitting EOF...
Diffstat (limited to 'lib')
-rw-r--r--lib/Buffer.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Buffer.cc b/lib/Buffer.cc
index 9d2f66a..a9768ba 100644
--- a/lib/Buffer.cc
+++ b/lib/Buffer.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: Buffer.cc,v 1.25 2004-11-27 21:46:04 pixel Exp $ */
+/* $Id: Buffer.cc,v 1.26 2004-12-21 22:40:24 pixel Exp $ */
#include <string.h>
#ifdef HAVE_CONFIG_H
@@ -26,13 +26,13 @@
#include "Buffer.h"
#include "generic.h"
-Buffer::Buffer(bool _seekable) : Handle(-1), buffer(0), zero(0), realsiz(0), bufsiz(0), ptr(0), wptr(0), seekable(_seekable) { }
+Buffer::Buffer(bool _seekable) : Handle(-1), buffer(0), zero(0), realsiz(0), bufsiz(0), ptr(0), wptr(0), seekable(_seekable), got_eof(false) { }
Buffer::~Buffer() {
free(buffer);
}
-Buffer::Buffer(const Buffer & b) : Handle(-1), buffer(0), zero(b.zero), realsiz(b.realsiz), bufsiz(b.bufsiz), ptr(b.ptr), wptr(b.wptr), seekable(b.seekable) {
+Buffer::Buffer(const Buffer & b) : Handle(-1), buffer(0), zero(b.zero), realsiz(b.realsiz), bufsiz(b.bufsiz), ptr(b.ptr), wptr(b.wptr), seekable(b.seekable), got_eof(b.got_eof) {
buffer = (Byte *) malloc(bufsiz);
memcpy(buffer, b.buffer, bufsiz);
}
@@ -60,6 +60,9 @@ ssize_t Buffer::read(void *buf, size_t count) throw (GeneralException) {
count = MIN(count, realsiz - ptr);
if (!count) {
+ if (got_eof)
+ close();
+ got_eof = true;
return 0;
}