file needs to be Binary for windows
authorDave Murphy <davem@devkitpro.org>
Sun, 6 Jan 2013 15:34:54 +0000 (15:34 +0000)
committerDave Murphy <davem@devkitpro.org>
Sun, 6 Jan 2013 15:59:57 +0000 (15:59 +0000)
O_BINARY only defined on windows

src/stlink-common.c

index 82d6070897523171619d2a5c7be8df8215aaac20..2d7db142cfa6ee5a5ed6d6bc7966bc2052a7fdf0 100644 (file)
 #include "stlink-common.h"
 #include "uglylogging.h"
 
+#ifndef _WIN32
+#define O_BINARY 0
+#endif
+
 #define LOG_TAG __FILE__
 #define DLOG(format, args...)         ugly_log(UDEBUG, LOG_TAG, format, ## args)
 #define ILOG(format, args...)         ugly_log(UINFO, LOG_TAG, format, ## args)
@@ -757,7 +761,7 @@ static int map_file(mapped_file_t* mf, const char* path) {
     int error = -1;
     struct stat st;
 
-    const int fd = open(path, O_RDONLY);
+    const int fd = open(path, O_RDONLY | O_BINARY);
     if (fd == -1) {
         fprintf(stderr, "open(%s) == -1\n", path);
         return -1;