Change how read and write errors are detected on fstream based streams.

This commit is contained in:
Peter Howkins
2018-03-21 01:01:09 +00:00
parent 490890cd23
commit abd209a83c
2 changed files with 12 additions and 6 deletions

View File

@@ -208,12 +208,14 @@ unixf_storage::readString(mmdb_pos_t loc, char* base, int len, int str_off)
int offset = int(loc) + str_off;
if ( seekg( offset, ios::beg ) == 0 ) {
seekg( offset, ios::beg );
if ( bad() ) {
MESSAGE(cerr, "seekg failed");
throw(streamException(fstream::rdstate()));
}
if ( read( base, len ) == 0 || len != fstream::gcount() ) {
read( base, len );
if ( bad() || len != fstream::gcount() ) {
MESSAGE(cerr, "read() failed");
throw(streamException(fstream::rdstate()));
}