SGFile::SGFile( const string &file) {
set_type( sgFileType );
file_name = file;
+ eof_flag = true;
}
return false;
}
+ eof_flag = false;
return true;
}
// read a block of data of specified size
int SGFile::read( char *buf, int length ) {
// read a chunk
- return ::read( fp, buf, length );
+ ssize_t result = ::read( fp, buf, length );
+ if ( result == 0 ) {
+ eof_flag = true;
+ }
+ return result;
}
int pos = lseek( fp, 0, SEEK_CUR );
// read a chunk
- int result = ::read( fp, buf, length );
+ ssize_t result = ::read( fp, buf, length );
+ if ( result == 0 ) {
+ eof_flag = true;
+ }
// find the end of line and reset position
int i;
return false;
}
+ eof_flag = true;
return true;
}
string file_name;
int fp;
+ bool eof_flag;
public:
/** @return the name of the file being manipulated. */
inline string get_file_name() const { return file_name; }
+
+ /** @return true of eof conditions exists */
+ inline bool eof() const { return eof_flag; };
};