Revision: 57313
          http://sourceforge.net/p/brlcad/code/57313
Author:   mohitdaga
Date:     2013-08-30 10:44:28 +0000 (Fri, 30 Aug 2013)
Log Message:
-----------
add binary options for files read from stdin and stdout. This is specific for 
_WIN32 and __CYGWIN__ machines.

Modified Paths:
--------------
    brlcad/trunk/src/libicv/bw.c
    brlcad/trunk/src/libicv/pix.c

Modified: brlcad/trunk/src/libicv/bw.c
===================================================================
--- brlcad/trunk/src/libicv/bw.c        2013-08-30 10:13:26 UTC (rev 57312)
+++ brlcad/trunk/src/libicv/bw.c        2013-08-30 10:44:28 UTC (rev 57313)
@@ -59,9 +59,12 @@
     data =  data2uchar(bif);
     size = (size_t) bif->height*bif->width;
 
-    if(filename==NULL)
+    if(filename==NULL) {
        fd = fileno(stdout);
-    else if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, WRMODE)) 
< 0) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+    setmode(fd, O_BINARY);
+#endif
+    } else if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 
WRMODE)) < 0) {
        bu_log("bw_write: Cannot open file for saving\n");
        return -1;
     }
@@ -86,9 +89,12 @@
     size_t size;
     size_t buffsize=1024;
 
-    if(filename==NULL)
+    if(filename==NULL) {
        fd = fileno(stdin);
-    else if ((fd = open(filename, O_RDONLY, WRMODE)) < 0) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+    setmode(fd, O_BINARY);
+#endif
+    } else if ((fd = open(filename, O_RDONLY, WRMODE)) < 0) {
        bu_log("bw_read: Cannot open %s for reading\n", filename);
        return NULL;
     }

Modified: brlcad/trunk/src/libicv/pix.c
===================================================================
--- brlcad/trunk/src/libicv/pix.c       2013-08-30 10:13:26 UTC (rev 57312)
+++ brlcad/trunk/src/libicv/pix.c       2013-08-30 10:44:28 UTC (rev 57313)
@@ -55,9 +55,12 @@
        return -1;
     }
 
-    if(filename==NULL)
+    if(filename==NULL) {
        fd = fileno(stdout);
-    else if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, WRMODE)) 
< 0) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+    setmode(fd, O_BINARY);
+#endif
+    } else if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 
WRMODE)) < 0) {
        bu_log("pix_write: Cannot open file for saving\n");
        return -1;
     }
@@ -83,9 +86,12 @@
     size_t size;
     size_t buffsize=1024*3;
 
-    if(filename == NULL)
+    if(filename == NULL) {
        fd = fileno(stdin);
-    else if ((fd = open(filename, O_RDONLY, WRMODE))<0) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+    setmode(fd, O_BINARY);
+#endif
+    } else if ((fd = open(filename, O_RDONLY, WRMODE))<0) {
        bu_log("pix_read: Cannot open file for reading\n");
        return NULL;
     }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to