From: rnv Date: Mon, 5 May 2014 15:35:24 +0000 (+0400) Subject: Fix a problem with the zero file descriptor. X-Git-Tag: V7_4_0rc1~10^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=462fad4cea04bee25aeae56ecb34c2ce799cc28d Fix a problem with the zero file descriptor. --- diff --git a/src/SMESHUtils/SMESH_File.cxx b/src/SMESHUtils/SMESH_File.cxx index b07205516..d4311bb71 100644 --- a/src/SMESHUtils/SMESH_File.cxx +++ b/src/SMESHUtils/SMESH_File.cxx @@ -45,7 +45,13 @@ namespace boofs = boost::filesystem; //================================================================================ SMESH_File::SMESH_File(const std::string& name, bool open) - :_name(name), _size(-1), _file(0), _map(0), _pos(0), _end(0) + :_name(name), _size(-1), +#ifdef WIN32 + _file(INVALID_HANDLE_VALUE), +#else + _file(-1), +#endif + _map(0), _pos(0), _end(0) { if ( open ) this->open(); } @@ -138,11 +144,15 @@ void SMESH_File::close() else if ( _file >= 0 ) { #ifdef WIN32 - CloseHandle(_file); - _file = INVALID_HANDLE_VALUE; + if(_file != INVALID_HANDLE_VALUE) { + CloseHandle(_file); + _file = INVALID_HANDLE_VALUE; + } #else - ::close(_file); - _file = -1; + if(_file != -1) { + ::close(_file); + _file = -1; + } #endif } }