Skip to content

Commit

Permalink
change semantics of mkdir() command to match Unix "mkdir -p" (create …
Browse files Browse the repository at this point in the history
…subdirs if required)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17183 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Henning Kiel committed Sep 11, 2013
1 parent f88ec56 commit d619c21
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Compiler/Script/CevalScript.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ algorithm

case (cache,env,"mkdir",{Values.STRING(str)},st,_)
equation
b = System.createDirectory(str);
b = Util.createDirectoryTree(str);
then
(cache,Values.BOOL(b),st);

Expand Down
43 changes: 43 additions & 0 deletions Compiler/Util/Util.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3856,4 +3856,47 @@ algorithm
end match;
end testsuiteFriendly2;

protected function createDirectoryTreeH
input String inString;
input String parentDir;
input Boolean parentDirExists;
output Boolean outBool;
algorithm
outBool := matchcontinue(inString,parentDir,parentDirExists)
local
Boolean b;

case (_, _, _)
equation
true = stringEqual(parentDir, System.dirname(parentDir));
b = System.createDirectory(inString);
then b;

case (_, _, true)
equation
b = System.createDirectory(inString);
then b;

case (_, _, false)
equation
true = createDirectoryTree(parentDir);
b = System.createDirectory(inString);
then b;

else false;
end matchcontinue;
end createDirectoryTreeH;

public function createDirectoryTree
input String inString;
output Boolean outBool;
protected
String parentDir;
Boolean parentDirExists;
algorithm
parentDir := System.dirname(inString);
parentDirExists := System.directoryExists(parentDir);
outBool := createDirectoryTreeH(inString,parentDir,parentDirExists);
end createDirectoryTree;

end Util;

0 comments on commit d619c21

Please sign in to comment.