aboutsummaryrefslogtreecommitdiff
path: root/src/stable/myriadstream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable/myriadstream.cpp')
-rw-r--r--src/stable/myriadstream.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/stable/myriadstream.cpp b/src/stable/myriadstream.cpp
index 50c6924..3c78bb0 100644
--- a/src/stable/myriadstream.cpp
+++ b/src/stable/myriadstream.cpp
@@ -19,7 +19,8 @@ using Bu::Fmt;
19#endif 19#endif
20#include "bu/sio.h" 20#include "bu/sio.h"
21 21
22#define TRACE( x ) Bu::println("%1:%2: %3: %4 - %5").arg(__FILE__).arg( __LINE__ ).arg(__PRETTY_FUNCTION__).arg(rMyriad.sStore.getLocation()).arg(x) 22// #define TRACE( x ) Bu::println("%1:%2: %3: %4 - %5").arg(__FILE__).arg( __LINE__ ).arg(__PRETTY_FUNCTION__).arg(rMyriad.sStore.getLocation()).arg(x)
23#define TRACE( x ) (void)0
23 24
24Bu::MyriadStream::MyriadStream( Bu::Myriad &rMyriad, 25Bu::MyriadStream::MyriadStream( Bu::Myriad &rMyriad,
25 Bu::Myriad::Stream *pStream ) : 26 Bu::Myriad::Stream *pStream ) :
@@ -55,8 +56,8 @@ Bu::size Bu::MyriadStream::read( void *pBuf, Bu::size nBytes )
55 sio << "MyriadStream: read: " << __LINE__ << ": Started, asked to read " << nBytes << "b." 56 sio << "MyriadStream: read: " << __LINE__ << ": Started, asked to read " << nBytes << "b."
56 << sio.nl; 57 << sio.nl;
57#endif 58#endif
58 if( nBytes > (Bu::size)pStream->iSize-iPos ) 59 if( nBytes > (Bu::size)pStream->getSize()-iPos )
59 nBytes = pStream->iSize-iPos; 60 nBytes = pStream->getSize()-iPos;
60 if( nBytes <= 0 ) 61 if( nBytes <= 0 )
61 return 0; 62 return 0;
62 int iLeft = nBytes; 63 int iLeft = nBytes;
@@ -92,7 +93,7 @@ Bu::size Bu::MyriadStream::read( void *pBuf, Bu::size nBytes )
92 rMyriad.iBlockSize - iPos%rMyriad.iBlockSize, 93 rMyriad.iBlockSize - iPos%rMyriad.iBlockSize,
93 iLeft 94 iLeft
94 ), 95 ),
95 pStream->iSize-iPos 96 pStream->getSize()-iPos
96 ); 97 );
97#ifdef MYRIAD_STREAM_DEBUG 98#ifdef MYRIAD_STREAM_DEBUG
98 sio << "MyriadStream: read: " << __LINE__ << ": Copying out bytes: " 99 sio << "MyriadStream: read: " << __LINE__ << ": Copying out bytes: "
@@ -166,14 +167,14 @@ Bu::size Bu::MyriadStream::write( const void *pBuf, Bu::size nBytes )
166 // There are two main writing modes when it comes down to it. 167 // There are two main writing modes when it comes down to it.
167 // Overwrite mode and append mode. Append is what pretty much always 168 // Overwrite mode and append mode. Append is what pretty much always
168 // happens when creating a new stream. 169 // happens when creating a new stream.
169 if( iPos < pStream->iSize ) 170 if( iPos < pStream->getSize() )
170 { 171 {
171 int iAmnt = Bu::buMin( 172 int iAmnt = Bu::buMin(
172 Bu::buMin( 173 Bu::buMin(
173 rMyriad.iBlockSize - iPos%rMyriad.iBlockSize, 174 rMyriad.iBlockSize - iPos%rMyriad.iBlockSize,
174 iLeft 175 iLeft
175 ), 176 ),
176 pStream->iSize-iPos 177 pStream->getSize()-iPos
177 ); 178 );
178#ifdef MYRIAD_STREAM_DEBUG 179#ifdef MYRIAD_STREAM_DEBUG
179 sio << "MyriadStream: write (ovr): " << __LINE__ << ": Copying in bytes: " 180 sio << "MyriadStream: write (ovr): " << __LINE__ << ": Copying in bytes: "
@@ -208,9 +209,9 @@ Bu::size Bu::MyriadStream::write( const void *pBuf, Bu::size nBytes )
208 iAmnt 209 iAmnt
209 ); 210 );
210 iPos += iAmnt; 211 iPos += iAmnt;
211 TRACE(Bu::String("Stream=%1 - pStream->iSize(%2) += iAmnt(%3)").arg(pStream->iId).arg( pStream->iSize ).arg(iAmnt).end()); 212 TRACE(Bu::String("Stream=%1 - pStream->iSize(%2) += iAmnt(%3)").arg(pStream->iId).arg( pStream->getSize() ).arg(iAmnt).end());
212 pStream->iSize += iAmnt; 213 pStream->growTo( pStream->getSize()+iAmnt );
213 TRACE(Bu::String("Stream=%1 - pStream->iSize = %2").arg(pStream->iId).arg( pStream->iSize ).end()); 214 TRACE(Bu::String("Stream=%1 - pStream->iSize = %2").arg(pStream->iId).arg( pStream->getSize() ).end());
214 rMyriad.headerChanged(); 215 rMyriad.headerChanged();
215 pBuf = &((char *)pBuf)[iAmnt]; 216 pBuf = &((char *)pBuf)[iAmnt];
216 iLeft -= iAmnt; 217 iLeft -= iAmnt;
@@ -237,12 +238,12 @@ void Bu::MyriadStream::setPos( Bu::size pos )
237 238
238void Bu::MyriadStream::setPosEnd( Bu::size pos ) 239void Bu::MyriadStream::setPosEnd( Bu::size pos )
239{ 240{
240 iPos = pStream->iSize-pos; 241 iPos = pStream->getSize()-pos;
241} 242}
242 243
243bool Bu::MyriadStream::isEos() 244bool Bu::MyriadStream::isEos()
244{ 245{
245 return iPos >= pStream->iSize; 246 return iPos >= pStream->getSize();
246} 247}
247 248
248bool Bu::MyriadStream::isOpen() 249bool Bu::MyriadStream::isOpen()
@@ -299,7 +300,7 @@ void Bu::MyriadStream::setSize( Bu::size iSize )
299 300
300Bu::size Bu::MyriadStream::getSize() const 301Bu::size Bu::MyriadStream::getSize() const
301{ 302{
302 return pStream->iSize; 303 return pStream->getSize();
303} 304}
304 305
305Bu::size Bu::MyriadStream::getBlockSize() const 306Bu::size Bu::MyriadStream::getBlockSize() const