curl-library
Re: [Patch] docs/examples/httpput.c
Date: Thu, 24 Oct 2013 15:21:16 +0200
"Dan Fandrich" <dan_at_coneharvesters.com> wrote:
>> But I'm not sure <unistd.h> is needed at all.
>
> It's needed for close(2). But the only reason that's needed is because fstat
> is used instead of stat(2); if you fix that, then you could remove that
> include altogether.
Okay. I've tested the following with MSVC and MingW. htttput.c now
simply uses stat():
--- Git-latest/docs/examples/httpput.c 2013-01-28 15:48:38 +0000
+++ docs/examples/httpput.c 2013-10-24 13:18:09 +0000
@@ -22,8 +22,6 @@
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
-#include <unistd.h>
-
#include <curl/curl.h>
/*
@@ -59,7 +57,6 @@
CURL *curl;
CURLcode res;
FILE * hd_src ;
- int hd ;
struct stat file_info;
char *file;
@@ -72,9 +69,7 @@
url = argv[2];
/* get the file size of the local file */
- hd = open(file, O_RDONLY) ;
- fstat(hd, &file_info);
- close(hd) ;
+ stat(file, &file_info);
/* get a FILE * of the same file, could also be made with
fdopen() from the previous descriptor, but hey this is just
-------
--gv
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-10-24