From: oetiker Date: Tue, 10 Jun 2008 07:18:02 +0000 (+0000) Subject: for windows we must open files in O_BINARY mode X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1f8f1d85e44f350be0684b7364894436bb9e70e5;p=rrdtool-all.git for windows we must open files in O_BINARY mode git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1423 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_create.c b/program/src/rrd_create.c index bb8d45d6..028123ef 100644 --- a/program/src/rrd_create.c +++ b/program/src/rrd_create.c @@ -675,8 +675,12 @@ int rrd_create_fn( int unkn_cnt; rrd_file_t *rrd_file_dn; rrd_t rrd_dn; + unsigned flags = O_WRONLY | O_CREAT | O_TRUNC; +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) + flags |= O_BINARY; +#endif - if ((rrd_file = open(file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) { + if ((rrd_file = open(file_name, flags, 0666)) < 0) { rrd_set_error("creating '%s': %s", file_name, rrd_strerror(errno)); free(rrd->stat_head); free(rrd->live_head); diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c index 4caebd39..67687fad 100644 --- a/program/src/rrd_open.c +++ b/program/src/rrd_open.c @@ -117,6 +117,10 @@ rrd_file_t *rrd_open( #endif } +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) + flags |= O_BINARY; +#endif + if ((rrd_file->fd = open(file_name, flags, mode)) < 0) { rrd_set_error("opening '%s': %s", file_name, rrd_strerror(errno)); goto out_free;