cache = getUserCache(path.getFileSystem());
+ String name = cache.get(this.userId);
+ if (name == null) {
+ name = getPrincipalName(path, "unix:owner");
+ cache.put(this.userId, name);
+ }
+ this.userName = name;
+ } else if (views.contains("owner")) {
+ this.userName = getPrincipalName(path, "owner:owner");
+ } else {
+ this.userName = null;
+ }
this.symbolicLink = (Boolean) attrs.get("isSymbolicLink");
this.regularFile = (Boolean) attrs.get("isRegularFile");
this.directory = (Boolean) attrs.get("isDirectory");
@@ -120,6 +160,11 @@ public FileAttributes(@Nonnull File file, boolean followLinks) throws IOExceptio
this.lastModifiedTime = (FileTime) attrs.get("lastModifiedTime");
}
+ private static String getPrincipalName(Path path, String attribute) throws IOException {
+ Object owner = Files.getAttribute(path, attribute, LinkOption.NOFOLLOW_LINKS);
+ return ((Principal) owner).getName();
+ }
+
public FileAttributes(
@Nullable Integer userId,
String userName,
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy