From 5fb2f09ff3baf7ea433a586e779a5abd731a9320 Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Mon, 4 Feb 2019 10:35:29 +0100 Subject: [PATCH] Fixed getObjectType failure. --- src/TNL/Object_impl.h | 6 +----- src/Tools/tnl-diff.h | 10 +++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/TNL/Object_impl.h b/src/TNL/Object_impl.h index 70415f8e81..f0b1a8545a 100644 --- a/src/TNL/Object_impl.h +++ b/src/TNL/Object_impl.h @@ -103,11 +103,7 @@ inline bool Object :: boundLoad( const String& fileName ) inline bool getObjectType( File& file, String& type ) { char mn[ 10 ]; - if( ! file.read( mn, strlen( magic_number ) ) ) - { - std::cerr << "Unable to read file " << file.getFileName() << " ... " << std::endl; - return false; - } + file.read( mn, strlen( magic_number ) ); if( strncmp( mn, magic_number, 5 ) != 0 ) { std::cout << "Not a TNL file (wrong magic number)." << std::endl; diff --git a/src/Tools/tnl-diff.h b/src/Tools/tnl-diff.h index 06344f5968..9623aa34bc 100644 --- a/src/Tools/tnl-diff.h +++ b/src/Tools/tnl-diff.h @@ -623,9 +623,13 @@ bool processFiles( const Config::ParameterContainer& parameters ) } String objectType; - if( ! getObjectType( inputFiles[ 0 ], objectType ) ) { - std::cerr << "unknown object ... SKIPPING!" << std::endl; - return false; + try + { + getObjectType( inputFiles[ 0 ], objectType ); + } + catch( std::ios_base::failure exception ) + { + std::cerr << "Cannot open file " << inputFiles[ 0 ] << std::endl; } if( verbose ) -- GitLab