Skip to content

Commit 3b68402

Browse files
committed
add hard_link_count()
1 parent a87d5d2 commit 3b68402

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

+stdlib/get_owner.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/Files.html#getOwner(java.nio.file.Path,java.nio.file.LinkOption...)
77
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/LinkOption.html
88

9-
owner = string(java.nio.file.Files.getOwner(java.io.File(path).toPath(), java.nio.file.LinkOption.values));
9+
opt = java.nio.file.LinkOption.values;
1010

11-
end
11+
owner = string(java.nio.file.Files.getOwner(java.io.File(path).toPath(), opt));
12+
13+
end

+stdlib/hard_link_count.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function c = hard_link_count(filepath)
2+
% HARD_LINK_COUNT get the number of hard links to a file
3+
% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#getPosixFileAttributes(java.nio.file.Path,java.nio.file.LinkOption...)
4+
% https://docs.oracle.com/javase/tutorial/essential/io/links.html
5+
arguments
6+
filepath (1,1) string {mustBeFile}
7+
end
8+
9+
if ispc
10+
c = [];
11+
return
12+
end
13+
14+
opt = java.nio.file.LinkOption.values;
15+
16+
c = java.nio.file.Files.getAttribute(java.io.File(filepath).toPath(), "unix:nlink", opt);
17+
%Files.getAttribute(filePath, "unix:nlink")
18+
19+
end

0 commit comments

Comments
 (0)