]> Creatis software - clitk.git/blobdiff - common/clitkXdrImageIOWriter.cxx
Remove debug verbose
[clitk.git] / common / clitkXdrImageIOWriter.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 2b4d497..fc75976
@@ -3,7 +3,7 @@
 
   Authors belong to:
   - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
   This software is distributed WITHOUT ANY WARRANTY; without even
@@ -14,7 +14,7 @@
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+===========================================================================**/
 /**
  * @file   clitkXdrImageIO.cxx
  * @author Simon Rit <simon.rit@gmail.com>
@@ -34,7 +34,7 @@
 #if !defined(unix) && !defined(__APPLE__)
 //#define _read  readfix
 #endif
-#define AVSINT ptrdiff_t
+#define AVSINT std::ptrdiff_t
 #define AVS_ERROR
 #define AVS_OK
 
@@ -97,6 +97,9 @@ void clitk::XdrImageIO::Write(const void* buffer)
 #include <math.h>
 #include <stdlib.h>
 #include <limits.h>
+#ifndef _WIN32
+#  include <unistd.h>
+#endif
 #if !defined(unix) && !defined(__APPLE__)
 #include <io.h>
 #endif
@@ -105,7 +108,7 @@ void clitk::XdrImageIO::Write(const void* buffer)
 
 #include <algorithm>
 
-#ifdef WIN32
+#ifdef _WIN32
 // don't use min() and max() macros indirectly defined by windows.h,
 // but use portable std::min() and std:max() instead
 #ifndef NOMINMAX
@@ -253,7 +256,7 @@ static int wxdr_write(int handle, const void * buf, unsigned len)
 {
   // if (handle == 1) // stdout
   if (handle == fileno(stdout)) {
-#ifdef WIN32
+#ifdef _WIN32
     // Behave as C standard library write(): return number of bytes
     // written or -1 and errno set on error.
     fflush(stdout);
@@ -834,6 +837,12 @@ void clitk::XdrImageIO::WriteImage(const char* file, char* headerinfo, char* hea
   char     *buf2;
   size_t   slen;
 
+#ifdef _WIN32
+  int oldFMode;
+  _get_fmode(&oldFMode);
+  _set_fmode(O_BINARY); /* default binary i/o */
+#endif
+
   if (bLittleEndian)
     swap_test = 0x00000001;
 
@@ -1200,5 +1209,10 @@ WRITE_COORDS:
     if (f != fileno(stdout)) close(f);
 
   if (getsize) return;
+
+#ifdef _WIN32
+  _set_fmode(oldFMode ? oldFMode : _O_TEXT); /* restore default binary i/o */
+#endif
+
   return AVS_OK;
 }