X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Futils.c;h=3f04edafbb8f70b153a6486518c56d0d66d3a586;hp=69f0bdc0090b20e832c5cca9ebf3cc55854314e8;hb=e59a7ee8ac8a7e31a52ade02cfdb54d341e2bec1;hpb=fb2ed23830b6e58646fef7679f0af56ce17eacfd diff --git a/src/utils.c b/src/utils.c index 69f0bdc0..3f04edaf 100644 --- a/src/utils.c +++ b/src/utils.c @@ -579,6 +579,7 @@ make_directory (const char *directory) { int quit = 0; int i; + int ret = 0; char *dir; /* Make a copy of dir, to be able to write to it. Otherwise, the @@ -594,18 +595,19 @@ make_directory (const char *directory) if (!dir[i]) quit = 1; dir[i] = '\0'; - /* Check whether the directory already exists. */ + /* Check whether the directory already exists. Allow creation of + of intermediate directories to fail, as the initial path components + are not necessarily directories! */ if (!file_exists_p (dir)) - { - if (mkdir (dir, 0777) < 0) - return -1; - } + ret = mkdir (dir, 0777); + else + ret = 0; if (quit) break; else dir[i] = '/'; } - return 0; + return ret; } /* Merge BASE with FILE. BASE can be a directory or a file name, FILE