GET_OWNER owner of file or directory
requires: java
Contents
Inputs
- p: path to examine
Outputs
- n: owner, or empty if path does not exist
function n = get_owner(p) arguments p (1,1) string end % 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...) % https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/LinkOption.html n = ""; if ~stdlib.exists(p), return, end op = javaPathObject(p); opt = javaLinkOption(); if stdlib.isoctave() n = javaMethod("getOwner", "java.nio.file.Files", op, opt).toString(); else n = string(java.nio.file.Files.getOwner(op, opt)); end end %!assert(!isempty(get_owner(pwd))) %!assert(isempty(get_owner(tempname)))