Commit b60e0fa9 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

David J Meyer's large file support.

parent 41c6f68d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ int main(int argc, char **argv)
    curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);

    /* and give the size of the upload (optional) */
    curl_easy_setopt(curl, CURLOPT_INFILESIZE, file_info.st_size);
    curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_info.st_size);

    /* Now run off and do what you've been told! */
    res = curl_easy_perform(curl);
+2 −3
Original line number Diff line number Diff line
@@ -85,9 +85,8 @@ int main(int argc, char **argv)
    /* now specify which file to upload */
    curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);

    /* and give the size of the upload, make sure that we don't accidentally
       pass a larger variable type than "long". */
    curl_easy_setopt(curl, CURLOPT_INFILESIZE, (long) file_info.st_size);
    /* and give the size of the upload */
    curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_info.st_size);

    /* Now run off and do what you've been told! */
    res = curl_easy_perform(curl);
+2 −2
Original line number Diff line number Diff line
@@ -298,9 +298,9 @@ Upload Data to a Remote Site

 A few protocols won't behave properly when uploads are done without any prior
 knowledge of the expected file size. So, set the upload file size using the
 CURLOPT_INFILESIZE for all known file sizes like this[1]:
 CURLOPT_INFILESIZE_LARGE for all known file sizes like this[1]:

    curl_easy_setopt(easyhandle, CURLOPT_INFILESIZE, file_size);
    curl_easy_setopt(easyhandle, CURLOPT_INFILESIZE_LARGE, file_size);

 When you call curl_easy_perform() this time, it'll perform all the necessary
 operations and when it has invoked the upload it'll call your supplied
+19 −3
Original line number Diff line number Diff line
@@ -602,6 +602,9 @@ techniques).
.IP CURLOPT_RESUME_FROM
Pass a long as parameter. It contains the offset in number of bytes that you
want the transfer to start from.
.IP CURLOPT_RESUME_FROM_LARGE
Pass an off_t as parameter. It contains the offset in number of bytes that you
want the transfer to start from.
.IP CURLOPT_CUSTOMREQUEST
Pass a pointer to a zero terminated string as parameter. It will be user
instead of GET or HEAD when doing a HTTP request, or instead of LIST or NLST
@@ -628,16 +631,29 @@ output. This is only relevant for protocols that have separate header and body
parts. On HTTP(S) servers, this will make libcurl do a HEAD request.
.IP CURLOPT_INFILESIZE
When uploading a file to a remote site, this option should be used to tell
libcurl what the expected size of the infile is.
libcurl what the expected size of the infile is. This value should be passed
as a long. See also \fICURLOPT_INFILESIZE_LARGE\fP.
.IP CURLOPT_INFILESIZE_LARGE
When uploading a file to a remote site, this option should be used to tell
libcurl what the expected size of the infile is.  This value should be passed
as an off_t.
.IP CURLOPT_UPLOAD
A non-zero parameter tells the library to prepare for an upload. The
\fICURLOPT_READDATA\fP and \fICURLOPT_INFILESIZE\fP are also interesting for
uploads.
\fICURLOPT_READDATA\fP and \fICURLOPT_INFILESIZE_LARGE\fP are also interesting
for uploads.
.IP CURLOPT_MAXFILESIZE
Pass a long as parameter. This allows you to specify the maximum size (in
bytes) of a file to download. If the file requested is larger than this value,
the transfer will not start and CURLE_FILESIZE_EXCEEDED will be returned.

NOTE: The file size is not always known prior to download, and for such files
this option has no effect even if the file transfer ends up being larger than
this given limit. This concerns both FTP and HTTP transfers.
.IP CURLOPT_MAXFILESIZE_LARGE
Pass an off_t as parameter. This allows you to specify the maximum size (in
bytes) of a file to download. If the file requested is larger than this value,
the transfer will not start and CURLE_FILESIZE_EXCEEDED will be returned.

NOTE: The file size is not always known prior to download, and for such files
this option has no effect even if the file transfer ends up being larger than
this given limit. This concerns both FTP and HTTP transfers.
+33 −3
Original line number Diff line number Diff line
@@ -270,6 +270,7 @@ typedef enum {
#define CURLOPTTYPE_LONG          0
#define CURLOPTTYPE_OBJECTPOINT   10000
#define CURLOPTTYPE_FUNCTIONPOINT 20000
#define CURLOPTTYPE_OFF_T         30000

/* name is uppercase CURLOPT_<name>,
   type is one of the defined CURLOPTTYPE_<type>
@@ -300,6 +301,7 @@ typedef enum {
#define LONG          CURLOPTTYPE_LONG
#define OBJECTPOINT   CURLOPTTYPE_OBJECTPOINT
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
#define OFF_T         CURLOPTTYPE_OFF_T
#define CINIT(name,type,number) CURLOPT_/**/name = type + number
#endif

@@ -356,7 +358,12 @@ typedef enum {
  /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about
   * how large the file being sent really is. That allows better error
   * checking and better verifies that the upload was succcessful. -1 means
   * unknown size. */
   * unknown size.
   *
   * For large file support, there is also a _LARGE version of the key
   * which takes an off_t type, allowing platforms with larger off_t
   * sizes to handle larger files.  See below for INFILESIZE_LARGE.
   */
  CINIT(INFILESIZE, LONG, 14),

  /* POST input fields. */
@@ -384,7 +391,12 @@ typedef enum {
  /* Set the "low speed time" */
  CINIT(LOW_SPEED_TIME, LONG, 20),

  /* Set the continuation offset */
  /* Set the continuation offset.
   *
   * Note there is also a _LARGE version of this key which uses
   * off_t types, allowing for large file offsets on platforms which
   * use larger-than-32-bit off_t's.  Look below for RESUME_FROM_LARGE.
   */
  CINIT(RESUME_FROM, LONG, 21),

  /* Set cookie in request: */
@@ -699,9 +711,27 @@ typedef enum {
  CINIT(IPRESOLVE, LONG, 113),

  /* Set this option to limit the size of a file that will be downloaded from
     an HTTP or FTP server. */
     an HTTP or FTP server.

     Note there is also _LARGE version which adds large file support for
     platforms which have larger off_t sizes.  See MAXFILESIZE_LARGE below. */
  CINIT(MAXFILESIZE, LONG, 114),

  /* See the comment for INFILESIZE above, but in short, specifies
   * the size of the file being uploaded.  -1 means unknown.
   */
  CINIT(INFILESIZE_LARGE, OFF_T, 115),

  /* Sets the continuation offset.  There is also a LONG version of this;
   * look above for RESUME_FROM.
   */
  CINIT(RESUME_FROM_LARGE, OFF_T, 116),

  /* Sets the maximum size of data that will be downloaded from
   * an HTTP or FTP server.  See MAXFILESIZE above for the LONG version.
   */
  CINIT(MAXFILESIZE_LARGE, OFF_T, 117),

  /* Set this option to the file name of your .netrc file you want libcurl
     to parse (using the CURLOPT_NETRC option). If not set, libcurl will do
     a poor attempt to find the user's home directory and check for a .netrc
Loading