Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 64c43c2

Browse files
committed
add error if file name is too long
1 parent 27e2783 commit 64c43c2

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Compiler/SimCode/SimCodeMain.mo

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ algorithm
718718
local
719719
String str;
720720
String fmutmp;
721-
721+
Boolean b;
722722
case (SimCode.SIMCODE(),"C")
723723
algorithm
724724
fmutmp := simCode.fileNamePrefix + ".fmutmp";
@@ -731,7 +731,11 @@ algorithm
731731
Util.createDirectoryTree(fmutmp + "/sources/include/");
732732
SerializeModelInfo.serialize(simCode, Flags.isSet(Flags.INFO_XML_OPERATIONS));
733733
str := fmutmp + "/sources/" + simCode.fileNamePrefix;
734-
true := System.covertTextFileToCLiteral(simCode.fileNamePrefix+"_info.json", str+"_info.c", Flags.getConfigString(Flags.TARGET));
734+
b := System.covertTextFileToCLiteral(simCode.fileNamePrefix+"_info.json", str+"_info.c", Flags.getConfigString(Flags.TARGET));
735+
if not b then
736+
Error.addMessage(Error.INTERNAL_ERROR, {"System.covertTextFileToCLiteral failed. Could not write "+str+"_info.c\n"});
737+
fail();
738+
end if;
735739
Tpl.tplNoret3(CodegenFMU.translateModel, simCode, FMUVersion, FMUType);
736740
then ();
737741
case (_,"Cpp")

Compiler/runtime/systemimpl.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,8 +2899,16 @@ int SystemImpl__covertTextFileToCLiteral(const char *textFile, const char *outFi
28992899
if (!fin) {
29002900
goto done;
29012901
}
2902+
errno = 0;
29022903
fout = fopen(outFile, "w");
29032904
if (!fout) {
2905+
const char *c_token[1]={strerror(errno)};
2906+
c_add_message(NULL,85,
2907+
ErrorType_scripting,
2908+
ErrorLevel_error,
2909+
gettext("SystemImpl__covertTextFileToCLiteral failed: %s. Maybe the total file name is too long."),
2910+
c_token,
2911+
1);
29042912
goto done;
29052913
}
29062914

0 commit comments

Comments
 (0)