Add eof() support to SGIOChannel/SGFile.
This commit is contained in:
@@ -70,3 +70,9 @@ int SGIOChannel::writestring( const char *str ) {
|
||||
bool SGIOChannel::close() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// dummy eof routine
|
||||
bool SGIOChannel::eof() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user