]> granicus.if.org Git - curl/commitdiff
Always create directory hierarchy for Metalink.
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Mon, 14 May 2012 13:46:15 +0000 (22:46 +0900)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 26 May 2012 21:11:40 +0000 (23:11 +0200)
Filenames contained in Metalink file can include directory information.
Filenames are unique in Metalink file, taking into account the directory
information. So we need to create the directory hierarchy.

Curl has --create-dirs option, but we create directory hierarchy for
Metalink downloads regardless of the option value.

This patch also put metalink int variable outside of HAVE_LIBMETALINK
guard. This reduces the number of #ifdefs.

src/tool_operate.c

index be841e7e728c749e5c9766cdeebbdc1669ec2826..0d17329b09801662456a39432861a96d80076f95 100644 (file)
@@ -406,8 +406,9 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
     int infilenum;
     URLGlob *inglob;
 
+    int metalink = 0; /* nonzero for metalink download. Put outside of
+                         HAVE_LIBMETALINK to reduce #ifdef */
 #ifdef HAVE_LIBMETALINK
-    int metalink; /* nonzero for metalink download */
     struct metalinkfile *mlfile;
     metalink_resource_t **mlres;
 #endif /* HAVE_LIBMETALINK */
@@ -427,7 +428,6 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
       mlres = mlfile->file->resources;
     }
     else {
-      metalink = 0;
       mlfile = NULL;
       mlres = NULL;
     }
@@ -642,7 +642,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
           /* Create the directory hierarchy, if not pre-existent to a multiple
              file output call */
 
-          if(config->create_dirs) {
+          if(config->create_dirs || metalink) {
             res = create_dir_hierarchy(outfile, config->errors);
             /* create_dir_hierarchy shows error upon CURLE_WRITE_ERROR */
             if(res == CURLE_WRITE_ERROR)