1
0
Fork 0

Make sure we open exactly the desired file when loading apt.dat files

Without this change, it would be possible that the NavCache is rebuilt
using $FG_ROOT/Airports/apt.dat (if $FG_ROOT/Airports/apt.dat.gz is
manually deleted) despite APTLoader::readAptDatFile() using
sg_gzifstream() with $FG_ROOT/Airports/apt.dat.gz, but the NavCache
would still contain a reference to $FG_ROOT/Airports/apt.dat.gz and log
messages would pretend we are reading this (non-existent) file.

Unrelated: the change

-          "Loaded data for " << nbAirports << " airports" );
+          "Loaded data for " << nbLoadedAirports << " airports" );

has no incidence given the current code, but it is more logical and
future-proof (in case someone adds a continue statement inside the for
loop starting at line 224...).
This commit is contained in:
Florent Rougon 2016-10-20 16:55:36 +02:00
parent 23cc1974d7
commit f4e0bf05f5

View file

@ -89,7 +89,7 @@ void APTLoader::readAptDatFile(const SGPath &aptdb_file,
std::size_t totalSizeOfAllAptDatFiles)
{
string apt_dat = aptdb_file.utf8Str(); // full path to the file being parsed
sg_gzifstream in(aptdb_file);
sg_gzifstream in(aptdb_file, std::ios_base::in | std::ios_base::binary, true);
if ( !in.is_open() ) {
const std::string errMsg = simgear::strutils::error_string(errno);
@ -304,7 +304,7 @@ void APTLoader::loadAirports()
} // of loop over 'airportInfoMap'
SG_LOG( SG_GENERAL, SG_INFO,
"Loaded data for " << nbAirports << " airports" );
"Loaded data for " << nbLoadedAirports << " airports" );
}
// Tell whether an apt.dat line is blank or a comment line