From 2fb20f793bc69267e1c1cf8b4238db8e79a9fd4f Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 4 Nov 2020 11:52:58 +0000 Subject: [PATCH] Try to capture cause of BTG load failures --- simgear/io/sg_binobj.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/simgear/io/sg_binobj.cxx b/simgear/io/sg_binobj.cxx index 82f1b458..5e4e5b1a 100644 --- a/simgear/io/sg_binobj.cxx +++ b/simgear/io/sg_binobj.cxx @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -563,6 +564,12 @@ bool SGBinObject::read_bin( const SGPath& file ) { // read headers unsigned int header; sgReadUInt( fp, &header ); + + if (sgReadError()) { + gzclose(fp); + throw sg_io_exception("Unable to read BTG header: " + simgear::strutils::error_string(errno), sg_location(file)); + } + if ( ((header & 0xFF000000) >> 24) == 'S' && ((header & 0x00FF0000) >> 16) == 'G' ) {