1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-10 15:48:06 -05:00

PSCP, PSFTP: don't duplicate slashes in dir_file_cat.

Now if a pathname ends with a slash already, we detect that (using the
shiny new ptrlen_endswith), and don't bother putting another one in.

No functional change, but this should improve the occasional error
message, e.g. 'pscp remote:some.filename /' will now say it can't
create /some.filename instead of //some.filename.
This commit is contained in:
Simon Tatham 2019-03-09 16:15:51 +00:00
parent 757c91e2de
commit d62a369af8
2 changed files with 9 additions and 2 deletions

View File

@ -436,7 +436,10 @@ bool create_directory(const char *name)
char *dir_file_cat(const char *dir, const char *file)
{
return dupcat(dir, "/", file, NULL);
ptrlen dir_pl = ptrlen_from_asciz(dir);
return dupcat(
dir, ptrlen_endswith(dir_pl, PTRLEN_LITERAL("/"), NULL) ? "" : "/",
file, NULL);
}
/*

View File

@ -451,7 +451,11 @@ bool create_directory(const char *name)
char *dir_file_cat(const char *dir, const char *file)
{
return dupcat(dir, "\\", file, NULL);
ptrlen dir_pl = ptrlen_from_asciz(dir);
return dupcat(
dir, (ptrlen_endswith(dir_pl, PTRLEN_LITERAL("\\"), NULL) ||
ptrlen_endswith(dir_pl, PTRLEN_LITERAL("/"), NULL)) ? "" : "\\",
file, NULL);
}
/* ----------------------------------------------------------------------