diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2020-10-20 23:37:13 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2020-10-20 23:37:13 +0200 |
commit | 7b3ee49b6aa5bcff2b46987ebc8d9cd46b9e5ac1 (patch) | |
tree | 7ce2fc46c98cd052893f01feda8b8f212f4c8f70 /src/wine.c | |
parent | db8ae62fb64fa33657f598a62045f17fc779ef8b (diff) | |
download | polecat-7b3ee49b6aa5bcff2b46987ebc8d9cd46b9e5ac1.tar.gz polecat-7b3ee49b6aa5bcff2b46987ebc8d9cd46b9e5ac1.zip |
improve codebase quality
- improve unreachable macro to print a message with a minor traceback then exit(0) instead of assert hackery
- add specific wine and dxvk directory methods
- rename dxvk install to download
- remove sanity asserts from lutris, caught by unreachable
- improve comments
- rename info to env
- only use a single buffer for information fetching
- fix formatting on code I had help on
- purge unused code
- if downloadToRam returns null pointer report that the archive went missing not that its invalid
- rename undescriptive "datadir" to be more specific
- remove unused code from when we stored the archive on disk
Diffstat (limited to 'src/wine.c')
-rw-r--r-- | src/wine.c | 36 |
1 files changed, 14 insertions, 22 deletions
@@ -64,34 +64,27 @@ int wine_download(int argc, char** argv) json_object_object_get_ex(value, "url", &url); char* name = basename((char*)json_object_get_string(url)); - char datadir[PATH_MAX]; - char downloadpath[PATH_MAX]; - struct MemoryStruct* tar; + char winedir[PATH_MAX]; + struct MemoryStruct* archive; - getDataDir(datadir, sizeof(datadir)); - makeDir(datadir); - - strncpy(downloadpath, datadir, sizeof(downloadpath)); - strncat(downloadpath, "/", sizeof(downloadpath) - strlen(downloadpath) - 1); - strncat(downloadpath, name, sizeof(downloadpath) - strlen(downloadpath) - 1); + getWineDir(winedir, sizeof(winedir)); + makeDir(winedir); printf("Downloading %s\n", name); - tar = downloadToRam(json_object_get_string(url)); - if (tar) + archive = downloadToRam(json_object_get_string(url)); + if (archive) { printf("Extracting %s\n", name); - extract(tar, datadir); - puts("Done"); + extract(archive, winedir); } else { - puts("Something went wrong. The tar is not valid"); + puts("Something went wrong. The archive went missing"); } - - free(tar->memory); - free(tar); + free(archive->memory); + free(archive); } json_object_put(runner); @@ -133,7 +126,7 @@ int wine_run(int argc, char** argv) if (argc > 1) { char winepath[PATH_MAX]; - getDataDir(winepath, sizeof(winepath)); + getWineDir(winepath, sizeof(winepath)); char* winever = argv[1]; strncat(winepath, "/", sizeof(winepath) - strlen(winepath) - 1); @@ -162,7 +155,6 @@ int wine_run(int argc, char** argv) strncat(winepath, "\"", sizeof(winepath) - strlen(winepath) - 1); } - puts(winepath); return system(winepath); } else @@ -182,14 +174,14 @@ int wine_run(int argc, char** argv) int wine_installed(int argc, char** argv) { - char datadir[PATH_MAX]; - getDataDir(datadir, sizeof(datadir)); + char winedir[PATH_MAX]; + getWineDir(winedir, sizeof(winedir)); DIR *dir; struct dirent *ent; printf("Installed wine versions:\n"); - if ((dir = opendir(datadir)) != NULL) + if ((dir = opendir(winedir)) != NULL) { while ((ent = readdir (dir)) != NULL) { |