From 1f8f1d85e44f350be0684b7364894436bb9e70e5 Mon Sep 17 00:00:00 2001 From: oetiker Date: Tue, 10 Jun 2008 07:18:02 +0000 Subject: [PATCH] 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 --- program/src/rrd_create.c | 6 +++++- program/src/rrd_open.c | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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; -- 2.30.2