Commit 82d1352e authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed File::open to avoid memory leak

parent 1b7a3c31
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ File :: ~File()
bool File :: open( const String& fileName,
                   const IOMode mode )
{
   // close the existing file to avoid memory leaks
   this->close();

   this->fileName = fileName;
   if( verbose )
   {
@@ -75,17 +78,13 @@ bool File :: close()
   fileName = "";
   readElements = writtenElements = 0;
   return true;
};
}

bool fileExists( const String& fileName )
{
  std::fstream file;
  file.open( fileName.getString(), std::ios::in );
  bool result( true );
  if( ! file )
     result = false;
  file.close();
  return result;
};
  return ! file.fail();
}

} // namespace TNL