Skip to content

Commit 3309f17

Browse files
committed
read_symlink streamline with try,catch'
1 parent ac6ddae commit 3309f17

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

+stdlib/read_symlink.m

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99

1010
r = "";
1111

12-
if stdlib.isoctave()
12+
try
13+
[ok, t] = isSymbolicLink(p);
14+
if ~ok, return, end
15+
catch e
16+
17+
if strcmp(e.identifier, "Octave:undefined-function")
1318
t = readlink(p);
14-
elseif isMATLABReleaseOlderThan("R2024b")
19+
elseif strcmp(e.identifier, 'MATLAB:UndefinedFunction')
1520
if ~stdlib.is_symlink(p)
1621
return
1722
end
@@ -22,9 +27,8 @@
2227

2328
% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#readSymbolicLink(java.nio.file.Path)
2429
t = java.nio.file.Files.readSymbolicLink(java.io.File(r).toPath());
25-
else
26-
[ok, t] = isSymbolicLink(p);
27-
if ~ok, return, end
30+
end
31+
2832
end
2933

3034
r = stdlib.posix(t);

0 commit comments

Comments
 (0)