#include <fstream>
#include <cstdlib>
#include <cstring>
using namespace std;
const int minRecordLen = 80;
int TextBuffer::Read( fstream& stream ) {
long length, current;
static int count = 0;
Clear( );
if ( stream.eof( ) ) return( bufferSize );
current = stream.tellg( );
stream.seekg( 0, fstream::end );
length = stream.tellg( );
length -= current;
if ( length < minRecordLen ) return( bufferSize );
if ( length > maxBytes )
length = maxBytes;
stream.seekg( current, fstream::beg );
stream.read ( buffer, length );
cout << "Disk I/O number = " << ++count << endl << endl << endl;
for ( int i = length - 1; i > minRecordLen; i-- )
if ( strncmp( buffer+i-7, "</book>", 7 ) == 0 ) {
bufferSize = i;
break;
}
return( bufferSize );
}
|