From ac5fb6be210b63fd7216541679f513dc97491ede Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 31 Jul 2009 17:53:02 +0000 Subject: Wow, Bu::Base64 had a bug about premature end of stream / not base64 data, now it throws exceptions. It'll still try to process bad data for a while though. Also, it turns out that Bu::File never reported EOS, now it does, appropriately. I'm about to change Bu::Stream::isEOS to be Bu::Stream::isEos, this is your warning. --- src/file.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index b22461a..0b9bff2 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -16,7 +16,8 @@ namespace Bu { subExceptionDef( FileException ) } Bu::File::File( const Bu::FString &sName, int iFlags ) : - fd( -1 ) + fd( -1 ), + bEos( true ) { fd = ::open( sName.getStr(), getPosixFlags( iFlags ), 0666 ); if( fd < 0 ) @@ -24,11 +25,13 @@ Bu::File::File( const Bu::FString &sName, int iFlags ) : throw Bu::FileException( errno, "%s: %s", strerror(errno), sName.getStr() ); } + bEos = false; } Bu::File::File( int fd ) : fd( fd ) { + bEos = false; } Bu::File::~File() @@ -46,6 +49,7 @@ void Bu::File::close() strerror(errno) ); } fd = -1; + bEos = true; } } @@ -55,7 +59,11 @@ size_t Bu::File::read( void *pBuf, size_t nBytes ) throw FileException("File not open."); ssize_t iRead = ::read( fd, pBuf, nBytes ); - if( iRead < 0 ) + if( iRead == 0 ) + bEos = true; + else if( iRead == -1 && errno == EAGAIN ) + return 0; + else if( iRead < 0 ) throw FileException( errno, "%s", strerror( errno ) ); return iRead; } @@ -105,7 +113,7 @@ void Bu::File::setPosEnd( long pos ) bool Bu::File::isEOS() { - return false; + return bEos; } bool Bu::File::canRead() -- cgit v1.2.3