Skip to content

Commit ce40b4d

Browse files
committed
Handle relative file:// and local files, always returning an absolute path
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15970 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 894a0e0 commit ce40b4d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Compiler/FrontEnd/ModelicaBuiltin.mo

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,12 +1913,11 @@ algorithm
19131913
end while;
19141914
filename := if isMatch then filename + matches[3] else filename;
19151915
elseif isFileUriAbsolute then
1916-
(,matches) := regex(uri,"file://(/.*)?",2);
1916+
(,matches) := regex(uri,"file://(/.*)?",2,caseInsensitive=true);
19171917
filename := matches[2];
19181918
elseif isFileUri and not isFileUriAbsolute then
1919-
str := "file:// schema without absolute paths are not supported: " + uri;
1920-
print(str + "\n");
1921-
filename := "";
1919+
(,matches) := regex(uri,"file://(.*)",2,caseInsensitive=true);
1920+
filename := realpath("./") + "/" + matches[2];
19221921
return;
19231922
elseif not (isModelicaUri or isFileUri) then
19241923
/* Not using else because OpenModelica handling of assertions at runtime is not very good */
@@ -1930,7 +1929,7 @@ algorithm
19301929
/* empty */
19311930
end if;
19321931
else
1933-
filename := uri;
1932+
filename := if regularFileExists(uri) then realpath(uri) else if regexBool(uri, "^/") then uri else (realpath("./") + "/" + uri);
19341933
end if;
19351934
annotation(Documentation(info="<html>
19361935
Handles modelica:// and file:// URI's. The result is an absolute path on the local system.

0 commit comments

Comments
 (0)