summaryrefslogtreecommitdiffhomepage
path: root/proto-wine/proton.cpp
diff options
context:
space:
mode:
authorRussell Sim <russell.sim@gmail.com>2020-06-14 09:07:27 +0200
committerRussell Sim <russell.sim@gmail.com>2020-06-14 09:08:35 +0200
commit8444c609936606a361dd2681a6e2356e0d5ee81c (patch)
treeddd8bee7bc99015b1470fce1cca8f2cf54736951 /proto-wine/proton.cpp
parentbeac0c60e8188cb593ac82df2c0773576b493c93 (diff)
Implement error handling
Diffstat (limited to 'proto-wine/proton.cpp')
-rw-r--r--proto-wine/proton.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/proto-wine/proton.cpp b/proto-wine/proton.cpp
index f2b0269e..b1eb8b9e 100644
--- a/proto-wine/proton.cpp
+++ b/proto-wine/proton.cpp
@@ -7,12 +7,13 @@
#ifndef OTR_WINE_NO_WRAPPER
+#include "proton.h"
+
#include <QDebug>
-#include <QtGlobal>
-#include <QString>
-#include <QProcessEnvironment>
#include <QDir>
#include <QFileInfo>
+#include <QProcessEnvironment>
+#include <QtGlobal>
static const char* steam_paths[] = {
@@ -30,7 +31,14 @@ QProcessEnvironment make_steam_environ(const QString& proton_path, int appid)
{
auto ret = QProcessEnvironment::systemEnvironment();
QString home = qgetenv("HOME");
- QString runtime_path;
+ QString runtime_path, app_wineprefix;
+
+ auto expand = [&](QString x) {
+ x.replace("HOME", home);
+ x.replace("PROTON_PATH", proton_path);
+ x.replace("RUNTIME_PATH", runtime_path);
+ return x;
+ };
for (const char* path : runtime_paths) {
QDir dir(QDir::homePath() + path);
@@ -38,12 +46,16 @@ QProcessEnvironment make_steam_environ(const QString& proton_path, int appid)
runtime_path = dir.absolutePath();
}
- auto expand = [&](QString x) {
- x.replace("HOME", home);
- x.replace("PROTON_PATH", proton_path);
- x.replace("RUNTIME_PATH", runtime_path);
- return x;
- };
+ if (runtime_path.isEmpty())
+ ProtonException(QString("Couldn't find a Steam runtime.")).raise();
+
+ for (const char* path : steam_paths) {
+ QDir dir(QDir::homePath() + path + expand("/%1/pfx").arg(appid));
+ if (dir.exists())
+ app_wineprefix = dir.absolutePath();
+ }
+ if (app_wineprefix.isEmpty())
+ ProtonException(QString("Couldn't find a Wineprefix for AppId %1").arg(appid)).raise();
QString path = expand(
":PROTON_PATH/dist/bin"
@@ -67,12 +79,7 @@ QProcessEnvironment make_steam_environ(const QString& proton_path, int appid)
);
library_path += ':'; library_path += qgetenv("LD_LIBRARY_PATH");
ret.insert("LD_LIBRARY_PATH", library_path);
-
- for (const char* path : steam_paths) {
- QDir dir(QDir::homePath() + path + expand("/%1/pfx").arg(appid));
- if (dir.exists())
- ret.insert("WINEPREFIX", dir.absolutePath());
- }
+ ret.insert("WINEPREFIX", app_wineprefix);
return ret;
}