cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Why doesn't set CURLFTP_CREATE_DIR_RETRY when run “curl --ftp-create-dirs”

From: Leif W <warp9pnt9_at_gmail.com>
Date: Thu, 21 Apr 2016 23:52:21 -0400

On 2016-04-21 04:20, Wanghui (John) wrote:
> But when running curl command line tool with --ftp-create-dirs, CURLOPT_FTP_CREATE_MISSING_DIRS is only set to 1.
>
> /* new in curl 7.10.7, extended in 7.19.4 but this only sets 0 or 1 */
>
> my_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS,
>
> config->ftp_create_dirs?1L:0L);
>
>
>
> Could curl command line tool offer an option to set CURLOPT_FTP_CREATE_MISSING_DIRS to be 2?

Seems to make sense that the tool should support the same feature.

Would this be a simple matter of changing the ftp_create_dirs from a
bool to a long, set default to 0 if not used, toggle on if used with no
nextarg, or assign 2L value, and update the docs? What might break?
What test cases needed? If this is a viable change, should a bug be
filed to help keep track of the reason for patch submit?

I haven't compiled anything using MS toolchain before, and wasn't able
to quickly get it to work based solely upon the windows build
instructions[1]. Otherwise, I'd have tried and tested by now. :) But
that is another issue.

Anyways, attached is an UNTESTED patch (diff -u), for discussion. It
could probably be refactored. Doesn't use include/curl/curl.h enum,
though I chose to implement as a numeric parameter corresponding to the
enum. There may be alternative choices.

The patch modifies 3 files, tool_cfgable.c, tool_getparam.c, and
tool_operate.c. I do not know how to write test cases, but test147 and
test148 tested the original toggle feature, test624 and test625 tested
the SFTP extension.

--ftp-create-dirs [num]
0 = Option not used, or disabled, CWD fails
1 = CWD fails, try MKD, if MKD ok, then CWD
2 = CWD fails, other connection succeeds MKD, our MKD fails, retry CWD

[1] https://github.com/curl/curl/blob/master/winbuild/BUILD.WINDOWS.txt

--Leif

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-users
FAQ: https://curl.haxx.se/docs/faq.html
Etiquette: https://curl.haxx.se/mail/etiquette.html

Received on 2016-04-22