-// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 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
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 );
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