aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wine.c57
-rw-r--r--src/wine.h11
2 files changed, 66 insertions, 2 deletions
diff --git a/src/wine.c b/src/wine.c
index 089a0e9..6a46792 100644
--- a/src/wine.c
+++ b/src/wine.c
@@ -126,6 +126,7 @@ int wine_run(int argc, char** argv)
if (argc > 1)
{
char winepath[PATH_MAX];
+ char* winebinloc = NULL; // to be set by the wine type check
getWineDir(winepath, sizeof(winepath));
char* winever = argv[1];
@@ -135,6 +136,7 @@ int wine_run(int argc, char** argv)
if (!isDir(winepath))
{
+ // if the proton version does not exist try appending the system arch e.g. x86_64
struct utsname buffer;
if (!uname(&buffer))
@@ -142,9 +144,34 @@ int wine_run(int argc, char** argv)
strncat(winepath, "-", sizeof(winepath) - strlen(winepath) - 1);
strncat(winepath, buffer.machine, sizeof(winepath) - strlen(winepath) - 1);
}
+
+ // if it still doesn't exist tell this wine ver is not installed
+ if (!isDir(winepath))
+ {
+ printf("`%s' is not an installed wine version\n", winever);
+ return 0;
+ }
}
- strncat(winepath, WINEBIN, sizeof(winepath) - strlen(winepath) - 1);
+ switch(check_wine_ver(winepath, sizeof(winepath)+1))
+ {
+ case WINE_NORMAL:
+ winebinloc = WINEBIN;
+ break;
+
+ case WINE_PROTON:
+ winebinloc = PROTONBIN;
+ break;
+
+ default:
+ #ifdef DEBUG
+ printf("Couldn't find figure out if this `%s' is Wine or Proton, defaulting to Wine", winever);
+ #endif
+ winebinloc = WINEBIN;
+ break;
+ }
+
+ strncat(winepath, winebinloc, sizeof(winepath) - strlen(winepath) - 1);
if (isFile(winepath))
{
@@ -159,7 +186,7 @@ int wine_run(int argc, char** argv)
}
else
{
- printf("`%s' is not an installed wine version\n", winever);
+ printf("cannot find wine for `%s'\n", winever);
}
}
@@ -208,3 +235,29 @@ int wine_help(int argc, char** argv)
return 0;
}
+
+enum wine_type_t check_wine_ver(char* winepath, size_t size)
+{
+ char* winepathcopy = NULL;
+
+ winepathcopy = malloc(size);
+ strncpy(winepathcopy, winepath, size);
+ strncat(winepathcopy, WINEBIN, size - strlen(winepathcopy));
+
+ if (isFile(winepathcopy))
+ {
+ free(winepathcopy);
+ return WINE_NORMAL;
+ }
+
+ strncpy(winepathcopy, winepath, size);
+ strncat(winepathcopy, PROTONBIN, size - strlen(winepathcopy));
+
+ if (isFile(winepathcopy))
+ {
+ free(winepathcopy);
+ return WINE_PROTON;
+ }
+
+ return WINE_NONE;
+}
diff --git a/src/wine.h b/src/wine.h
index b36d3ee..445212d 100644
--- a/src/wine.h
+++ b/src/wine.h
@@ -2,6 +2,15 @@
#define WINE_H
#define WINEBIN "/bin/wine"
+#define PROTONBIN "/dist/bin/wine"
+
+// enum type used to represent if the installed wine version is proton or normal wine
+// this is mainly used to know wheither to call WINEBIN or PROTONBIN
+enum wine_type_t {
+ WINE_NONE,
+ WINE_NORMAL,
+ WINE_PROTON
+};
int wine(int, char**);
int wine_download(int, char**);
@@ -10,4 +19,6 @@ int wine_run(int, char**);
int wine_installed(int, char**);
int wine_help(int, char**);
+enum wine_type_t check_wine_ver(char*, size_t);
+
#endif \ No newline at end of file