curl-library
RE: Setting Local Directory for an ftpget
Date: Wed, 21 Dec 2011 10:21:57 +0100 (CET)
On Tue, 20 Dec 2011, SuperWare Support wrote:
> I have it successfully getting the files, but am looking if there is an easy
> way to rename all the files it has just downloaded without starting from
> scratch to add all the necessary options - url, username, password, etc...
I don't understand why you consider that "starting from scratch". You connect
to the site and get the files and then you already set the URL and user name
and everything in the easy handle. Doing a second request to the same URL with
the same user name and so on should require very little extra code on your
behalf.
> What I tried to do is add a curl_slist to the callback_data struct and in
> the file_is_comming callback I append RNFR and RNTO pairs to build a command
> list that could be executed.
That sounds like a good approach.
> I tried issuing a curl_easy_setopt(curl, CURLOPT_POSTQUOTE, data.headerlist)
> before running the commands which get the files in hopes that libcurl would
> take the curl_slist headerlist list of commands as it exists when it is
> ready to run the commands, but apparently it takes it at the point where you
> set the CURLOPT_POSTQUOTE, which is empty at that time.
Setting options while a request is in progress is a bit of a grey area and I
try to avoid promising what will happen then. The best approach is to allow
the file transfer request to complete and then do a second request to do the
range of renames, as that request will re-use the connection etc it won't be
any noticable delay in time or anothing, but with the added benefit that
you'll use the API as intended.
> Is there an easy way to take that list of commands, the url, the ssl
> settings and basically everything except the callbacks and other things that
> drive downloading the files the first pass through?
Yes, you re-use the same curl handle and you just "disable" the options you
don't like in your request request.
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2011-12-21