added a minimal support for failing and reporting errors
This commit is contained in:
parent
898fedcfdf
commit
87599e519f
|
@ -231,10 +231,11 @@ namespace io {
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Save(const SaveMeshType &m,const char * filename){
|
static int Save(const SaveMeshType &m,const char * filename){
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int vertSize,faceSize;
|
unsigned int vertSize,faceSize;
|
||||||
F() = fopen(filename,"wb");
|
F() = fopen(filename,"wb");
|
||||||
|
if(F()==NULL) return 1; // 1 is the error code for cant'open, see the ErrorMsg function
|
||||||
std::vector<std::string> nameF,nameV;
|
std::vector<std::string> nameF,nameV;
|
||||||
SaveMeshType::FaceType::Name(nameF);
|
SaveMeshType::FaceType::Name(nameF);
|
||||||
SaveMeshType::VertexType::Name(nameV);
|
SaveMeshType::VertexType::Name(nameV);
|
||||||
|
@ -375,8 +376,21 @@ namespace io {
|
||||||
|
|
||||||
// fflush(F());
|
// fflush(F());
|
||||||
fclose(F());
|
fclose(F());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static const char *ErrorMsg(int error)
|
||||||
|
{
|
||||||
|
static std::vector<std::string> 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 class
|
||||||
|
|
||||||
} // end Namespace tri
|
} // end Namespace tri
|
||||||
|
|
Loading…
Reference in New Issue