added check for save errors
This commit is contained in:
parent
21d49e900e
commit
eaff614cb9
|
@ -86,8 +86,11 @@ public:
|
||||||
fprintf(o,"ENDSEC\n");
|
fprintf(o,"ENDSEC\n");
|
||||||
fprintf(o,"0\n");
|
fprintf(o,"0\n");
|
||||||
fprintf(o,"EOF\n");
|
fprintf(o,"EOF\n");
|
||||||
|
|
||||||
|
int result = 0;
|
||||||
|
if (ferror(o)) result = 2;
|
||||||
fclose(o);
|
fclose(o);
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
/// Standard call for knowing the meaning of an error code
|
/// Standard call for knowing the meaning of an error code
|
||||||
static const char *ErrorMsg(int error)
|
static const char *ErrorMsg(int error)
|
||||||
|
@ -95,12 +98,13 @@ public:
|
||||||
static std::vector<std::string> dxf_error_msg;
|
static std::vector<std::string> dxf_error_msg;
|
||||||
if (dxf_error_msg.empty())
|
if (dxf_error_msg.empty())
|
||||||
{
|
{
|
||||||
dxf_error_msg.resize(2 );
|
dxf_error_msg.resize(3);
|
||||||
dxf_error_msg[0] = "No errors";
|
dxf_error_msg[0] = "No errors";
|
||||||
dxf_error_msg[1] = "Can't open file";
|
dxf_error_msg[1] = "Can't open file";
|
||||||
|
dxf_error_msg[2] = "Output Stream Error";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(error>1 || error<0) return "Unknown error";
|
if (error>2 || error<0) return "Unknown error";
|
||||||
else return dxf_error_msg[error].c_str();
|
else return dxf_error_msg[error].c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,11 @@ namespace vcg {
|
||||||
for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi)
|
for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
(*vi).Flags()=FlagV[j++];
|
(*vi).Flags()=FlagV[j++];
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
int result = 0;
|
||||||
|
if (stream.status() != QTextStream::Ok) result = 3;
|
||||||
|
stream.flush();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *ErrorMsg(int error)
|
static const char *ErrorMsg(int error)
|
||||||
|
@ -181,13 +185,14 @@ namespace vcg {
|
||||||
static std::vector<std::string> off_error_msg;
|
static std::vector<std::string> off_error_msg;
|
||||||
if (off_error_msg.empty())
|
if (off_error_msg.empty())
|
||||||
{
|
{
|
||||||
off_error_msg.resize(2 );
|
off_error_msg.resize(4);
|
||||||
off_error_msg[0] = "No errors";
|
off_error_msg[0] = "No errors";
|
||||||
off_error_msg[1] = "Can't open file";
|
off_error_msg[1] = "Can't open file";
|
||||||
off_error_msg[2] = "Internal error";
|
off_error_msg[2] = "Internal error";
|
||||||
|
off_error_msg[3] = "Otput Stream Error";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(error>2 || error<0) return "Unknown error";
|
if (error>3 || error<0) return "Unknown error";
|
||||||
else return off_error_msg[error].c_str();
|
else return off_error_msg[error].c_str();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -62,7 +62,8 @@ public:
|
||||||
E_NOTDEFINITION, // 5
|
E_NOTDEFINITION, // 5
|
||||||
E_NO_VERTICES, // 6
|
E_NO_VERTICES, // 6
|
||||||
E_NOTFACESVALID, // 7
|
E_NOTFACESVALID, // 7
|
||||||
E_NO_VALID_MATERIAL
|
E_NO_VALID_MATERIAL, // 8
|
||||||
|
E_STREAMERROR // 9
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -80,10 +81,11 @@ public:
|
||||||
"Function not defined", // 5
|
"Function not defined", // 5
|
||||||
"Vertices not valid", // 6
|
"Vertices not valid", // 6
|
||||||
"Faces not valid", // 7
|
"Faces not valid", // 7
|
||||||
"The mesh has not a attribute containing the vector of materials" // 8
|
"The mesh has not a attribute containing the vector of materials", // 8
|
||||||
|
"Output Stream Error" //9
|
||||||
};
|
};
|
||||||
|
|
||||||
if(error>7 || error<0) return "Unknown error";
|
if(error>9 || error<0) return "Unknown error";
|
||||||
else return obj_error_msg[error];
|
else return obj_error_msg[error];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -277,7 +279,6 @@ public:
|
||||||
fprintf(fp,"# %d faces, %d coords texture\n\n",m.fn,int(CoordIndexTexture.size()));
|
fprintf(fp,"# %d faces, %d coords texture\n\n",m.fn,int(CoordIndexTexture.size()));
|
||||||
|
|
||||||
fprintf(fp,"# End of File\n");
|
fprintf(fp,"# End of File\n");
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
int errCode = E_NOERROR;
|
int errCode = E_NOERROR;
|
||||||
if((mask & Mask::IOM_WEDGTEXCOORD) || (mask & Mask::IOM_FACECOLOR) || (mask & Mask::IOM_VERTTEXCOORD) )
|
if((mask & Mask::IOM_WEDGTEXCOORD) || (mask & Mask::IOM_FACECOLOR) || (mask & Mask::IOM_VERTTEXCOORD) )
|
||||||
|
@ -286,9 +287,13 @@ public:
|
||||||
else errCode = WriteMaterials(materialVec, filename,cb);
|
else errCode = WriteMaterials(materialVec, filename,cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int result = E_NOERROR;
|
||||||
if (errCode != E_NOERROR)
|
if (errCode != E_NOERROR)
|
||||||
return errCode;
|
result = errCode;
|
||||||
return E_NOERROR;
|
else if (ferror(fp))
|
||||||
|
result = E_STREAMERROR;
|
||||||
|
fclose(fp);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -139,14 +139,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fclose(fpout);
|
|
||||||
// Recupera i flag originali
|
// Recupera i flag originali
|
||||||
j=0;
|
j=0;
|
||||||
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
(*vi).Flags()=FlagV[j++];
|
(*vi).Flags()=FlagV[j++];
|
||||||
|
|
||||||
return 0;
|
int result = 0;
|
||||||
|
if (ferror(fpout)) result = 2;
|
||||||
|
fclose(fpout);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *ErrorMsg(int error)
|
static const char *ErrorMsg(int error)
|
||||||
|
@ -154,12 +155,13 @@ public:
|
||||||
static std::vector<std::string> off_error_msg;
|
static std::vector<std::string> off_error_msg;
|
||||||
if (off_error_msg.empty())
|
if (off_error_msg.empty())
|
||||||
{
|
{
|
||||||
off_error_msg.resize(2 );
|
off_error_msg.resize(3);
|
||||||
off_error_msg[0] = "No errors";
|
off_error_msg[0] = "No errors";
|
||||||
off_error_msg[1] = "Can't open file";
|
off_error_msg[1] = "Can't open file";
|
||||||
|
off_error_msg[1] = "Output Stream error";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(error>1 || error<0) return "Unknown error";
|
if (error>2 || error<0) return "Unknown error";
|
||||||
else return off_error_msg[error].c_str();
|
else return off_error_msg[error].c_str();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -756,8 +756,10 @@ namespace vcg {
|
||||||
}
|
}
|
||||||
assert(ecnt==m.en);
|
assert(ecnt==m.en);
|
||||||
}
|
}
|
||||||
|
int result = 0;
|
||||||
|
if (ferror(fpout)) result = ply::E_STREAMERROR;
|
||||||
fclose(fpout);
|
fclose(fpout);
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *ErrorMsg(int error)
|
static const char *ErrorMsg(int error)
|
||||||
|
@ -780,6 +782,8 @@ namespace vcg {
|
||||||
ply_error_msg[ply::E_INCOMPATIBLETYPE ]="Incompatible type";
|
ply_error_msg[ply::E_INCOMPATIBLETYPE ]="Incompatible type";
|
||||||
ply_error_msg[ply::E_BADCAST ]="Bad cast";
|
ply_error_msg[ply::E_BADCAST ]="Bad cast";
|
||||||
|
|
||||||
|
ply_error_msg[ply::E_STREAMERROR ] = "Output Stream Error";
|
||||||
|
|
||||||
ply_error_msg[PlyInfo::E_NO_VERTEX ]="No vertex field found";
|
ply_error_msg[PlyInfo::E_NO_VERTEX ]="No vertex field found";
|
||||||
ply_error_msg[PlyInfo::E_NO_FACE ]="No face field found";
|
ply_error_msg[PlyInfo::E_NO_FACE ]="No face field found";
|
||||||
ply_error_msg[PlyInfo::E_SHORTFILE ]="Unespected eof";
|
ply_error_msg[PlyInfo::E_SHORTFILE ]="Unespected eof";
|
||||||
|
|
|
@ -150,20 +150,23 @@ static int Save(SaveMeshType &m, const char * filename , bool binary =true, int
|
||||||
}
|
}
|
||||||
fprintf(fp,"endsolid vcg\n");
|
fprintf(fp,"endsolid vcg\n");
|
||||||
}
|
}
|
||||||
|
int result = 0;
|
||||||
|
if (ferror(fp)) result = 2;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
static const char *ErrorMsg(int error)
|
static const char *ErrorMsg(int error)
|
||||||
{
|
{
|
||||||
static std::vector<std::string> stl_error_msg;
|
static std::vector<std::string> stl_error_msg;
|
||||||
if (stl_error_msg.empty())
|
if (stl_error_msg.empty())
|
||||||
{
|
{
|
||||||
stl_error_msg.resize(2 );
|
stl_error_msg.resize(3);
|
||||||
stl_error_msg[0] = "No errors";
|
stl_error_msg[0] = "No errors";
|
||||||
stl_error_msg[1] = "Can't open file";
|
stl_error_msg[1] = "Can't open file";
|
||||||
|
stl_error_msg[2] = "Output Stream error";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(error>1 || error<0) return "Unknown error";
|
if (error>2 || error<0) return "Unknown error";
|
||||||
else return stl_error_msg[error].c_str();
|
else return stl_error_msg[error].c_str();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -281,8 +281,10 @@ namespace vcg {
|
||||||
" ]\n"
|
" ]\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
|
int result = 0;
|
||||||
|
if (ferror(fp)) result = 2;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
///Returns mask of capability one define with what are the saveable information of the format.
|
///Returns mask of capability one define with what are the saveable information of the format.
|
||||||
static int GetExportMaskCapability()
|
static int GetExportMaskCapability()
|
||||||
|
@ -305,11 +307,12 @@ namespace vcg {
|
||||||
static std::vector<std::string> wrl_error_msg;
|
static std::vector<std::string> wrl_error_msg;
|
||||||
if(wrl_error_msg.empty())
|
if(wrl_error_msg.empty())
|
||||||
{
|
{
|
||||||
wrl_error_msg.resize(2 );
|
wrl_error_msg.resize(3);
|
||||||
wrl_error_msg[0] = "No errors";
|
wrl_error_msg[0] = "No errors";
|
||||||
wrl_error_msg[1] = "Can't open file";
|
wrl_error_msg[1] = "Can't open file";
|
||||||
|
wrl_error_msg[1] = "Output Stream error";
|
||||||
}
|
}
|
||||||
if(error>1 || error<0) return "Unknown error";
|
if(error>2 || error<0) return "Unknown error";
|
||||||
else return wrl_error_msg[error].c_str();
|
else return wrl_error_msg[error].c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,15 +152,15 @@ public:
|
||||||
enum Error
|
enum Error
|
||||||
{
|
{
|
||||||
// Funzioni superiori
|
// Funzioni superiori
|
||||||
E_NO_VERTEX = ply::E_MAXPLYERRORS+1, // 14
|
E_NO_VERTEX = ply::E_MAXPLYERRORS+1, // 15
|
||||||
E_NO_FACE = ply::E_MAXPLYERRORS+2, // 15
|
E_NO_FACE = ply::E_MAXPLYERRORS+2, // 16
|
||||||
E_SHORTFILE = ply::E_MAXPLYERRORS+3, // 16
|
E_SHORTFILE = ply::E_MAXPLYERRORS+3, // 17
|
||||||
E_NO_3VERTINFACE = ply::E_MAXPLYERRORS+4, // 17
|
E_NO_3VERTINFACE = ply::E_MAXPLYERRORS+4, // 18
|
||||||
E_BAD_VERT_INDEX = ply::E_MAXPLYERRORS+5, // 18
|
E_BAD_VERT_INDEX = ply::E_MAXPLYERRORS+5, // 19
|
||||||
E_NO_6TCOORD = ply::E_MAXPLYERRORS+6, // 19
|
E_NO_6TCOORD = ply::E_MAXPLYERRORS+6, // 20
|
||||||
E_DIFFER_COLORS = ply::E_MAXPLYERRORS+7,
|
E_DIFFER_COLORS = ply::E_MAXPLYERRORS+7, // 21
|
||||||
E_BAD_VERT_INDEX_EDGE = ply::E_MAXPLYERRORS+8, // 18
|
E_BAD_VERT_INDEX_EDGE = ply::E_MAXPLYERRORS+8, // 22
|
||||||
E_MAXPLYINFOERRORS= ply::E_MAXPLYERRORS+9// 20
|
E_MAXPLYINFOERRORS= ply::E_MAXPLYERRORS+9 // 23
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // end class
|
}; // end class
|
||||||
|
|
|
@ -91,6 +91,8 @@ enum PlyError {
|
||||||
E_BADTYPE, // 10
|
E_BADTYPE, // 10
|
||||||
E_INCOMPATIBLETYPE, // 11
|
E_INCOMPATIBLETYPE, // 11
|
||||||
E_BADCAST, // 12
|
E_BADCAST, // 12
|
||||||
|
//saving error
|
||||||
|
E_STREAMERROR, // 13
|
||||||
E_MAXPLYERRORS
|
E_MAXPLYERRORS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue