Skip to content

Commit

Permalink
Improved error message in case not possible to create a file
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinOtter committed Jan 14, 2016
1 parent 690eb02 commit 322035e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions C-Sources/ModelicaIO.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,18 @@ MODELICA_EXPORT int ModelicaIO_writeRealMatrix(const char* fileName,
matc = MAT_COMPRESSION_NONE;
}

mat = append == 0 ?
Mat_CreateVer(fileName, NULL, matv) :
Mat_Open(fileName, (int)MAT_ACC_RDWR | matv);

if (mat == NULL) {
ModelicaFormatError("Not possible to open file \"%s\"\n", fileName);
return 0;
if ( append == 0 ) {
mat = Mat_CreateVer(fileName, NULL, matv);
if (mat == NULL) {
ModelicaFormatError("Not possible to newly create file \"%s\"\n(maybe version 7.3 not supported)\n", fileName);
return 0;
}
} else {
mat = Mat_Open(fileName, (int)MAT_ACC_RDWR | matv);
if (mat == NULL) {
ModelicaFormatError("Not possible to open file \"%s\"\n", fileName);
return 0;
}
}

/* MAT file array is stored column-wise -> need to transpose */
Expand Down

0 comments on commit 322035e

Please sign in to comment.