>From 50a26f70321ac075636bad1a31c4500f22309781 Mon Sep 17 00:00:00 2001 From: Matthew White Date: Thu, 28 Jul 2016 17:10:46 +0200 Subject: [PATCH] Support metalink:file elements with a "path/file" format Use the directory information contained in a metalink:file element in the same way the option --directory-prefix will. --directory-prefix="dirA/dirB/file.gz" This conforms to the RFC5854 specification. The Metalink Download Description Format 4.1.2.1. The "name" Attribute https://tools.ietf.org/html/rfc5854#section-4.1.2.1 * src/metalink.c: Treat metalink:file as directory prefix --- src/metalink.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/metalink.c b/src/metalink.c index 6b278be..623f32d 100644 --- a/src/metalink.c +++ b/src/metalink.c @@ -154,6 +154,15 @@ retrieve_from_metalink (const metalink_t* metalink) output_stream = unique_create (mfile->name, true, &filename); output_stream_regular = true; + /* When filename is set, wget behaves as if the option + --directory-prefix was used (see RFC5854), and + creates the proper "path/file" directory tree. */ + if (filename == NULL && mfile->name) + { + filename = malloc(strlen(mfile->name) + 1); + strcpy(filename, mfile->name); + } + /* Store the real file name for displaying in messages. */ opt.output_document = filename; -- 2.7.3