summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/BStream.h3
-rw-r--r--src/BStream.cc7
2 files changed, 7 insertions, 3 deletions
diff --git a/includes/BStream.h b/includes/BStream.h
index d5b5c17..86b0e0f 100644
--- a/includes/BStream.h
+++ b/includes/BStream.h
@@ -17,6 +17,7 @@ class BStream : public Handle {
int peekNextByte();
String readString(bool putNL = false);
bool isEmpty() { return m_availBytes == 0; }
+ void detach() { m_detached = true; }
private:
IO<Handle> m_h;
uint8_t * m_buffer;
@@ -24,6 +25,8 @@ class BStream : public Handle {
size_t m_cursor;
String m_name;
bool m_passThru;
+ bool m_detached;
+ bool m_closed;
};
};
diff --git a/src/BStream.cc b/src/BStream.cc
index a27cbc5..89e38b0 100644
--- a/src/BStream.cc
+++ b/src/BStream.cc
@@ -11,14 +11,15 @@ Balau::BStream::BStream(const IO<Handle> & h) : m_h(h), m_buffer((uint8_t *) mal
}
void Balau::BStream::close() throw (Balau::GeneralException) {
- m_h->close();
+ if (!m_detached)
+ m_h->close();
free(m_buffer);
m_availBytes = 0;
m_cursor = 0;
}
-bool Balau::BStream::isClosed() { return m_h->isClosed(); }
-bool Balau::BStream::isEOF() { return m_availBytes == 0 && m_h->isEOF(); }
+bool Balau::BStream::isClosed() { return m_closed || m_h->isClosed(); }
+bool Balau::BStream::isEOF() { return (m_availBytes == 0) && m_h->isEOF(); }
bool Balau::BStream::canRead() { return true; }
const char * Balau::BStream::getName() { return m_name.to_charp(); }
off_t Balau::BStream::getSize() { return m_h->getSize(); }