Open files in binary mode on systems that have O_BINARY
authorRon Yorston <rmy@tigress.co.uk>
Wed, 13 Nov 2013 10:06:47 +0000 (13 10:06 +0000)
committerChris Frey <cdfrey@foursquare.net>
Mon, 18 Nov 2013 05:32:42 +0000 (18 00:32 -0500)
There are three places in the library where files are opened.  In two
of those places the flag O_BINARY is included if defined.  This patch
does the same in the third.

I noticed this because I've been using (a hacked version of) the library
cross-compiled with MinGW on WIN32.  I expect Cygwin would also be
affected.

Ron

lib/append.c

index ff58532..32622f3 100644 (file)
@@ -218,7 +218,11 @@ tar_append_regfile(TAR *t, const char *realname)
        size_t size;
        int rv = -1;
 
+#if defined(O_BINARY)
+       filefd = open(realname, O_RDONLY|O_BINARY);
+#else
        filefd = open(realname, O_RDONLY);
+#endif
        if (filefd == -1)
        {
 #ifdef DEBUG