diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2020-11-21 12:51:18 +0100 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2020-11-21 12:51:18 +0100 |
commit | 4f1251e4fab43871d3902879c94c1b2d4daafe4c (patch) | |
tree | 25695581efcddd0858a94e91473fb0800bb6dfa0 /src/wine.c | |
parent | 79fd4e76c6a2e572236bbc7e7b848f5d46242845 (diff) | |
download | polecat-4f1251e4fab43871d3902879c94c1b2d4daafe4c.tar.gz polecat-4f1251e4fab43871d3902879c94c1b2d4daafe4c.zip |
add proton support
Diffstat (limited to 'src/wine.c')
-rw-r--r-- | src/wine.c | 57 |
1 files changed, 55 insertions, 2 deletions
@@ -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; +} |