X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_File.cxx;h=77df586f5312799921dee836a88ba8da136f2402;hb=HEAD;hp=e4431ac9a3e92ee71cdebfb00bf6fc1b164696ea;hpb=0b4f557c95428aa7025773eef95eef5796a1e74a;p=modules%2Fsmesh.git diff --git a/src/SMESHUtils/SMESH_File.cxx b/src/SMESHUtils/SMESH_File.cxx index e4431ac9a..3048b69c4 100644 --- a/src/SMESHUtils/SMESH_File.cxx +++ b/src/SMESHUtils/SMESH_File.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -81,12 +81,12 @@ bool SMESH_File::open() if ( !_map && length > 0 ) { #ifdef WIN32 -#ifdef UNICODE - std::wstring aName = Kernel_Utils::utf8_decode_s(_name); - const wchar_t* name = aName.c_str(); -#else - char* name = name.data(); -#endif +# ifdef UNICODE + std::wstring aName = Kernel_Utils::utf8_decode_s(_name); + const wchar_t* name = aName.c_str(); +# else + char* name = _name.data(); +# endif _file = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); bool ok = ( _file != INVALID_HANDLE_VALUE ); @@ -319,14 +319,16 @@ bool SMESH_File::getInts(std::vector& ints) bool SMESH_File::openForWriting() { + close(); + #ifdef WIN32 #ifdef UNICODE - std::wstring aName = Kernel_Utils::utf8_decode_s(_name); - const wchar_t* name = aName.c_str(); + std::wstring aName = Kernel_Utils::utf8_decode_s(_name); + const wchar_t* name = aName.c_str(); #else - char* name = name.data(); + char* name = _name.data(); #endif - _file = CreateFile( name, // name of the write + _file = CreateFile( name, // name of the write GENERIC_WRITE, // open for writing 0, // do not share NULL, // default security