Added handling of error return type

This commit is contained in:
Robert Osfield 2016-06-30 09:29:32 +01:00
parent 05d97aad28
commit 6df325f651

View File

@ -413,15 +413,21 @@ bool trpgr_Archive::ReadExternalTile(uint32 x,uint32 y,uint32 lod,trpgMemReadBuf
// Find the file end // Find the file end
if (fseek(filep,0,SEEK_END)) if (fseek(filep,0,SEEK_END))
throw 1; throw 1;
// Note: This means tile is capped at 2 gigs // Note: This means tile is capped at 2 gigs
long pos = ftell(filep); long pos = ftell(filep);
if (pos<0)
throw 1;
if (fseek(filep,0,SEEK_SET)) if (fseek(filep,0,SEEK_SET))
throw 1; throw 1;
// Now we know the size. Read the whole file // Now we know the size. Read the whole file
buf.SetLength(pos); buf.SetLength(pos);
char *data = buf.GetDataPtr(); char *data = buf.GetDataPtr();
if (fread(data,pos,1,filep) != 1) if (fread(data,pos,1,filep) != 1)
throw 1; throw 1;
fclose(filep); fclose(filep);
filep = NULL; filep = NULL;
} }