File tree Expand file tree Collapse file tree 3 files changed +20
-8
lines changed
Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -1395,6 +1395,8 @@ algorithm
13951395
13961396 case _
13971397 equation
1398+ // this is because System.dirname(".openmodelica") != ".openmodelica"
1399+ // System.dirname(".openmodelica") = "." on Windows!
13981400 true = stringEqual(parentDir, System . dirname(parentDir));
13991401 b = System . createDirectory(inString);
14001402 then b;
@@ -1421,9 +1423,14 @@ protected
14211423 String parentDir;
14221424 Boolean parentDirExists;
14231425algorithm
1424- parentDir := System . dirname(inString);
1425- parentDirExists := System . directoryExists(parentDir);
1426- outBool := createDirectoryTreeH(inString,parentDir,parentDirExists);
1426+ // if is already there, just retrun true!
1427+ if System . directoryExists(inString) then
1428+ outBool := true ;
1429+ else
1430+ parentDir := System . dirname(inString);
1431+ parentDirExists := System . directoryExists(parentDir);
1432+ outBool := createDirectoryTreeH(inString,parentDir,parentDirExists);
1433+ end if ;
14271434end createDirectoryTree;
14281435
14291436public function nextPowerOf2
Original file line number Diff line number Diff line change @@ -945,7 +945,10 @@ extern int SystemImpl__createDirectory(const char *str)
945945#endif
946946 if (rv == -1 )
947947 {
948- return 0 ;
948+ if (errno == EEXIST ) // directory exists, return success!
949+ return 1 ;
950+ else
951+ return 0 ;
949952 }
950953 else
951954 {
Original file line number Diff line number Diff line change @@ -7,10 +7,12 @@ setModelicaPath(OpenModelica.Scripting.cd() + "/.openmodelica/libraries/");
77getModelicaPath();
88echo(false);
99OpenModelica.Scripting.mkdir(".openmodelica");
10- if not OpenModelica.Scripting.mkdir(".openmodelica/libraries/") then
11- print("\nmkdir failed\n");
12- print(getErrorString());
13- exit(1);
10+ if not OpenModelica.Scripting.directoryExists(".openmodelica/libraries/") then
11+ if not OpenModelica.Scripting.mkdir(".openmodelica/libraries/") then
12+ print("\nmkdir failed\n");
13+ print(getErrorString());
14+ exit(1);
15+ end if;
1416end if;
1517vers:=OpenModelica.Scripting.getAvailablePackageVersions(Modelica, "3.2.3");
1618if size(vers,1) <> 1 then
You can’t perform that action at this time.
0 commit comments