Salome HOME
projects
/
modules
/
smesh.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BUG: impossible to import a med file of size more than MAX_INT (~2.1 Gb)
[modules/smesh.git]
/
src
/
SMESHUtils
/
SMESH_File.cxx
diff --git
a/src/SMESHUtils/SMESH_File.cxx
b/src/SMESHUtils/SMESH_File.cxx
index c31c2e8bc1e90cc2e9e5a26240907a4b6a826b97..556212201577637d642265fd613a4cc9ecde78b8 100644
(file)
--- a/
src/SMESHUtils/SMESH_File.cxx
+++ b/
src/SMESHUtils/SMESH_File.cxx
@@
-1,4
+1,4
@@
-// Copyright (C) 2007-201
4
CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-201
6
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
//
// 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)
//================================================================================
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();
}
{
if ( open ) this->open();
}
@@
-69,7
+75,7
@@
SMESH_File::~SMESH_File()
bool SMESH_File::open()
{
bool SMESH_File::open()
{
-
int
length = size();
+
long
length = size();
if ( !_map && length > 0 )
{
#ifdef WIN32
if ( !_map && length > 0 )
{
#ifdef WIN32
@@
-78,7
+84,7
@@
bool SMESH_File::open()
bool ok = ( _file != INVALID_HANDLE_VALUE );
#else
_file = ::open(_name.data(), O_RDONLY );
bool ok = ( _file != INVALID_HANDLE_VALUE );
#else
_file = ::open(_name.data(), O_RDONLY );
- bool ok = ( _file > 0 );
+ bool ok = ( _file >
=
0 );
#endif
if ( ok )
{
#endif
if ( ok )
{
@@
-105,6
+111,10
@@
bool SMESH_File::open()
#endif
}
}
#endif
}
}
+ else if ( _error.empty() )
+ {
+ _error = "Can't open for reading an existing file " + _name;
+ }
}
return _pos;
}
}
return _pos;
}
@@
-134,11
+144,15
@@
void SMESH_File::close()
else if ( _file >= 0 )
{
#ifdef WIN32
else if ( _file >= 0 )
{
#ifdef WIN32
- CloseHandle(_file);
- _file = INVALID_HANDLE_VALUE;
+ if(_file != INVALID_HANDLE_VALUE) {
+ CloseHandle(_file);
+ _file = INVALID_HANDLE_VALUE;
+ }
#else
#else
- ::close(_file);
- _file = -1;
+ if(_file != -1) {
+ ::close(_file);
+ _file = -1;
+ }
#endif
}
}
#endif
}
}
@@
-171,10
+185,10
@@
long SMESH_File::size()
if ( _size >= 0 ) return _size; // size of an open file
boost::system::error_code err;
if ( _size >= 0 ) return _size; // size of an open file
boost::system::error_code err;
- uintmax_t size = boofs::file_size( _name, err );
+
boost::
uintmax_t size = boofs::file_size( _name, err );
_error = err.message();
_error = err.message();
- return
err ? -1 : (long) size
;
+ return
!err ? (long) size : -1
;
}
//================================================================================
}
//================================================================================
@@
-257,7
+271,7
@@
void SMESH_File::rewind()
bool SMESH_File::getInts(std::vector<int>& ints)
{
bool SMESH_File::getInts(std::vector<int>& ints)
{
-
in
t i = 0;
+
size_
t i = 0;
while ( i < ints.size() )
{
while ( !isdigit( *_pos ) && !eof()) ++_pos;
while ( i < ints.size() )
{
while ( !isdigit( *_pos ) && !eof()) ++_pos;
@@
-316,7
+330,7
@@
bool SMESH_File::writeRaw(const void* data, size_t size)
#else
ssize_t nbWritten = ::write( _file, data, size );
#else
ssize_t nbWritten = ::write( _file, data, size );
- return ( nbWritten == size );
+ return ( nbWritten ==
(ssize_t)
size );
#endif
}
#endif
}