aboutsummaryrefslogtreecommitdiff
path: root/src/wine.c
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2020-07-31 16:24:59 +0200
committerJan200101 <sentrycraft123@gmail.com>2020-07-31 16:24:59 +0200
commitaabfdfe3fcbcf718b30872c98568581d7e7e6cca (patch)
treeb8b1d94814c9d339c6d6bb019f1fff9e4ccb2406 /src/wine.c
parent83e4ea0f70ba75f337615ee847f85d4be630686b (diff)
downloadpolecat-aabfdfe3fcbcf718b30872c98568581d7e7e6cca.tar.gz
polecat-aabfdfe3fcbcf718b30872c98568581d7e7e6cca.zip
implement config dirs and unpack tars to them0.1.1
Diffstat (limited to 'src/wine.c')
-rw-r--r--src/wine.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/wine.c b/src/wine.c
index 2c304ed..82ab655 100644
--- a/src/wine.c
+++ b/src/wine.c
@@ -2,10 +2,13 @@
#include <string.h>
#include <json.h>
#include <libgen.h>
+#include <unistd.h>
#include "wine.h"
#include "net.h"
+#include "tar.h"
#include "common.h"
+#include "config.h"
const static struct Command wine_commands[] = {
{ .name = "install", .func = wine_install, .description = "download and install a wine version from lutris" },
@@ -26,7 +29,6 @@ int wine(int argc, char** argv)
return wine_help(argc, argv);
}
-
int wine_install(int argc, char** argv)
{
if (argc == 4)
@@ -42,7 +44,7 @@ int wine_install(int argc, char** argv)
if (choice > json_object_array_length(versions) - 1 || choice < 0)
{
- printf("`%i' is not a valid ID\n\nrun `polecat wine list' to get a valid ID", choice);
+ fprintf(stderr, "`%i' is not a valid ID\n\nrun `polecat wine list' to get a valid ID\n", choice);
}
else
{
@@ -51,10 +53,22 @@ int wine_install(int argc, char** argv)
json_object_object_get_ex(value, "url", &url);
char* name = basename((char*)json_object_get_string(url));
+
+ char datadir[256];
+ char downloadpath[256];
+
+ getDataDir(datadir);
+ makeDir(datadir);
+
+ strcpy(downloadpath, datadir);
+ strcat(downloadpath, "/");
+ strcat(downloadpath, name);
- printf("Downloading %s", name);
- downloadFile(json_object_get_string(url), name);
- printf("\nDone\n");
+ fprintf(stderr, "Downloading %s\n", name);
+ downloadFile(json_object_get_string(url), downloadpath);
+ fprintf(stderr, "Extracting %s\n", name);
+ extract(downloadpath, datadir);
+ fprintf(stderr, "Done\n");
}
}
}