From 8ffc1b85b04ebe0142f19d7c6fe482576451676f Mon Sep 17 00:00:00 2001 From: joerg_wunsch Date: Fri, 12 Aug 2011 15:53:53 +0000 Subject: [PATCH] Contributed by tixiv@gmx.net: bug #33345: File auto detection as binary doesn't open file in binary mode on Windows * fileio.c: Move the decision about opening files in binary mode until before the fopen() call. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@964 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 8 ++++++++ fileio.c | 30 +++++++++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index f50f7c8f..a2e42412 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-08-12 Joerg Wunsch + + Contributed by tixiv@gmx.net: + bug #33345: File auto detection as binary doesn't open + file in binary mode on Windows + * fileio.c: Move the decision about opening files in + binary mode until before the fopen() call. + 2011-06-16 Thomas Fischl * avrdude.conf.in: Fix part id of ATtiny9. diff --git a/fileio.c b/fileio.c index f4ff016b..5af91bab 100644 --- a/fileio.c +++ b/fileio.c @@ -1034,21 +1034,6 @@ int fileio(int op, char * filename, FILEFMT format, if (rc < 0) return -1; -#if defined(WIN32NATIVE) - /* Open Raw Binary format in binary mode on Windows.*/ - if(format == FMT_RBIN) - { - if(fio.op == FIO_READ) - { - fio.mode = "rb"; - } - if(fio.op == FIO_WRITE) - { - fio.mode = "wb"; - } - } -#endif - /* point at the requested memory buffer */ buf = mem->buf; if (fio.op == FIO_READ) @@ -1100,6 +1085,21 @@ int fileio(int op, char * filename, FILEFMT format, } } +#if defined(WIN32NATIVE) + /* Open Raw Binary format in binary mode on Windows.*/ + if(format == FMT_RBIN) + { + if(fio.op == FIO_READ) + { + fio.mode = "rb"; + } + if(fio.op == FIO_WRITE) + { + fio.mode = "wb"; + } + } +#endif + if (format != FMT_IMM) { if (!using_stdio) { f = fopen(fname, fio.mode);