Skip to content

Commit 476583c

Browse files
committed
streamline
1 parent b36e7f5 commit 476583c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

+stdlib/create_symlink.m

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
link {mustBeTextScalar}
1313
end
1414

15+
ok = false;
1516

1617
try
1718
createSymbolicLink(link, target);
@@ -26,22 +27,27 @@
2627
% see example/Filesystem.java for this working in plain Java.
2728
% see example/javaCreateSymbolicLink.m for a non-working attempt in Matlab.
2829
if stdlib.has_python()
29-
py.pathlib.Path(link).symlink_to(target);
30-
ok = true;
30+
try
31+
py.pathlib.Path(link).symlink_to(target);
32+
ok = true;
33+
catch e
34+
warning(e.identifier, "%s", e.message)
35+
end
3136
elseif stdlib.dotnet_api() >= 6
3237
% https://learn.microsoft.com/en-us/dotnet/api/system.io.file.createsymboliclink
33-
System.IO.File.CreateSymbolicLink(link, target);
34-
ok = true;
38+
try
39+
System.IO.File.CreateSymbolicLink(link, target);
40+
ok = true;
41+
catch e
42+
warning(e.identifier, "%s", e.message)
43+
end
3544
else
3645
warning(e.identifier, "%s", e.message)
37-
ok = false;
3846
end
3947
case "Octave:undefined-function"
4048
err = symlink(target, link);
4149
ok = err == 0;
42-
otherwise
43-
warning(e.identifier, "%s", e.message)
44-
ok = false;
50+
otherwise, warning(e.identifier, "%s", e.message)
4551
end
4652
end
4753

0 commit comments

Comments
 (0)