(http://curl.haxx.se/mail/archive-2007-12/0039.html) reported and fixed
a file truncation problem on Windows build targets triggered when retrying a download with curl.
This commit is contained in:
4
CHANGES
4
CHANGES
@@ -13,6 +13,10 @@ Yang Tse (18 Dec 2007)
|
|||||||
if no build target has been defined we will target WinXP when building
|
if no build target has been defined we will target WinXP when building
|
||||||
curl/libcurl with MSVC 9.0 (VS2008).
|
curl/libcurl with MSVC 9.0 (VS2008).
|
||||||
|
|
||||||
|
- (http://curl.haxx.se/mail/archive-2007-12/0039.html) reported and fixed
|
||||||
|
a file truncation problem on Windows build targets triggered when retrying
|
||||||
|
a download with curl.
|
||||||
|
|
||||||
Daniel S (17 Dec 2007)
|
Daniel S (17 Dec 2007)
|
||||||
- Mateusz Loskot pointed out that MSVC 9.0 (VS2008) has the pollfd struct and
|
- Mateusz Loskot pointed out that MSVC 9.0 (VS2008) has the pollfd struct and
|
||||||
defines in winsock2.h somehow differently than previous versions and that
|
defines in winsock2.h somehow differently than previous versions and that
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ This release includes the following bugfixes:
|
|||||||
o POST with callback over proxy requiring NTLM or Digest
|
o POST with callback over proxy requiring NTLM or Digest
|
||||||
o Expect: 100-continue flaw on re-used connection with POSTs
|
o Expect: 100-continue flaw on re-used connection with POSTs
|
||||||
o build fix for MSVC 9.0 (VS2008)
|
o build fix for MSVC 9.0 (VS2008)
|
||||||
|
o Windows curl builds failed file truncation when retry downloading
|
||||||
|
|
||||||
This release includes the following known bugs:
|
This release includes the following known bugs:
|
||||||
|
|
||||||
|
|||||||
20
src/main.c
20
src/main.c
@@ -323,21 +323,19 @@ char convert_char(curl_infotype infotype, char this_char)
|
|||||||
#define _lseeki64(hnd,ofs,whence) lseek(hnd,ofs,whence)
|
#define _lseeki64(hnd,ofs,whence) lseek(hnd,ofs,whence)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_FTRUNCATE
|
||||||
|
#define HAVE_FTRUNCATE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
static int ftruncate64 (int fd, curl_off_t where)
|
static int ftruncate64 (int fd, curl_off_t where)
|
||||||
{
|
{
|
||||||
curl_off_t curr;
|
if(_lseeki64(fd, where, SEEK_SET) < 0)
|
||||||
int rc = 0;
|
return -1;
|
||||||
|
|
||||||
if ((curr = _lseeki64(fd, 0, SEEK_CUR)) < 0)
|
if(!SetEndOfFile((HANDLE)_get_osfhandle(fd)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (_lseeki64(fd, where, SEEK_SET) < 0)
|
return 0;
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (write(fd, 0, 0) < 0)
|
|
||||||
rc = -1;
|
|
||||||
_lseeki64(fd, curr, SEEK_SET);
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
#define ftruncate(fd,where) ftruncate64(fd,where)
|
#define ftruncate(fd,where) ftruncate64(fd,where)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user