diff --git a/packages/vms/config-vms.h b/packages/vms/config-vms.h index 45ee1b18de883896fb779f70ea8d1db88d0a3116..275f0f12e071a3c760ffff9c09c4b51961bf538e 100644 --- a/packages/vms/config-vms.h +++ b/packages/vms/config-vms.h @@ -96,6 +96,9 @@ /* Define if you have the strstr function. */ #define HAVE_STRSTR 1 +/* Define if you have the ftruncate function. */ +#define HAVE_FTRUNCATE 1 + /* Define if you have the uname function. */ #define HAVE_UNAME 1 diff --git a/src/Makefile.netware b/src/Makefile.netware index d3d14fdfcd4d853e541bb743403e68a41e5040a3..c5f73c70455461f66e239a005957e85869f78874 100644 --- a/src/Makefile.netware +++ b/src/Makefile.netware @@ -280,6 +280,7 @@ config.h: Makefile.netware @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@ @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@ @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@ + @echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@ @echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@ @echo $(DL)#define HAVE_GETTIMEOFDAY 1$(DL) >> $@ @echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@ diff --git a/src/config-amigaos.h b/src/config-amigaos.h index 2d66e37e3a07fc79d13ae59d6fa9ad4cb4cb5066..0f904a30fb8bb890308367bc9a48f0587b0b4092 100644 --- a/src/config-amigaos.h +++ b/src/config-amigaos.h @@ -18,6 +18,7 @@ #define HAVE_TIME_H 1 #define TIME_WITH_SYS_TIME 1 #define HAVE_TERMIOS_H 1 +#define HAVE_FTRUNCATE 1 #define HAVE_PWD_H 1 diff --git a/src/config-mac.h b/src/config-mac.h index 36505c94ccdd6f630e05b4722fcb7da6ac72ae33..e1806d5c6b5b04a65614620f0e8f8452f2b81447 100644 --- a/src/config-mac.h +++ b/src/config-mac.h @@ -8,6 +8,7 @@ #define HAVE_SETVBUF 1 #define HAVE_UTIME 1 +#define HAVE_FTRUNCATE 1 #define main(x,y) curl_main(x,y) diff --git a/src/config-riscos.h b/src/config-riscos.h index 166021421ec5e5075b2300b67f937a8965537228..3213364793d795675ab5549b75f4ed7581342fa6 100644 --- a/src/config-riscos.h +++ b/src/config-riscos.h @@ -89,6 +89,9 @@ /* Define if you have the header file. */ #define HAVE_FCNTL_H +/* Define if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE + /* Define if getaddrinfo exists and works */ #define HAVE_GETADDRINFO diff --git a/src/config-vms.h b/src/config-vms.h index 79f1ba7b76c48caf56544a87eec18d75f1321716..3df6535d5826b7d4b5b2b458da83fd26863af63c 100644 --- a/src/config-vms.h +++ b/src/config-vms.h @@ -11,6 +11,9 @@ /* Define if you have the header file. */ #undef HAVE_IO_H +/* Define if you have ftruncate() */ +#define HAVE_FTRUNCATE 1 + /* Define if you have strdup() */ #define HAVE_STRDUP 1 diff --git a/src/config-win32.h b/src/config-win32.h index a7c0d16829fe4e31a2353aa5c9edc57b8d5e919f..c07c349e5dd6feed5d17dbbb6d522fc7cffcbc4e 100644 --- a/src/config-win32.h +++ b/src/config-win32.h @@ -14,6 +14,9 @@ /* Define if you have the header file */ #define HAVE_LIMITS_H 1 +/* Define if you have the ftruncate function. */ +#define HAVE_FTRUNCATE 1 + /* Define if you have the strdup function. */ #define HAVE_STRDUP 1 diff --git a/src/main.c b/src/main.c index b37d1dae010aab62bd4b60d668863cde01b65e1b..43e9c4939a1ed7664fe6485521d5d9ac2e5be22b 100644 --- a/src/main.c +++ b/src/main.c @@ -3771,10 +3771,12 @@ operate(struct Configurable *config, int argc, char *argv[]) " bytes\n", outs.bytes); fflush(outs.stream); /* truncate file at the position where we started appending */ +#ifdef HAVE_FTRUNCATE ftruncate( fileno(outs.stream), outs.init); +#endif /* now seek to the end of the file, the position where we just truncated the file */ - fseek(outs.stream, 0, SEEK_END); + fseek(outs.stream, outs.init, SEEK_SET); outs.bytes = 0; /* clear for next round */ } continue;