X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_File.cxx;h=556212201577637d642265fd613a4cc9ecde78b8;hb=88d37b48bdda91c42c4ddcdb0f1c451c05fb552e;hp=b0720551629cf4757b476920df69f09241035e28;hpb=2107fb0fba6fb5276625455541e4ee59a6c5b305;p=modules%2Fsmesh.git diff --git a/src/SMESHUtils/SMESH_File.cxx b/src/SMESHUtils/SMESH_File.cxx index b07205516..556212201 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-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 @@ -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(); } @@ -69,7 +75,7 @@ SMESH_File::~SMESH_File() bool SMESH_File::open() { - int length = size(); + long length = size(); if ( !_map && length > 0 ) { #ifdef WIN32 @@ -138,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 } } @@ -178,7 +188,7 @@ long SMESH_File::size() boost::uintmax_t size = boofs::file_size( _name, err ); _error = err.message(); - return err ? -1 : (long) size; + return !err ? (long) size : -1; } //================================================================================ @@ -261,7 +271,7 @@ void SMESH_File::rewind() bool SMESH_File::getInts(std::vector& ints) { - int i = 0; + size_t i = 0; while ( i < ints.size() ) { while ( !isdigit( *_pos ) && !eof()) ++_pos; @@ -320,7 +330,7 @@ bool SMESH_File::writeRaw(const void* data, size_t size) #else ssize_t nbWritten = ::write( _file, data, size ); - return ( nbWritten == size ); + return ( nbWritten == (ssize_t) size ); #endif }