Parcourir la source

fix bug when trying to write to non-writable files

Former-commit-id: 70f3c450cecd7ef7ce73ecf7e8486e065dcfdada
Alec Jacobson il y a 11 ans
Parent
commit
f736b0d480
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      include/igl/matlab/MatlabWorkspace.h

+ 5 - 0
include/igl/matlab/MatlabWorkspace.h

@@ -188,6 +188,11 @@ inline bool igl::MatlabWorkspace::write(const std::string & path) const
 {
   using namespace std;
   MATFile * mat_file = matOpen(path.c_str(), "w");
+  if(mat_file == NULL)
+  {
+    fprintf(stderr,"Error opening file %s\n",path.c_str());
+    return false;
+  }
   assert(names.size() == data.size());
   // loop over names and data
   for(int i = 0;i < (int)names.size(); i++)