diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dxvk.c | 85 | ||||
-rw-r--r-- | src/dxvk.h | 4 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/wine.c | 8 |
4 files changed, 88 insertions, 13 deletions
@@ -4,6 +4,7 @@ #include <json.h> #include <libgen.h> #include <linux/limits.h> +#include <dirent.h> #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); @@ -1,8 +1,12 @@ #ifndef DXVK_H #define DXVK_H +#define DXVKSETUP "/setup_dxvk.sh" + int dxvk(int, char**); int dxvk_download(int, char**); +int dxvk_install(int, char**); +int dxvk_installed(int, char**); int dxvk_list(int, char**); int dxvk_help(int, char**); @@ -12,9 +12,7 @@ const static struct Command main_commands[] = { { .name = "wine", .func = wine, .description = "manage wine versions" }, -#ifdef DEBUG - { .name = "dxvk", .func = dxvk, .description = "manage dxvk versions" }, -#endif + { .name = "dxvk", .func = dxvk, .description = "manage DXVK versions" }, { .name = "lutris", .func = lutris, .description = "run lutris instraller"}, { .name = "env", .func = main_env, .description = "show some information about polecat" }, }; @@ -22,7 +22,7 @@ const static struct Command wine_commands[] = { { .name = "download", .func = wine_download, .description = "download and extract a wine version from lutris" }, { .name = "list", .func = wine_list, .description = "list installable wine versions" }, { .name = "run", .func = wine_run, .description = "run a installed wine version" }, - { .name = "installed", .func = wine_installed, .description = "list installed wine versions" }, + { .name = "list-installed", .func = wine_installed, .description = "list installed wine versions" }, }; int wine(int argc, char** argv) @@ -136,7 +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 + // if the wine version does not exist try appending the system arch e.g. x86_64 struct utsname buffer; if (!uname(&buffer)) @@ -145,7 +145,7 @@ int wine_run(int argc, char** argv) strncat(winepath, buffer.machine, sizeof(winepath) - strlen(winepath) - 1); } - // if it still doesn't exist tell this wine ver is not installed + // if it still doesn't exist tell this wine version is not installed if (!isDir(winepath)) { printf("`%s' is not an installed wine version\n", winever); @@ -192,7 +192,7 @@ int wine_run(int argc, char** argv) } else { - printf("Specify a what wine version to run.\nUse `" NAME " wine installed' to list available versions\n"); + printf("Specify a what wine version to run.\nUse `" NAME " wine list-installed' to list available versions\n"); } |