浏览代码

fix bug when trying to write to non-writable files

Former-commit-id: 70f3c450cecd7ef7ce73ecf7e8486e065dcfdada
Alec Jacobson 11 年之前
父节点
当前提交
f736b0d480
共有 1 个文件被更改,包括 5 次插入0 次删除
  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;
   using namespace std;
   MATFile * mat_file = matOpen(path.c_str(), "w");
   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());
   assert(names.size() == data.size());
   // loop over names and data
   // loop over names and data
   for(int i = 0;i < (int)names.size(); i++)
   for(int i = 0;i < (int)names.size(); i++)