X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkXdrImageIOWriter.cxx;h=fc75976b7feff9dfd92ed58e2f6008b1a0d7d709;hb=c25dc5b9c8094da27269fa006f847ddd8154c8e1;hp=1e826db7d6ab07b49142085d84d2ce6180069fba;hpb=faf73a151b8b24e5590a39d58dd69040f0ff1303;p=clitk.git diff --git a/common/clitkXdrImageIOWriter.cxx b/common/clitkXdrImageIOWriter.cxx index 1e826db..fc75976 100644 --- a/common/clitkXdrImageIOWriter.cxx +++ b/common/clitkXdrImageIOWriter.cxx @@ -97,7 +97,9 @@ void clitk::XdrImageIO::Write(const void* buffer) #include #include #include -#include +#ifndef _WIN32 +# include +#endif #if !defined(unix) && !defined(__APPLE__) #include #endif @@ -106,7 +108,7 @@ void clitk::XdrImageIO::Write(const void* buffer) #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; @@ -1201,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; }