From 8cdd242f85e4e6dc1a36a19cd544b3091438e30b Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Tue, 4 Mar 2014 14:22:02 +0100 Subject: [PATCH] xbps-uhelper fetch supports user defined output file xbps-uhelper now supports downloading files with a defined destination. The syntax of fetch is "URI>FILENAME". So if you call xbps-uhelper fetch "http://foobar.com/foo.tar.gz>bar.tar.gz" the output file will be named "bar.tar.gz" --- bin/xbps-uhelper/main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/xbps-uhelper/main.c b/bin/xbps-uhelper/main.c index 3f0a1aa9..874b60d6 100644 --- a/bin/xbps-uhelper/main.c +++ b/bin/xbps-uhelper/main.c @@ -49,7 +49,7 @@ usage(void) " Action arguments:\n" " cmpver\t\t \n" " digest\t\t \n" - " fetch\t\t \n" + " fetch\t\t \n" " getpkgdepname\t\n" " getpkgdepversion\t\n" " getpkgname\t\t\n" @@ -87,7 +87,7 @@ main(int argc, char **argv) struct xbps_handle xh; struct xferstat xfer; const char *version, *rootdir = NULL, *confdir = NULL; - char *pkgname, *hash; + char *pkgname, *hash, *sep; int flags = 0, c, rv = 0; while ((c = getopt(argc, argv, "C:dr:V")) != -1) { @@ -248,13 +248,19 @@ main(int argc, char **argv) usage(); for (int i = 1; i < argc; i++) { - rv = xbps_fetch_file(&xh, argv[i], "v"); + if( (sep = strrchr(argv[i], '>')) ) { + *sep = '\0'; + rv = xbps_fetch_file_dest(&xh, argv[i], sep+1, "v"); + } else { + rv = xbps_fetch_file(&xh, argv[i], "v"); + } + if (rv == -1) { - printf("%s: %s\n", argv[1], + printf("%s: %s\n", argv[i], xbps_fetch_error_string()); } else if (rv == 0) { printf("%s: file is identical than remote.\n", - argv[1]); + argv[i]); } else rv = 0; }