From 87599e519f4484344178df54e787d0872deb5869 Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 18 Feb 2010 23:33:56 +0000 Subject: [PATCH] added a minimal support for failing and reporting errors --- wrap/io_trimesh/export_vmi.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/wrap/io_trimesh/export_vmi.h b/wrap/io_trimesh/export_vmi.h index 4ca070ce..d31b2f9f 100644 --- a/wrap/io_trimesh/export_vmi.h +++ b/wrap/io_trimesh/export_vmi.h @@ -231,11 +231,12 @@ namespace io { public: - static void Save(const SaveMeshType &m,const char * filename){ + static int Save(const SaveMeshType &m,const char * filename){ unsigned int i; unsigned int vertSize,faceSize; F() = fopen(filename,"wb"); - std::vector nameF,nameV; + if(F()==NULL) return 1; // 1 is the error code for cant'open, see the ErrorMsg function + std::vector nameF,nameV; SaveMeshType::FaceType::Name(nameF); SaveMeshType::VertexType::Name(nameV); vertSize = m.vert.size(); @@ -375,8 +376,21 @@ namespace io { // fflush(F()); fclose(F()); + return 0; } + static const char *ErrorMsg(int error) + { + static std::vector off_error_msg; + if(off_error_msg.empty()) + { + off_error_msg.resize(2 ); + off_error_msg[0]="No errors"; + off_error_msg[1]="Can't open file"; + } + if(error>1 || error<0) return "Unknown error"; + else return off_error_msg[error].c_str(); + } }; // end class } // end Namespace tri