cURL / Mailing Lists / curl-library / Single Mail

curl-library

sftp create or delete directory with libcurl question

From: ΑυΣ’Ξ° <506017026_at_qq.com>
Date: Tue, 18 Feb 2014 10:05:22 +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;
}



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!

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-02-18