X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_File.cxx;h=8d138b46cee114b2425be891aa87241073809f16;hp=ade3256bbe7c5a3d2d52e485b22452586c99416a;hb=ad4fc4d4c9f7b740fa6b7a7e1cacd173915c1bcb;hpb=4edb4666f465956c76c5b41ec9c8fc582dbea64a diff --git a/src/SMESHUtils/SMESH_File.cxx b/src/SMESHUtils/SMESH_File.cxx index ade3256bb..8d138b46c 100644 --- a/src/SMESHUtils/SMESH_File.cxx +++ b/src/SMESHUtils/SMESH_File.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -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(); } @@ -105,6 +111,10 @@ bool SMESH_File::open() #endif } } + else if ( _error.empty() ) + { + _error = "Can't open for reading an existing file " + _name; + } } return _pos; } @@ -134,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 } }