Nicolas Berloquin's fix of his previous dir creation patch
This commit is contained in:
parent
7a74303f3c
commit
fa446f860f
19
src/main.c
19
src/main.c
@ -31,7 +31,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/errno.h> /* NICO */
|
#include <sys/errno.h>
|
||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ struct Configurable {
|
|||||||
bool globoff;
|
bool globoff;
|
||||||
bool use_httpget;
|
bool use_httpget;
|
||||||
bool insecure_ok; /* set TRUE to allow insecure SSL connects */
|
bool insecure_ok; /* set TRUE to allow insecure SSL connects */
|
||||||
bool create_dirs; /* NICO */
|
bool create_dirs;
|
||||||
|
|
||||||
char *writeout; /* %-styled format string to output */
|
char *writeout; /* %-styled format string to output */
|
||||||
bool writeenv; /* write results to environment, if available */
|
bool writeenv; /* write results to environment, if available */
|
||||||
@ -526,7 +526,7 @@ struct Configurable {
|
|||||||
static int parseconfig(const char *filename,
|
static int parseconfig(const char *filename,
|
||||||
struct Configurable *config);
|
struct Configurable *config);
|
||||||
static char *my_get_line(FILE *fp);
|
static char *my_get_line(FILE *fp);
|
||||||
static int create_dir_hierarchy(char *outfile); /* NICO */
|
static int create_dir_hierarchy(char *outfile);
|
||||||
|
|
||||||
static void GetStr(char **string,
|
static void GetStr(char **string,
|
||||||
char *value)
|
char *value)
|
||||||
@ -1073,7 +1073,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
{"z", "time-cond", TRUE},
|
{"z", "time-cond", TRUE},
|
||||||
{"Z", "max-redirs", TRUE},
|
{"Z", "max-redirs", TRUE},
|
||||||
{"#", "progress-bar",FALSE},
|
{"#", "progress-bar",FALSE},
|
||||||
{"@", "create-dirs", FALSE}, /* NICO */
|
{"@", "create-dirs", FALSE},
|
||||||
};
|
};
|
||||||
|
|
||||||
if(('-' != flag[0]) ||
|
if(('-' != flag[0]) ||
|
||||||
@ -1710,7 +1710,6 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '@':
|
case '@':
|
||||||
/* NICO */
|
|
||||||
config->create_dirs = TRUE;
|
config->create_dirs = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2343,7 +2342,7 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
config->showerror=TRUE;
|
config->showerror=TRUE;
|
||||||
config->conf=CONF_DEFAULT;
|
config->conf=CONF_DEFAULT;
|
||||||
config->use_httpget=FALSE;
|
config->use_httpget=FALSE;
|
||||||
config->create_dirs=FALSE; /* NICO */
|
config->create_dirs=FALSE;
|
||||||
|
|
||||||
if(argc>1 &&
|
if(argc>1 &&
|
||||||
(!strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
|
(!strnequal("--", argv[1], 2) && (argv[1][0] == '-')) &&
|
||||||
@ -2569,8 +2568,9 @@ operate(struct Configurable *config, int argc, char *argv[])
|
|||||||
/* Create the directory hierarchy, if not pre-existant to a multiple
|
/* Create the directory hierarchy, if not pre-existant to a multiple
|
||||||
file output call */
|
file output call */
|
||||||
|
|
||||||
if(config->create_dirs) /* NICO */
|
if(config->create_dirs)
|
||||||
create_dir_hierarchy(outfile);
|
if (-1 == create_dir_hierarchy(outfile))
|
||||||
|
return CURLE_WRITE_ERROR;
|
||||||
|
|
||||||
if(config->resume_from_current) {
|
if(config->resume_from_current) {
|
||||||
/* We're told to continue from where we are now. Get the
|
/* We're told to continue from where we are now. Get the
|
||||||
@ -3065,8 +3065,7 @@ static int create_dir_hierarchy(char *outfile)
|
|||||||
if (strlen(dirbuildup) > 0)
|
if (strlen(dirbuildup) > 0)
|
||||||
sprintf(dirbuildup,"%s%s%s",dirbuildup, DIR_CHAR, tempdir);
|
sprintf(dirbuildup,"%s%s%s",dirbuildup, DIR_CHAR, tempdir);
|
||||||
else {
|
else {
|
||||||
/* TODO: BEEEP this is not portable, we need to fix the '/' here! */
|
if (0 != strncmp(outdup, DIR_CHAR, 1))
|
||||||
if (outdup[0] != '/')
|
|
||||||
sprintf(dirbuildup,"%s",tempdir);
|
sprintf(dirbuildup,"%s",tempdir);
|
||||||
else
|
else
|
||||||
sprintf(dirbuildup,"%s%s", DIR_CHAR, tempdir);
|
sprintf(dirbuildup,"%s%s", DIR_CHAR, tempdir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user