Skip to content

Commit 48dc21e

Browse files
committed
Linux: implement relative installation
When setting an empty updater.conf next to the updater executable, the folder containing the updater executable is used to install the game.
1 parent 68333dd commit 48dc21e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

linux.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ void migrateHomePath()
112112
}
113113
}
114114

115+
QString relativeInstallPath()
116+
{
117+
QFileInfo applicationFileInfo(QCoreApplication::applicationFilePath());
118+
QString applicationDirectory = applicationFileInfo.absolutePath();
119+
QFile configurationFile(applicationDirectory + "/updater.conf");
120+
if (configurationFile.exists()) {
121+
return applicationDirectory;
122+
}
123+
return QString();
124+
}
125+
115126
QString defaultInstallPath()
116127
{
117128
// if needed, migrate legacy homepath to prevent the updater
@@ -123,6 +134,10 @@ QString defaultInstallPath()
123134
// it returns "~/.local/share/unvanquished/updater"
124135
// and we want "~/.local/share/unvanquished/base"
125136
// game itself puts stuff in "~/.local/share/unvanquished"
137+
QString relative = relativeInstallPath();
138+
if (!relative.isNull()) {
139+
return relative;
140+
}
126141
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/unvanquished/base";
127142
}
128143

@@ -294,6 +309,10 @@ void initApplicationName()
294309
// Settings are stored in ~/.config/unvanquished/updater.conf
295310
QSettings* makePersistentSettings(QObject* parent)
296311
{
312+
QString relative = relativeInstallPath();
313+
if (!relative.isNull()) {
314+
return new QSettings(relative, QSettings::NativeFormat, parent);
315+
}
297316
return new QSettings(parent);
298317
}
299318

0 commit comments

Comments
 (0)