Skip to content

Commit 9b22540

Browse files
committed
is_symlink: more fallback
1 parent 72bce56 commit 9b22540

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

+stdlib/disk_capacity.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% DISK_CAPACITY disk total capacity (bytes)
2-
% optional: mex
32
%
43
% example: stdlib.disk_capacity('/')
54

+stdlib/is_symlink.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%% IS_SYMLINK is path a symbolic link
2-
% optional: mex
32

43
function ok = is_symlink(p)
54
arguments
@@ -15,15 +14,17 @@
1514
if stdlib.dotnet_api() >= 6
1615
ok = ~isempty(System.IO.FileInfo(p).LinkTarget);
1716
else
18-
attr = string(System.IO.File.GetAttributes(p).ToString());
19-
% https://learn.microsoft.com/en-us/dotnet/api/system.io.fileattributes
20-
% ReparsePoint is for Linux, macOS, and Windows
21-
ok = contains(attr, 'ReparsePoint');
17+
attr = string(System.IO.File.GetAttributes(p).ToString());
18+
% https://learn.microsoft.com/en-us/dotnet/api/system.io.fileattributes
19+
% ReparsePoint is for Linux, macOS, and Windows
20+
ok = contains(attr, 'ReparsePoint');
2221
end
2322
elseif stdlib.has_java()
2423
ok = java.nio.file.Files.isSymbolicLink(javaPathObject(stdlib.absolute(p)));
24+
elseif stdlib.has_python()
25+
ok = py.pathlib.Path(p).is_symlink();
2526
else
26-
rethrow(e)
27+
ok = logical.empty;
2728
end
2829
case "Octave:undefined-function"
2930
% use lstat() to work with a broken symlink, like Matlab isSymbolicLink

buildfile.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ function build_exe(context)
273273
srcs{end+1} = "src/disk_capacity.cpp";
274274
end
275275

276-
if (isMATLABReleaseOlderThan("R2024b") && ~stdlib.has_dotnet()) || build_all
276+
if (isMATLABReleaseOlderThan("R2024b") && ~stdlib.has_dotnet() && ~stdlib.has_java() && ~stdlib.has_python()) || build_all
277277
srcs{end+1} = ["src/is_symlink.cpp", win, sym];
278278
end
279279

0 commit comments

Comments
 (0)