summaryrefslogtreecommitdiff
path: root/src/profile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/profile.cpp')
-rw-r--r--src/profile.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/profile.cpp b/src/profile.cpp
index c1e30c22..92f2abce 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -805,9 +805,10 @@ bool Profile::localSettingsEnabled() const
if (enabled) {
QStringList missingFiles;
for (QString file : m_GamePlugin->iniFiles()) {
- if (!QFile::exists(m_Directory.filePath(file))) {
- log::warn("missing {} in {}", file, m_Directory.path());
- missingFiles << file;
+ QString fileName = QFileInfo(file).fileName();
+ if (!QFile::exists(m_Directory.filePath(fileName))) {
+ log::warn("missing {} in {}", fileName, m_Directory.path());
+ missingFiles << fileName;
}
}
if (!missingFiles.empty()) {
@@ -837,7 +838,7 @@ bool Profile::enableLocalSettings(bool enable)
if (res == QMessageBox::Yes) {
QStringList filesToDelete;
for (QString file : m_GamePlugin->iniFiles()) {
- filesToDelete << m_Directory.absoluteFilePath(file);
+ filesToDelete << m_Directory.absoluteFilePath(QFileInfo(file).fileName());
}
shellDelete(filesToDelete, true);
} else if (res == QMessageBox::No) {
@@ -886,7 +887,32 @@ QString Profile::getIniFileName() const
if (iniFiles.isEmpty())
return "";
else
- return m_Directory.absoluteFilePath(iniFiles[0]);
+ return m_Directory.absoluteFilePath(QFileInfo(iniFiles[0]).fileName());
+}
+
+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