X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkXdrImageIOWriter.cxx;h=6eae6a595f529f45a76286370010b25710a30a61;hb=b7b8f2b040d1772c30c34653ee3fe0c27bc8fa71;hp=1e826db7d6ab07b49142085d84d2ce6180069fba;hpb=faf73a151b8b24e5590a39d58dd69040f0ff1303;p=clitk.git diff --git a/common/clitkXdrImageIOWriter.cxx b/common/clitkXdrImageIOWriter.cxx index 1e826db..6eae6a5 100644 --- a/common/clitkXdrImageIOWriter.cxx +++ b/common/clitkXdrImageIOWriter.cxx @@ -41,7 +41,7 @@ //From portdefs.h #if defined(unix) || defined(__APPLE__) #define O_BINARY 0 -#define setmode(a,b) 0 +//#define setmode(a,b) 0 // comment by ds #endif #ifndef __LARGE__ @@ -97,16 +97,18 @@ void clitk::XdrImageIO::Write(const void* buffer) #include #include #include -#include -#if !defined(unix) && !defined(__APPLE__) -#include +#ifndef _WIN32 +# include +#endif +#ifdef _WIN32 +# include #endif #include #include #include -#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 @@ -254,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); @@ -835,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; @@ -949,7 +957,7 @@ void clitk::XdrImageIO::WriteImage(const char* file, char* headerinfo, char* hea for (i=0; i