Skip to content

Commit ccd2a4b

Browse files
committed
read_symlink: enable .net fallback
1 parent 982dc38 commit ccd2a4b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

+stdlib/read_symlink.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
p {mustBeTextScalar}
99
end
1010

11+
r = string.empty;
1112

1213
try
1314
[ok, r] = isSymbolicLink(p);
@@ -16,15 +17,16 @@
1617
switch e.identifier
1718
case "Octave:undefined-function", r = readlink(p);
1819
case "MATLAB:UndefinedFunction"
19-
if stdlib.is_symlink(p)
20+
if ~stdlib.is_symlink(p), return, end
21+
22+
if stdlib.has_dotnet() && stdlib.dotnet_api() >= 6
23+
r = System.IO.FileInfo(p).LinkTarget;
24+
elseif stdlib.has_java()
2025
% must be absolute path
2126
% must not be .canonical or symlink is gobbled!
2227
r = stdlib.absolute(p);
23-
2428
% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#readSymbolicLink(java.nio.file.Path)
2529
r = java.nio.file.Files.readSymbolicLink(javaPathObject(r)).string;
26-
else
27-
r = string.empty;
2830
end
2931
otherwise, rethrow(e)
3032
end

buildfile.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,11 @@ function build_exe(context)
258258
win = [pure, "src/windows.cpp"];
259259

260260
mac = "src/macos.cpp";
261-
linux = "src/linux_fs.cpp";
262261

263262
sym = "src/symlink_fs.cpp";
264263

265264

266265
srcs = {
267-
"src/is_absolute.cpp", ...
268266
"src/remove.cpp", ...
269267
["src/is_admin.cpp", "src/admin_fs.cpp"] ...
270268
"src/is_char_device.cpp", ...
@@ -273,14 +271,16 @@ function build_exe(context)
273271
"src/proximate_to.cpp", ...
274272
"src/disk_available.cpp", ...
275273
"src/disk_capacity.cpp", ...
276-
["src/is_wsl.cpp", linux], ...
277274
"src/set_permissions.cpp", ...
278275
["src/is_rosetta.cpp", mac], ...
279276
["src/drop_slash.cpp", normal], ...
280277
};
281278

282-
if isMATLABReleaseOlderThan("R2024b") || build_all
279+
if (isMATLABReleaseOlderThan("R2024b") && ~stdlib.has_dotnet()) || build_all
283280
srcs{end+1} = ["src/is_symlink.cpp", win, sym];
281+
end
282+
283+
if (isMATLABReleaseOlderThan("R2024b") && ~stdlib.has_dotnet() || stdlib.dotnet_api() < 6) || build_all
284284
srcs{end+1} = ["src/read_symlink.cpp", win, sym];
285285
end
286286

0 commit comments

Comments
 (0)