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
This commit is contained in:
Joerg Wunsch 2011-08-12 15:53:53 +00:00
parent 6a8d1d55be
commit d640768544
2 changed files with 23 additions and 15 deletions

View File

@ -1,3 +1,11 @@
2011-08-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
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 <tfischl@gmx.de> 2011-06-16 Thomas Fischl <tfischl@gmx.de>
* avrdude.conf.in: Fix part id of ATtiny9. * avrdude.conf.in: Fix part id of ATtiny9.

View File

@ -1034,21 +1034,6 @@ int fileio(int op, char * filename, FILEFMT format,
if (rc < 0) if (rc < 0)
return -1; 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 */ /* point at the requested memory buffer */
buf = mem->buf; buf = mem->buf;
if (fio.op == FIO_READ) 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 (format != FMT_IMM) {
if (!using_stdio) { if (!using_stdio) {
f = fopen(fname, fio.mode); f = fopen(fname, fio.mode);