X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2Fold%2FclitkIOCommon.cxx;fp=common%2FclitkIOCommon.cxx;h=be69d374edfa5caad8f08db2a7b1c689a99d37f4;hb=9284f78523ef4469d086d04c1bcd791ce00575d1;hp=16ec36127d677b7b3cf377d0b32f007666dddf17;hpb=e534754cde3aee05927b1ca4aa6962dc05ee0322;p=clitk.git diff --git a/common/clitkIOCommon.cxx b/common/old/clitkIOCommon.cxx similarity index 94% rename from common/clitkIOCommon.cxx rename to common/old/clitkIOCommon.cxx index 16ec361..be69d37 100644 --- a/common/clitkIOCommon.cxx +++ b/common/old/clitkIOCommon.cxx @@ -28,7 +28,8 @@ PURPOSE. See the above copyright notices for more information. =================================================*/ // clitk include -#include "clitkIOCommon.h" +#include "clitkImageCommon.h" +#include //==================================================================== // Open a file for reading @@ -66,10 +67,17 @@ gdcm::File * clitk::readDicomHeader(const std::string & filename, //==================================================================== //==================================================================== -itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename) { +itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename, bool exit_on_error) { itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode); - if (!reader) return NULL; + if (!reader) + if (exit_on_error) //default behavior for tools who don't handle the problem + { + std::cerr "Error reading file " << filename << ", exiting immediately" << std::endl; + std::exit(-1); + } + else + return NULL; reader->SetFileName(filename); reader->ReadImageInformation(); return reader;