mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
Ref T660, also use relative paths in add-on.xml
This commit is contained in:
committed by
Mat Sutcliffe
parent
6e99bf2e02
commit
b3af9bc356
@@ -338,8 +338,8 @@ namespace BlackMisc
|
|||||||
bool CFsCommonUtil::adjustFileDirectory(CAircraftModel &model, const QString &simObjectsDirectory)
|
bool CFsCommonUtil::adjustFileDirectory(CAircraftModel &model, const QString &simObjectsDirectory)
|
||||||
{
|
{
|
||||||
if (model.hasExistingCorrespondingFile()) { return true; }
|
if (model.hasExistingCorrespondingFile()) { return true; }
|
||||||
if (simObjectsDirectory.isEmpty()) { return false; }
|
if (simObjectsDirectory.isEmpty()) { return false; }
|
||||||
if (!model.hasFileName()) { return false; } // we can do nothing here
|
if (!model.hasFileName()) { return false; } // we can do nothing here
|
||||||
|
|
||||||
const QString simObjectsDirectoryFix = CFileUtils::fixWindowsUncPath(simObjectsDirectory);
|
const QString simObjectsDirectoryFix = CFileUtils::fixWindowsUncPath(simObjectsDirectory);
|
||||||
const QDir dir(simObjectsDirectoryFix);
|
const QDir dir(simObjectsDirectoryFix);
|
||||||
@@ -459,7 +459,7 @@ namespace BlackMisc
|
|||||||
const QString fileContent = CFileUtils::readFileToString(configFile);
|
const QString fileContent = CFileUtils::readFileToString(configFile);
|
||||||
if (fileContent.isEmpty()) { continue; }
|
if (fileContent.isEmpty()) { continue; }
|
||||||
const QList<QStringRef> lines = splitLinesRefs(fileContent);
|
const QList<QStringRef> lines = splitLinesRefs(fileContent);
|
||||||
static const QString p("PATH=");
|
static const QString p("Path=");
|
||||||
for (const QStringRef &line : lines)
|
for (const QStringRef &line : lines)
|
||||||
{
|
{
|
||||||
const int i = line.lastIndexOf(p, -1, Qt::CaseInsensitive);
|
const int i = line.lastIndexOf(p, -1, Qt::CaseInsensitive);
|
||||||
@@ -482,21 +482,30 @@ namespace BlackMisc
|
|||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QIODevice::ReadOnly) || !doc.setContent(&file)) { continue; }
|
if (!file.open(QIODevice::ReadOnly) || !doc.setContent(&file)) { continue; }
|
||||||
|
if (CFsCommonUtil::logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"Reading '%1' from addon path: '%2'") << file.fileName() << addOnPath; }
|
||||||
|
|
||||||
const QDomNodeList components = doc.elementsByTagName("AddOn.Component");
|
const QDomNodeList components = doc.elementsByTagName("AddOn.Component");
|
||||||
for (int i = 0; i < components.size(); i++)
|
for (int i = 0; i < components.size(); i++)
|
||||||
{
|
{
|
||||||
const QDomNode component = components.item(i);
|
const QDomNode component = components.item(i);
|
||||||
const QDomElement category = component.firstChildElement("Category");
|
const QDomElement category = component.firstChildElement("Category");
|
||||||
const QString categoryValue = category.text();
|
const QString categoryValue = category.text();
|
||||||
if (!caseInsensitiveStringCompare(categoryValue, QStringLiteral("SimObjects"))) { continue; }
|
if (!caseInsensitiveStringCompare(categoryValue, QStringLiteral("SimObjects"))) { continue; }
|
||||||
const QDomElement path = component.firstChildElement("Path");
|
const QDomElement path = component.firstChildElement("Path");
|
||||||
const QString pathValue = path.text();
|
const QString pathValue = CFileUtils::normalizeFilePathToQtStandard(path.text());
|
||||||
if (pathValue.isEmpty()) { continue; }
|
const bool correctPath = pathValue.contains("Airplanes", Qt::CaseInsensitive) ||
|
||||||
if (!checked || QDir(pathValue).exists())
|
pathValue.contains("Rotorcraft", Qt::CaseInsensitive);
|
||||||
|
if (!correctPath) { continue; }
|
||||||
|
|
||||||
|
// absolute or relative path
|
||||||
|
const QString fp = pathValue.left(3).contains(':') ?
|
||||||
|
pathValue :
|
||||||
|
CFileUtils::appendFilePaths(addOnPath, pathValue);
|
||||||
|
if (CFsCommonUtil::logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"Testing '%1' as addon path: '%2'") << fp << addOnPath; }
|
||||||
|
if (!checked || QDir(fp).exists())
|
||||||
{
|
{
|
||||||
const QString path = CFileUtils::normalizeFilePathToQtStandard(pathValue);
|
simObjectPaths.insert(CFileUtils::normalizeFilePathToQtStandard(fp));
|
||||||
simObjectPaths.insert(path);
|
if (logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"P3D SimObjects path: '%1'") << fp; }
|
||||||
if (logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"P3D SimObjects path: '%1'") << path; }
|
|
||||||
}
|
}
|
||||||
} // components
|
} // components
|
||||||
} // paths
|
} // paths
|
||||||
|
|||||||
Reference in New Issue
Block a user