Add eof() support to SGIOChannel/SGFile.

This commit is contained in:
curt
2005-09-24 12:28:14 +00:00
parent fd126746f7
commit 7f2dfaa5b4
3 changed files with 16 additions and 2 deletions

View File

@@ -70,3 +70,9 @@ int SGIOChannel::writestring( const char *str ) {
bool SGIOChannel::close() {
return false;
}
// dummy eof routine
bool SGIOChannel::eof() {
return false;
}

View File

@@ -152,6 +152,14 @@ public:
*/
virtual bool close();
/**
* The eof() method returns true if end of file has been reached
* in a context where that makes sense. Otherwise it returns
* false.
* @return result of eof check
*/
virtual bool eof();
inline void set_type( SGChannelType t ) { type = t; }
inline SGChannelType get_type() const { return type; }

View File

@@ -80,7 +80,7 @@ bool SGFile::open( const SGProtocolDir d ) {
int SGFile::read( char *buf, int length ) {
// read a chunk
ssize_t result = ::read( fp, buf, length );
if ( result == 0 ) {
if ( length > 0 && result == 0 ) {
eof_flag = true;
}
return result;
@@ -94,7 +94,7 @@ int SGFile::readline( char *buf, int length ) {
// read a chunk
ssize_t result = ::read( fp, buf, length );
if ( result == 0 ) {
if ( length > 0 && result == 0 ) {
eof_flag = true;
}