From 243aea1f7f1b50da2228a89812ff77a92dae82ad Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 16 Jan 2016 23:39:10 +0100 Subject: [PATCH 1/1] uclient-fetch: add support for setting output directory Signed-off-by: Felix Fietkau --- uclient-fetch.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/uclient-fetch.c b/uclient-fetch.c index c2b7e69..5ab2ea0 100644 --- a/uclient-fetch.c +++ b/uclient-fetch.c @@ -388,6 +388,7 @@ static int usage(const char *progname) "Options:\n" " -q: Turn off status messages\n" " -O : Redirect output to file (use \"-\" for stdout)\n" + " -P : Set directory for output files\n" " --user= HTTP authentication username\n" " --password= HTTP authentication password\n" " --user-agent|-U Set HTTP user agent\n" @@ -480,7 +481,7 @@ int main(int argc, char **argv) signal(SIGPIPE, SIG_IGN); init_ustream_ssl(); - while ((ch = getopt_long(argc, argv, "cO:qsU:Y:", longopts, &longopt_idx)) != -1) { + while ((ch = getopt_long(argc, argv, "cO:P:qsU:Y:", longopts, &longopt_idx)) != -1) { switch(ch) { case 0: switch (longopt_idx) { @@ -539,6 +540,13 @@ int main(int argc, char **argv) case 'O': output_file = optarg; break; + case 'P': + if (chdir(optarg)) { + if (!quiet) + perror("Change output directory"); + exit(1); + } + break; case 'q': quiet = true; break; -- 2.11.0