mirror of https://github.com/moparisthebest/curl
make the ftp-method multicwd case possible to LIST the root directory of a
server!
This commit is contained in:
parent
cc26cc5dcd
commit
fe85ae15f3
14
lib/ftp.c
14
lib/ftp.c
|
@ -3719,6 +3719,13 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||||
if(!ftpc->dirs)
|
if(!ftpc->dirs)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
/* we have a special case for listing the root dir only */
|
||||||
|
if(strequal(path_to_use, "/")) {
|
||||||
|
cur_pos++; /* make it point to the zero byte */
|
||||||
|
ftpc->dirs[0] = strdup("/");
|
||||||
|
ftpc->dirdepth++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
/* parse the URL path into separate path components */
|
/* parse the URL path into separate path components */
|
||||||
while ((slash_pos = strchr(cur_pos, '/')) != NULL) {
|
while ((slash_pos = strchr(cur_pos, '/')) != NULL) {
|
||||||
/* 1 or 0 to indicate absolute directory */
|
/* 1 or 0 to indicate absolute directory */
|
||||||
|
@ -3731,9 +3738,8 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||||
CWD requires a parameter and a non-existant parameter a) doesn't
|
CWD requires a parameter and a non-existant parameter a) doesn't
|
||||||
work on many servers and b) has no effect on the others. */
|
work on many servers and b) has no effect on the others. */
|
||||||
int len = (int)(slash_pos - cur_pos + absolute_dir);
|
int len = (int)(slash_pos - cur_pos + absolute_dir);
|
||||||
ftpc->dirs[ftpc->dirdepth] = curl_easy_unescape(conn->data,
|
ftpc->dirs[ftpc->dirdepth] =
|
||||||
cur_pos - absolute_dir,
|
curl_easy_unescape(conn->data, cur_pos - absolute_dir, len, NULL);
|
||||||
len, NULL);
|
|
||||||
if (!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */
|
if (!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */
|
||||||
failf(data, "no memory");
|
failf(data, "no memory");
|
||||||
freedirs(conn);
|
freedirs(conn);
|
||||||
|
@ -3763,7 +3769,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
||||||
ftpc->dirs = (char **)bigger;
|
ftpc->dirs = (char **)bigger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ftp->file = cur_pos; /* the rest is the file name */
|
ftp->file = cur_pos; /* the rest is the file name */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue