diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 763480650..19f86fcf8 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -58,6 +58,9 @@ void ExportSceneCollada(const char* pFile,IOSystem* pIOSystem, const aiScene* pS // we're still here - export successfully completed. Write result to the given IOSYstem boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .dae file: " + std::string(pFile)); + } // XXX maybe use a small wrapper around IOStream that behaves like std::stringstream in order to avoid the extra copy. outfile->Write( iDoTheExportThing.mOutput.str().c_str(), static_cast(iDoTheExportThing.mOutput.tellp()),1); diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index 4bd65a338..9ac902ee3 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -59,10 +59,16 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write both the main OBJ file and the material script { boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .obj file: " + std::string(pFile)); + } outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } { boost::scoped_ptr outfile (pIOSystem->Open(exporter.GetMaterialLibFileName(),"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .mtl file: " + std::string(exporter.GetMaterialLibFileName())); + } outfile->Write( exporter.mOutputMat.str().c_str(), static_cast(exporter.mOutputMat.tellp()),1); } } diff --git a/code/PlyExporter.cpp b/code/PlyExporter.cpp index df06175d2..257e6f1f7 100644 --- a/code/PlyExporter.cpp +++ b/code/PlyExporter.cpp @@ -57,6 +57,10 @@ void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write the file. boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .ply file: " + std::string(pFile)); + } + outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } diff --git a/code/STLExporter.cpp b/code/STLExporter.cpp index b71cea66e..521f28ae3 100644 --- a/code/STLExporter.cpp +++ b/code/STLExporter.cpp @@ -57,6 +57,10 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene // we're still here - export successfully completed. Write the file. boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .stl file: " + std::string(pFile)); + } + outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); }