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=ab53c66b268d97cd57d9aa9fea94b8fa74383c01;p=rrdtool.git for windows we must open files in O_BINARY mode git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1423 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_create.c b/src/rrd_create.c index bb8d45d..028123e 100644 --- a/src/rrd_create.c +++ b/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/src/rrd_open.c b/src/rrd_open.c index 4caebd3..67687fa 100644 --- a/src/rrd_open.c +++ b/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;