mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Fix recursive FTP retrieval so that
`wget -r ftp://<username>:<password>@host/%2Fhome/hniksic/dir/' works. Published in <sxsk84ug8gt.fsf@florida.arsdigita.de>.
This commit is contained in:
parent
665a84b4a2
commit
0c70c624f9
@ -1,3 +1,9 @@
|
|||||||
|
2001-04-09 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
|
* ftp.c (ftp_retrieve_dirs): Don't forcibly prepend "/" to u->dir;
|
||||||
|
that hack is no longer necessary.
|
||||||
|
(getftp): Prepend initial directory to *non*-absolute u->dir's.
|
||||||
|
|
||||||
2001-04-09 Hrvoje Niksic <hniksic@arsdigita.com>
|
2001-04-09 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
* init.c (cmd_file): New function.
|
* init.c (cmd_file): New function.
|
||||||
|
85
src/ftp.c
85
src/ftp.c
@ -349,56 +349,45 @@ Error in server response, closing control connection.\n"));
|
|||||||
logputs (LOG_VERBOSE, _("==> CWD not needed.\n"));
|
logputs (LOG_VERBOSE, _("==> CWD not needed.\n"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Change working directory. If the FTP host runs VMS and
|
char *target = u->dir;
|
||||||
the path specified is absolute, we will have to convert
|
|
||||||
it to VMS style as VMS does not like leading slashes */
|
|
||||||
DEBUGP (("changing working directory\n"));
|
DEBUGP (("changing working directory\n"));
|
||||||
if (*(u->dir) == '/')
|
|
||||||
|
/* Change working directory. To change to a non-absolute
|
||||||
|
Unix directory, we need to prepend initial directory
|
||||||
|
(con->id) to it. Absolute directories "just work". */
|
||||||
|
|
||||||
|
if (*target != '/')
|
||||||
{
|
{
|
||||||
int pwd_len = strlen (con->id);
|
int idlen = strlen (con->id);
|
||||||
char *result = (char *)alloca (strlen (u->dir) + pwd_len + 10);
|
char *ntarget = (char *)alloca (idlen + 1 + strlen (u->dir) + 1);
|
||||||
*result = '\0';
|
/* pwd_len == 1 means pwd = "/" */
|
||||||
switch (con->rs)
|
sprintf (ntarget, "%s%s%s", con->id, idlen == 1 ? "" : "/",
|
||||||
{
|
target);
|
||||||
case ST_VMS:
|
target = ntarget;
|
||||||
{
|
|
||||||
char *tmp_dir, *tmpp;
|
|
||||||
STRDUP_ALLOCA (tmp_dir, u->dir);
|
|
||||||
for (tmpp = tmp_dir; *tmpp; tmpp++)
|
|
||||||
if (*tmpp=='/')
|
|
||||||
*tmpp = '.';
|
|
||||||
strcpy (result, con->id);
|
|
||||||
/* pwd ends with ']', we have to get rid of it */
|
|
||||||
result[pwd_len - 1]= '\0';
|
|
||||||
strcat (result, tmp_dir);
|
|
||||||
strcat (result, "]");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ST_UNIX:
|
|
||||||
case ST_WINNT:
|
|
||||||
case ST_MACOS:
|
|
||||||
/* pwd_len == 1 means pwd = "/", but u->dir begins with '/'
|
|
||||||
already */
|
|
||||||
if (pwd_len > 1)
|
|
||||||
strcpy (result, con->id);
|
|
||||||
strcat (result, u->dir);
|
|
||||||
DEBUGP(("\npwd=\"%s\"", con->id));
|
|
||||||
DEBUGP(("\nu->dir=\"%s\"", u->dir));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
abort ();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!opt.server_response)
|
|
||||||
logprintf (LOG_VERBOSE, "==> CWD %s ... ", result);
|
|
||||||
err = ftp_cwd (&con->rbuf, result);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/* If the FTP host runs VMS, we will have to convert it to
|
||||||
|
VMS style as VMS does not like leading slashes. "VMS
|
||||||
|
style" is [dir.subdir.subsubdir]. */
|
||||||
|
if (con->rs == ST_VMS)
|
||||||
{
|
{
|
||||||
if (!opt.server_response)
|
char *tmpp;
|
||||||
logprintf (LOG_VERBOSE, "==> CWD %s ... ", u->dir);
|
char *ntarget = (char *)alloca (strlen (target) + 1);
|
||||||
err = ftp_cwd (&con->rbuf, u->dir);
|
strcpy (ntarget, target);
|
||||||
|
assert (*ntarget == '/');
|
||||||
|
*ntarget = '[';
|
||||||
|
for (tmpp = ntarget + 1; *tmpp; tmpp++)
|
||||||
|
if (*tmpp == '/')
|
||||||
|
*tmpp = '.';
|
||||||
|
*tmpp++ = ']';
|
||||||
|
*tmpp = '\0';
|
||||||
|
target = ntarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!opt.server_response)
|
||||||
|
logprintf (LOG_VERBOSE, "==> CWD %s ... ", target);
|
||||||
|
err = ftp_cwd (&con->rbuf, target);
|
||||||
/* FTPRERR, WRITEFAILED, FTPNSFOD */
|
/* FTPRERR, WRITEFAILED, FTPNSFOD */
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
@ -1465,14 +1454,14 @@ ftp_retrieve_dirs (struct urlinfo *u, struct fileinfo *f, ccon *con)
|
|||||||
if (f->type != FT_DIRECTORY)
|
if (f->type != FT_DIRECTORY)
|
||||||
continue;
|
continue;
|
||||||
odir = u->dir;
|
odir = u->dir;
|
||||||
len = 1 + strlen (u->dir) + 1 + strlen (f->name) + 1;
|
len = strlen (u->dir) + 1 + strlen (f->name) + 1;
|
||||||
/* Allocate u->dir off stack, but reallocate only if a larger
|
/* Allocate u->dir off stack, but reallocate only if a larger
|
||||||
string is needed. */
|
string is needed. */
|
||||||
if (len > current_length)
|
if (len > current_length)
|
||||||
current_container = (char *)alloca (len);
|
current_container = (char *)alloca (len);
|
||||||
u->dir = current_container;
|
u->dir = current_container;
|
||||||
sprintf (u->dir, "/%s%s%s", odir + (*odir == '/'),
|
sprintf (u->dir, "%s%s%s", odir,
|
||||||
(!*odir || (*odir == '/' && !* (odir + 1))) ? "" : "/", f->name);
|
(*odir == '/' && !*(odir + 1)) ? "" : "/", f->name);
|
||||||
if (!accdir (u->dir, ALLABS))
|
if (!accdir (u->dir, ALLABS))
|
||||||
{
|
{
|
||||||
logprintf (LOG_VERBOSE, _("\
|
logprintf (LOG_VERBOSE, _("\
|
||||||
|
Loading…
Reference in New Issue
Block a user