-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 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
#include <boost/filesystem.hpp>
+#include <Basics_Utils.hxx>
+
namespace boofs = boost::filesystem;
//================================================================================
bool SMESH_File::open()
{
- int length = size();
+ long length = size();
if ( !_map && length > 0 )
{
#ifdef WIN32
- _file = CreateFile(_name.data(), GENERIC_READ, FILE_SHARE_READ,
+#ifdef UNICODE
+ const wchar_t* name = Kernel_Utils::decode(_name.data());
+#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 );
+#ifdef UNICODE
+ delete name;
+#endif
#else
_file = ::open(_name.data(), O_RDONLY );
bool ok = ( _file >= 0 );
boost::uintmax_t size = boofs::file_size( _name, err );
_error = err.message();
- return err ? -1 : (long) size;
+ return !err ? (long) size : -1;
}
//================================================================================
bool SMESH_File::getInts(std::vector<int>& ints)
{
- int i = 0;
+ size_t i = 0;
while ( i < ints.size() )
{
while ( !isdigit( *_pos ) && !eof()) ++_pos;
bool SMESH_File::openForWriting()
{
#ifdef WIN32
-
- _file = CreateFile( _name.c_str(), // name of the write
+#ifdef UNICODE
+ const wchar_t* name = Kernel_Utils::decode(_name.data());
+#else
+ char* name = name.data();
+#endif
+ _file = CreateFile( name, // name of the write
GENERIC_WRITE, // open for writing
0, // do not share
NULL, // default security
OPEN_ALWAYS, // CREATE NEW or OPEN EXISTING
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
+#ifdef UNICODE
+ delete name;
+#endif
return ( _file != INVALID_HANDLE_VALUE );
#else
#else
ssize_t nbWritten = ::write( _file, data, size );
- return ( nbWritten == size );
+ return ( nbWritten == (ssize_t) size );
#endif
}