curl-library
回复: mkdir or rmdir operation with libcurl on sftp
Date: Tue, 18 Feb 2014 12:53:40 +0800
I have a question about create or delete directory with libcurl on sftp
I use the libcurl command 'mkdir' or 'rmdir' , it will list the directory before the operation .so I set the NOBODY 1L to prevent from listing .
But when I 'mkdir' or 'rmdir' twice,the second NOBODY seem to be not work , when I execute the second operation,
it always list the directory.
this is my code:
int create_out_dir(CURL *curl){
printf("============================\n");
CURLcode result;
curl_easy_reset(curl);
curl_easy_setopt(curl, CURLOPT_URL, "sftp://ogsapp:ogsapp123@132.40.130.35:22/ogsapp/dcs/liuyw/");
curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 0);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
struct curl_slist *headerlist = NULL;
headerlist = curl_slist_append(headerlist, "mkdir /ogsapp/dcs/liuyw/testoutdir/");
headerlist = curl_slist_append(headerlist, "mkdir /ogsapp/dcs/liuyw/testoutdir/testindir/");
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD);
result = curl_easy_perform(curl);
curl_slist_free_all(headerlist);
printf("make testoutdir dir %d\n",result);
return result;
}
int rm_out_dir(CURL *curl){
printf("============================\n");
CURLcode result;
curl_easy_reset(curl);
curl_easy_setopt(curl, CURLOPT_URL, "sftp://ogsapp:ogsapp123@132.40.130.35:22/ogsapp/");
curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 0);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
struct curl_slist *headerlist = NULL;
headerlist = curl_slist_append(headerlist, "rmdir /ogsapp/dcs/liuyw/testoutdir/testindir/");
headerlist = curl_slist_append(headerlist, "rmdir /ogsapp/dcs/liuyw/testoutdir/");
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD);
result = curl_easy_perform(curl);
curl_slist_free_all(headerlist);
printf("make testoutdir dir %d\n",result);
return result;
}
int main(){
CURL *curl;
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
create_out_dir(curl);
rm_out_dir(curl);
return 0;
}
I call the create_out_dir() at first, then I call the rm_out_dir(), but the second function always list directory whether the nobody is set or not. I think it maybe the handle is re_use.How can I solve this problem?Thanks!
------------------ 原始邮件 ------------------
发件人: "Fabian Frank";<fabian.frank.de_at_gmail.com>;
发送时间: 2014年2月18日(星期二) 中午12:17
收件人: "libcurl development"<curl-library_at_cool.haxx.se>;
主题: Re: mkdir or rmdir operation with libcurl on sftp
On Sun, Feb 16, 2014 at 7:05 PM, 刘英伟 <506017026_at_qq.com> wrote: But when I 'mkdir' or 'rmdir' twice,the second NOBODY seem to be not work , when I execute the second operation,
Would it be possible to share some code that exposes this bug, so we can reproduce it?
Regards,
Fabian
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-02-18