1
0
Fork 0

Aircraft-loading: resolve symlinked dirs earlier.

This is to ensure we pass a realpath when validating Nasal / dialogs,
to fix: https://sourceforge.net/p/flightgear/codetickets/2057/
This commit is contained in:
James Turner 2020-04-29 12:33:25 +01:00
parent 954385ce0d
commit de0826294c
2 changed files with 7 additions and 5 deletions

View file

@ -347,6 +347,7 @@ private:
virtual VisitResult visit(const SGPath& p)
{
SGPath realPath = p.realpath();
// create cache node
int i = 0;
while (1) {
@ -356,17 +357,17 @@ private:
SGPropertyNode *n, *entry = _cache->getChild("aircraft", --i, true);
std::string fileName(p.file());
std::string fileName(realPath.file());
n = entry->getNode("file", true);
n->setStringValue(fileName);
n->setAttribute(SGPropertyNode::USERARCHIVE, true);
n = entry->getNode("path", true);
n->setStringValue(p.dir());
n->setStringValue(realPath.dir());
n->setAttribute(SGPropertyNode::USERARCHIVE, true);
if (simgear::strutils::iequals(fileName, _searchAircraft)) {
_foundPath = p;
_foundPath = realPath;
return VISIT_DONE;
}

View file

@ -2251,7 +2251,8 @@ void Options::initAircraft()
if (isOptionSet("aircraft-dir")) {
SGPath aircraftDirPath = SGPath::fromUtf8(valueForOption("aircraft-dir"));
globals->append_read_allowed_paths(aircraftDirPath);
SGPath realAircraftPath = aircraftDirPath.realpath();
globals->append_read_allowed_paths(realAircraftPath);
// Set this now, so it's available in FindAndCacheAircraft. Use realpath()
// as in FGGlobals::append_aircraft_path(), otherwise fgValidatePath()
@ -2259,7 +2260,7 @@ void Options::initAircraft()
// is a symlink (which is not a problem, since it was given as is by the
// user---this is very different from a symlink *under* the aircraft dir
// or a scenery dir).
fgSetString("/sim/aircraft-dir", aircraftDirPath.realpath().utf8Str());
fgSetString("/sim/aircraft-dir", realAircraftPath.utf8Str());
}
if (isOptionSet("state")) {