From 44d8d7fa77ad7370b3cde7faf59134ce50ad0c59 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sun, 22 Nov 2020 22:01:10 +0100 Subject: implement DXVK functionality, renamed installed to list-installed, […] - main DXVK functionality implemented, installing (etc.) can be done now this adds a dependency on the system installed wine to modify the registry but that isn't too huge of an issue right now - installed has been renamed to list-installed to be more user friendly - comments have been improved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dxvk.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 6 deletions(-) (limited to 'src/dxvk.c') diff --git a/src/dxvk.c b/src/dxvk.c index f8d4cc3..70a8fa8 100644 --- a/src/dxvk.c +++ b/src/dxvk.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "dxvk.h" #include "net.h" @@ -12,8 +13,10 @@ #include "config.h" const static struct Command dxvk_commands[] = { - { .name = "download", .func = dxvk_download, .description = "download and install a dxvk version" }, - { .name = "list", .func = dxvk_list, .description = "list available dxvk versions" }, + { .name = "download", .func = dxvk_download, .description = "download and install a dxvk version" }, + { .name = "list", .func = dxvk_list, .description = "list available dxvk versions" }, + { .name = "install", .func = dxvk_install, .description = "run the DXVK installer" }, + { .name = "list-installed", .func = dxvk_installed, .description = "list installed dxvk versions" }, }; int dxvk(int argc, char** argv) @@ -58,9 +61,9 @@ int dxvk_download(int argc, char** argv) char* name = basename((char*)json_object_get_string(assets)); struct MemoryStruct* archive; - char winedir[PATH_MAX]; - getDXVKDir(winedir, sizeof(winedir)); - makeDir(winedir); + char dxvkdir[PATH_MAX]; + getDXVKDir(dxvkdir, sizeof(dxvk)); + makeDir(dxvkdir); printf("Downloading %s\n", name); @@ -68,7 +71,7 @@ int dxvk_download(int argc, char** argv) if (archive) { printf("Extracting %s\n", name); - extract(archive, winedir); + extract(archive, dxvkdir); } else { @@ -89,6 +92,76 @@ int dxvk_download(int argc, char** argv) return 0; } +int dxvk_install(int argc, char** argv) +{ + if (argc > 1) + { + char dxvkpath[PATH_MAX]; + char* winebinloc = NULL; // to be set by the wine type check + getDXVKDir(dxvkpath, sizeof(dxvkpath)); + char* dxvkver = argv[1]; + + strncat(dxvkpath, "/", sizeof(dxvkpath) - strlen(dxvkpath) - 1); + strncat(dxvkpath, dxvkver, sizeof(dxvkpath) - strlen(dxvkpath) - 1); + + if (!isDir(dxvkpath)) + { + printf("`%s' is not an downloaded DXVK version\n", dxvkver); + return 0; + } + + strncat(dxvkpath, DXVKSETUP, sizeof(dxvkpath) - strlen(dxvkpath) - 1); + + if (isFile(dxvkpath)) + { + strncat(dxvkpath, " install", sizeof(dxvkpath) - strlen(dxvkpath) - 1); + + return system(dxvkpath); + } + else + { + printf("cannot find the setup script for `%s'\n", dxvkver); + } + + } + else + { + printf("Specify a what DXVK version to install.\nUse `" NAME " dxvk list-installed' to list available versions\n"); + } + + + return 0; +} + +int dxvk_installed(int argc, char** argv) +{ + char dxvkdir[PATH_MAX]; + getDXVKDir(dxvkdir, sizeof(dxvkdir)); + + DIR *dir; + struct dirent *ent; + + printf("Installed DXVK versions:\n"); + if ((dir = opendir(dxvkdir)) != NULL) + { + while ((ent = readdir(dir)) != NULL) + { + /* + * WARNING: crusty + * d_type is only specified on glibc (including musl) and BSD + */ + if (ent->d_name[0] != '.' && ent->d_type == DT_DIR) + { + printf(" - %s\n", ent->d_name); + } + } + closedir (dir); + } + + return 0; +} + + int dxvk_list(int argc, char** argv) { struct json_object* runner = fetchJSON(DXVK_API); -- cgit v1.2.3