mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
[XP driver] Fixed failure to find CSL package in certain directory layouts
Issue reported by Richard Åsberg on Discord. If one package is located two subdirectories below the parent directory of another, the first one might not be loaded.
This commit is contained in:
@@ -597,7 +597,7 @@ namespace BlackSimPlugin
|
||||
struct Prefix
|
||||
{
|
||||
Prefix(const QString &p) : s(p + '/') {}
|
||||
operator QString() const { return s.chopped(1); }
|
||||
QString parent() const { return s.section('/', 0, -2, QString::SectionSkipEmpty | QString::SectionIncludeLeadingSep); }
|
||||
bool isPrefixOf(const QString &o) const { return o.startsWith(s); }
|
||||
QString s;
|
||||
};
|
||||
@@ -634,8 +634,14 @@ namespace BlackSimPlugin
|
||||
|
||||
// comment KB 2019-06
|
||||
// a package is one xsb_aircraft.txt file BB has 9, X-CSL has 76
|
||||
const QDir simDir = getSimulatorSettings().getSimulatorDirectoryOrDefault();
|
||||
QSet<QString> superpackages;
|
||||
for (const Prefix& package : as_const(packages))
|
||||
{
|
||||
superpackages.insert(package.parent());
|
||||
}
|
||||
|
||||
const QDir simDir = getSimulatorSettings().getSimulatorDirectoryOrDefault();
|
||||
for (const QString &package : as_const(superpackages))
|
||||
{
|
||||
if (CDirectoryUtils::isSameOrSubDirectoryOf(package, simDir))
|
||||
{
|
||||
@@ -661,7 +667,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
if (dir.exists(QStringLiteral("xsb_aircraft.txt")))
|
||||
{
|
||||
if (dir.cdUp()) { return dir.path(); }
|
||||
return dir.path();
|
||||
}
|
||||
}
|
||||
while (dir.cdUp());
|
||||
|
||||
Reference in New Issue
Block a user