From 25dc43f19ce163cf2ff454502df4abff81d8c1e5 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 6 Jul 2019 02:13:36 +0200 Subject: [PATCH] Log all FSX/P3D config files read --- .../simulation/fscommon/fscommonutil.cpp | 46 +++++++++++++------ .../simulation/fscommon/fscommonutil.h | 3 ++ 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/blackmisc/simulation/fscommon/fscommonutil.cpp b/src/blackmisc/simulation/fscommon/fscommonutil.cpp index 7c1e3da8a..e1200b539 100644 --- a/src/blackmisc/simulation/fscommon/fscommonutil.cpp +++ b/src/blackmisc/simulation/fscommon/fscommonutil.cpp @@ -11,6 +11,7 @@ #include "blackmisc/directoryutils.h" #include "blackmisc/fileutils.h" #include "blackmisc/stringutils.h" +#include "blackmisc/logmessage.h" #include "blackconfig/buildconfig.h" #include @@ -435,9 +436,13 @@ namespace BlackMisc { const QString f = CFileUtils::appendFilePaths(d.absolutePath(), entry, configFile); const QFileInfo fi(f); - if (fi.exists()) { files.insert(f); } - } - } + if (fi.exists()) + { + files.insert(f); + if (logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"P3D config file: '%1'") << f; } + } + } // contains + } // entries } return files; } @@ -485,9 +490,15 @@ namespace BlackMisc const QDomElement path = component.firstChildElement("Path"); const QString pathValue = path.text(); if (pathValue.isEmpty()) { continue; } - if (!checked || QDir(pathValue).exists()) { simObjectPaths.insert(CFileUtils::normalizeFilePathToQtStandard(pathValue)); } - } - } + if (!checked || QDir(pathValue).exists()) + { + const QString path = CFileUtils::normalizeFilePathToQtStandard(pathValue); + simObjectPaths.insert(path); + if (logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"P3D SimObjects path: '%1'") << path; } + } + } // components + } // paths + return simObjectPaths; } @@ -526,7 +537,11 @@ namespace BlackMisc { const QString file = CFileUtils::appendFilePaths(CFileUtils::pathUp(path), "Microsoft/FSX/fsx.cfg"); const QFileInfo fi(file); - if (fi.exists()) { files.push_back(fi.absoluteFilePath()); } + if (fi.exists()) + { + files.push_back(fi.absoluteFilePath()); + if (logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"FSX config file: '%1'") << fi.absoluteFilePath(); } + } } return files; } @@ -560,14 +575,10 @@ namespace BlackMisc const QFileInfo fi(soPath); // relative or absolute paths - if (fi.isAbsolute() && (!checked || fi.exists())) - { - paths.insert(fi.absolutePath()); - } - else - { - paths.insert(soPath); - } + const QString p = (fi.isAbsolute() && (!checked || fi.exists())) ? + fi.absolutePath() : soPath; + paths.insert(p); + if (logConfigPathReading()) { CLogMessage(getLogCategories()).info(u"FSX SimObjects path: '%1'") << p; } } return paths; } @@ -701,6 +712,11 @@ namespace BlackMisc return msgs; } + + bool CFsCommonUtil::logConfigPathReading() + { + return true; + } } // namespace } // namespace } // namespace diff --git a/src/blackmisc/simulation/fscommon/fscommonutil.h b/src/blackmisc/simulation/fscommon/fscommonutil.h index a7aff8485..1522cb2a2 100644 --- a/src/blackmisc/simulation/fscommon/fscommonutil.h +++ b/src/blackmisc/simulation/fscommon/fscommonutil.h @@ -157,6 +157,9 @@ namespace BlackMisc //! Validate if known SimObjects path are used //! \remark only for P3D static CStatusMessageList validateSimObjectsPath(const QSet &simObjectDirs, const CAircraftModelList &models, CAircraftModelList &validModels, CAircraftModelList &invalidModels, bool ignoreEmptyFileNames, int stopAtFailedFiles, bool &stopped); + + //! Log the reading of config files + static bool logConfigPathReading(); }; } // namespace } // namespace