Skip to content

Commit 03e5651

Browse files
committed
read_symlink: return missing if not symlink
1 parent ca9b6d8 commit 03e5651

8 files changed

Lines changed: 12 additions & 15 deletions

File tree

+stdlib/+dotnet/read_symlink.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
% on Unix, this can be empty if the file is not a symlink
1010
catch e
1111
dotnetException(e)
12-
r = string.empty;
12+
r = missing;
1313
end
1414

1515
end

+stdlib/+java/read_symlink.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
r = string(javaMethod('readSymbolicLink', 'java.nio.file.Files', p));
1212
catch e
1313
javaException(e)
14-
r = string.empty;
14+
r = missing;
1515
end
1616

1717
end

+stdlib/+native/read_symlink.m

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
function r = read_symlink(file)
22

3-
if ~stdlib.matlabOlderThan('R2024b')
4-
[ok, r] = isSymbolicLink(file);
5-
if ~ok
6-
r = string.empty;
7-
end
3+
if stdlib.matlabOlderThan('R2024b')
4+
r = missing;
85
else
9-
r = string.empty;
6+
[~, r] = isSymbolicLink(file);
107
end
118

129
end

+stdlib/+python/read_symlink.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function r = read_symlink(file)
22

3-
r = string.empty;
3+
r = missing;
44

55
try
66
p = py.pathlib.Path(file);

+stdlib/+shell/read_symlink.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function [r, cmd] = read_symlink(file)
22

3-
r = string.empty;
3+
r = missing;
44

55
if isunix()
66
cmd = sprintf('readlink -fn "%s"', file);

+stdlib/read_symlink.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
backend (1,:) string = ["native", "java", "python", "dotnet", "shell"]
1717
end
1818

19-
r = string.empty;
19+
r = missing;
2020

2121
for b = backend
2222
switch b
@@ -36,7 +36,7 @@
3636
error('stdlib:read_symlink:ValueError', 'Unknown backend: %s', b)
3737
end
3838

39-
if ~isempty(r)
39+
if ~ismissing(r)
4040
return
4141
end
4242
end

+stdlib/toolbox_used.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
if ispc()
3232
old = getenv('KMP_DUPLICATE_LIB_OK');
33-
setenv('KMP_DUPLICATE_LIB_OK', 'TRUE');
33+
setenv('KMP_DUPLICATE_LIB_OK', 'TRUE')
3434

3535
% otherwise,
3636
% matlab -batch "buildtool test"

test/TestSymlink.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ function test_read_symlink_not_symlink(tc, Pre)
5555

5656
function test_read_symlink(tc, B_is_symlink)
5757
r = stdlib.read_symlink(tc.link, B_is_symlink);
58-
tc.verifyClass(r, 'string')
5958

6059
if ismember(B_is_symlink, stdlib.Backend().select('read_symlink'))
60+
tc.verifyClass(r, 'string')
6161
tc.verifyEqual(r, string(tc.target))
6262
else
63-
tc.verifyEmpty(r)
63+
tc.verifyTrue(ismissing(r))
6464
end
6565
end
6666

0 commit comments

Comments
 (0)