diff options
Diffstat (limited to '')
-rw-r--r-- | src/buffer.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/buffer.cpp b/src/buffer.cpp index b54f97e..47fab70 100644 --- a/src/buffer.cpp +++ b/src/buffer.cpp | |||
@@ -7,7 +7,7 @@ | |||
7 | 7 | ||
8 | #include "bu/buffer.h" | 8 | #include "bu/buffer.h" |
9 | 9 | ||
10 | Bu::Buffer::Buffer( Bu::Stream &rNext, int iBufSize ) : | 10 | Bu::Buffer::Buffer( Bu::Stream &rNext, int iWhat, int iBufSize ) : |
11 | Bu::Filter( rNext ), | 11 | Bu::Filter( rNext ), |
12 | sSoFar( 0 ), | 12 | sSoFar( 0 ), |
13 | iBufSize( iBufSize ), | 13 | iBufSize( iBufSize ), |
@@ -16,7 +16,8 @@ Bu::Buffer::Buffer( Bu::Stream &rNext, int iBufSize ) : | |||
16 | iReadBufFill( 0 ), | 16 | iReadBufFill( 0 ), |
17 | iReadPos( 0 ), | 17 | iReadPos( 0 ), |
18 | iWriteBufFill( 0 ), | 18 | iWriteBufFill( 0 ), |
19 | iWritePos( 0 ) | 19 | iWritePos( 0 ), |
20 | iWhat( iWhat ) | ||
20 | { | 21 | { |
21 | sReadBuf = new char[iBufSize]; | 22 | sReadBuf = new char[iBufSize]; |
22 | sWriteBuf = new char[iBufSize]; | 23 | sWriteBuf = new char[iBufSize]; |
@@ -51,6 +52,9 @@ void Bu::Buffer::fillReadBuf() | |||
51 | 52 | ||
52 | Bu::size Bu::Buffer::read( void *pBuf, Bu::size nBytes ) | 53 | Bu::size Bu::Buffer::read( void *pBuf, Bu::size nBytes ) |
53 | { | 54 | { |
55 | if( (iWhat&Read) == 0 ) | ||
56 | return rNext.read( pBuf, nBytes ); | ||
57 | |||
54 | if( nBytes <= 0 ) | 58 | if( nBytes <= 0 ) |
55 | { | 59 | { |
56 | fillReadBuf(); | 60 | fillReadBuf(); |
@@ -89,6 +93,9 @@ Bu::size Bu::Buffer::read( void *pBuf, Bu::size nBytes ) | |||
89 | 93 | ||
90 | Bu::size Bu::Buffer::write( const void *pBuf, Bu::size nBytes ) | 94 | Bu::size Bu::Buffer::write( const void *pBuf, Bu::size nBytes ) |
91 | { | 95 | { |
96 | if( (iWhat&Write) == 0 ) | ||
97 | return rNext.write( pBuf, nBytes ); | ||
98 | |||
92 | Bu::size nTotWrote = 0; | 99 | Bu::size nTotWrote = 0; |
93 | 100 | ||
94 | do | 101 | do |
@@ -137,6 +144,9 @@ Bu::size Bu::Buffer::write( const void *pBuf, Bu::size nBytes ) | |||
137 | 144 | ||
138 | void Bu::Buffer::flush() | 145 | void Bu::Buffer::flush() |
139 | { | 146 | { |
147 | if( (iWhat&Write) == 0 ) | ||
148 | return rNext.flush(); | ||
149 | |||
140 | if( iWriteBufFill > 0 ) | 150 | if( iWriteBufFill > 0 ) |
141 | { | 151 | { |
142 | //printf("Buffer: Flushing remaining data, %db.\n", iWriteBufFill ); | 152 | //printf("Buffer: Flushing remaining data, %db.\n", iWriteBufFill ); |