summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikaƫl Capelle <capelle.mikael@gmail.com>2020-09-27 21:22:21 +0200
committerGitHub <noreply@github.com>2020-09-27 21:22:21 +0200
commit9dbf4d7820963dd61cf6fad1abbe7b3962ea922e (patch)
tree47caddfcf7595b8a645569413ebac1b2734985c2 /src
parent12524354a8aa599612a547f4aa76ec9cd9c5baa7 (diff)
parent39b7f4abe972fb6bfbaea7764b81402099b5a0db (diff)
Merge pull request #1244 from Holt59/add-iprofile-inifilepath
Add IProfile::iniFilePath().
Diffstat (limited to 'src')
-rw-r--r--src/profile.cpp25
-rw-r--r--src/profile.h10
2 files changed, 35 insertions, 0 deletions
diff --git a/src/profile.cpp b/src/profile.cpp
index c1e30c22..6bf282d0 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -889,6 +889,31 @@ QString Profile::getIniFileName() const
return m_Directory.absoluteFilePath(iniFiles[0]);
}
+QString Profile::absoluteIniFilePath(QString iniFile) const
+{
+ // This is the file to which the given iniFile would be mapped, as
+ // an absolute file path:
+ QFileInfo targetIniFile(m_GamePlugin->documentsDirectory(), iniFile);
+
+ bool isGameIni = false;
+ for (auto gameIni : m_GamePlugin->iniFiles()) {
+ // We compare the target file, not the actual ones:
+ if (QFileInfo(m_GamePlugin->documentsDirectory(), gameIni) == targetIniFile) {
+ isGameIni = true;
+ break;
+ }
+ }
+
+ // Local-settings are not enabled, or the iniFile is not in the list of INI
+ // files for the current game.
+ if (!localSettingsEnabled() || !isGameIni) {
+ return targetIniFile.absoluteFilePath();
+ }
+
+ // If we reach here, the file is in the profile:
+ return m_Directory.absoluteFilePath(targetIniFile.fileName());
+}
+
QString Profile::getProfileTweaks() const
{
return QDir::cleanPath(m_Directory.absoluteFilePath(ToQString(AppConfig::profileTweakIni())));
diff --git a/src/profile.h b/src/profile.h
index c7cbc7b7..b8628276 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -196,6 +196,16 @@ public:
QString getIniFileName() const;
/**
+ * @brief Retrieve the absolute file to the corresponding file.
+ *
+ * @param iniFile INI file to retrieve a path for. This can either be the
+ * name of a file or a path to the absolute file outside of the profile.
+ *
+ * @return the absolute path for the given INI file for this profile.
+ */
+ QString absoluteIniFilePath(QString iniFile) const override;
+
+ /**
* @return the path of the tweak ini in this profile
*/
QString getProfileTweaks() const;