cURL / Mailing Lists / curl-users / Single Mail

curl-users

resume on file://downloads seems not to work!

From: ·å Í¿ <tu0151034_at_yahoo.com.cn>
Date: Fri, 25 May 2007 18:12:07 +0800 (CST)

hi.
  I am using a curl with version 7.16.1.
  I type the command as follows:
   
  # curl file://downloads/1 -T 2 -C 40
   
  The size of file 2 was exactly 61 bytes. After implementing, I found curl sent exactly 61 bytes instead of 21 bytes.
   
  I think that resume on file://downloads seems not to work! But curl pronounces it can support resume on file://URL inhttp://curl.haxx.se/docs/features.html.
   
  And I checked the source code of function "file_upload" in the file "file.c"
  ======================================================
  static CURLcode file_upload(struct connectdata *conn)
  {
           .................................
   
     conn->fread = data->set.fread;
   conn->fread_in = data->set.in;
   conn->data->reqdata.upload_fromhere = buf;
     if(!dir)
     return CURLE_FILE_COULDNT_READ_FILE; /* fix: better error code */
     if(!dir[1])
     return CURLE_FILE_COULDNT_READ_FILE; /* fix: better error code */
  !! fp = fopen(file->path, "wb");
   if(!fp) {
     failf(data, "Can't open %s for writing", file->path);
     return CURLE_WRITE_ERROR;
   }
     if(-1 != data->set.infilesize)
     /* known size of data to "upload" */
     Curl_pgrsSetUploadSize(data, data->set.infilesize);
     while (res == CURLE_OK) {
     int readcount;
     res = Curl_fillreadbuffer(conn, BUFSIZE, &readcount);
     if(res)
        break;
      if (readcount <= 0) /* fix questionable compare error. curlvms */
      break;
      nread = (size_t)readcount;
      /* write the data to the target */
!! nwrite = fwrite(buf, 1, nread, fp);
   
  ...........................
  }
  ======================================================
   
  Please pay attention to the lines labelled by "!!".
  If you open the destination file as "wb" mode and don't call "lseek" function, how can you realize "resume" on file://download/.
   
  thanks in advance
   
  Best Regards
   
  Tu Feng

       
---------------------------------
ÇÀ×¢ÑÅ»¢Ãâ·ÑÓÊÏä3.5GÈÝÁ¿£¬20M¸½¼þ£¡
Received on 2007-05-25