diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 06604bc8e..53ee07388 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -75,6 +75,10 @@ void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* p // invoke the exporter ColladaExporter iDoTheExportThing( pScene, pIOSystem, path, file); + + if (iDoTheExportThing.mOutput.fail()) { + throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile)); + } // we're still here - export successfully completed. Write result to the given IOSYstem std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); @@ -104,7 +108,7 @@ ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, co // set up strings endstr = "\n"; - // start writing + // start writing the file WriteFile(); } diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index cc9d2f31c..692eac0e6 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -62,6 +62,10 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // invoke the exporter ObjExporter exporter(pFile, pScene); + if (exporter.mOutput.fail() || exporter.mOutputMat.fail()) { + throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile)); + } + // we're still here - export successfully completed. Write both the main OBJ file and the material script { std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); diff --git a/code/PlyExporter.cpp b/code/PlyExporter.cpp index 2844cbd39..eb0867046 100644 --- a/code/PlyExporter.cpp +++ b/code/PlyExporter.cpp @@ -70,6 +70,10 @@ void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // invoke the exporter PlyExporter exporter(pFile, pScene); + if (exporter.mOutput.fail()) { + throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile)); + } + // we're still here - export successfully completed. Write the file. std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); if(outfile == NULL) { diff --git a/code/STLExporter.cpp b/code/STLExporter.cpp index 629296724..f94debfc9 100644 --- a/code/STLExporter.cpp +++ b/code/STLExporter.cpp @@ -62,6 +62,10 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // invoke the exporter STLExporter exporter(pFile, pScene); + if (exporter.mOutput.fail()) { + throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile)); + } + // we're still here - export successfully completed. Write the file. std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); if(outfile == NULL) { @@ -75,6 +79,10 @@ void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* // invoke the exporter STLExporter exporter(pFile, pScene, true); + if (exporter.mOutput.fail()) { + throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile)); + } + // we're still here - export successfully completed. Write the file. std::unique_ptr outfile (pIOSystem->Open(pFile,"wb")); if(outfile == NULL) { diff --git a/code/XFileExporter.cpp b/code/XFileExporter.cpp index 7de494daf..6407bf738 100644 --- a/code/XFileExporter.cpp +++ b/code/XFileExporter.cpp @@ -80,6 +80,10 @@ void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pSce // invoke the exporter XFileExporter iDoTheExportThing( pScene, pIOSystem, path, file, &props); + if (iDoTheExportThing.mOutput.fail()) { + throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile)); + } + // we're still here - export successfully completed. Write result to the given IOSYstem std::unique_ptr outfile (pIOSystem->Open(pFile,"wt")); if(outfile == NULL) {