Skip to content

Commit

Permalink
symlink: use new readSymlink if available
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jun 26, 2024
1 parent e663bcd commit 36bc897
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions +stdlib/+fileio/read_symlink.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 36bc897

Please sign in to comment.