1 #ifndef WIBBLE_STREAM_POSIX_H 2 #define WIBBLE_STREAM_POSIX_H 30 PosixBuf() : m_buf(0), m_buf_size(0), m_fd(-1) {}
31 PosixBuf(
int fd,
size_t bufsize = 4096) : m_buf(0), m_buf_size(0), m_fd(-1)
56 m_buf =
new char[1024];
61 setp(m_buf, m_buf + m_buf_size);
86 int fd()
const {
return m_fd; }
103 if (pptr() > pbase())
105 int amount = pptr() - pbase();
106 int res = ::write(m_fd, m_buf, amount);
109 setp(m_buf, m_buf + m_buf_size);
int overflow(int c)
Definition: posix.h:91
Exception thrown when some consistency check fails.
Definition: exception.h:254
int detach()
Sync the PosixBuf and detach it from the file descriptor.
Definition: posix.h:71
~PosixBuf()
Definition: posix.h:35
void attach(int fd, size_t bufsize=4096)
Attach the stream to a file descriptor, using the given stream size.
Definition: posix.h:54
PosixBuf(int fd, size_t bufsize=4096)
Definition: posix.h:31
PosixBuf()
Definition: posix.h:30
int fd() const
Access the underlying file descriptor.
Definition: posix.h:86
Base class for system exceptions.
Definition: exception.h:396
int sync()
Definition: posix.h:101