diff --git a/+stdlib/+fileio/read_symlink.m b/+stdlib/+fileio/read_symlink.m index 6fd9b19..8a33aae 100644 --- a/+stdlib/+fileio/read_symlink.m +++ b/+stdlib/+fileio/read_symlink.m @@ -4,17 +4,23 @@ p (1,1) string end -import java.io.File -import java.nio.file.Files - r = string.empty; -if ~stdlib.fileio.is_symlink(p) || ~stdlib.fileio.exists(p), return, end +if isMATLABReleaseOlderThan("R2024b") + +if ~stdlib.fileio.is_symlink(p) || ~stdlib.fileio.exists(p) + return +end r = stdlib.fileio.absolute_path(p); % https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#readSymbolicLink(java.nio.file.Path) % must be absolute path -r = Files.readSymbolicLink(File(r).toPath()); +r = java.nio.file.Files.readSymbolicLink(java.io.File(r).toPath()); +else + [ok, t] = isSymbolicLink(p); + if ok + r = t; + end end