Skip to content

Commit

Permalink
read_symlink: return string
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jun 26, 2024
1 parent 36bc897 commit fbd8994
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion +stdlib/+fileio/read_symlink.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#readSymbolicLink(java.nio.file.Path)
% must be absolute path
r = java.nio.file.Files.readSymbolicLink(java.io.File(r).toPath());
r = stdlib.fileio.posix(java.nio.file.Files.readSymbolicLink(java.io.File(r).toPath()));

else
[ok, t] = isSymbolicLink(p);
Expand Down
11 changes: 9 additions & 2 deletions test/TestSymlink.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,21 @@ function test_is_symlink(tc)

end


function test_read_symlink(tc)
import matlab.unittest.constraints.IsOfClass

tc.verifyEmpty(stdlib.read_symlink("not-exist"))
tc.verifyEmpty(stdlib.read_symlink(tc.TestData.this))
tc.verifyNotEmpty(stdlib.read_symlink(tc.TestData.link))

t = stdlib.read_symlink(tc.TestData.link);
tc.verifyNotEmpty(t)
tc.verifyThat(t, IsOfClass('string'))
tc.verifyTrue(stdlib.samepath(tc.TestData.this, t))

end


function test_create_symlink(tc)

tc.verifyFalse(stdlib.create_symlink(tc.TestData.this, tc.TestData.link))
Expand All @@ -61,4 +68,4 @@ function test_create_symlink(tc)

end

end
end

0 comments on commit fbd8994

Please sign in to comment.