protected Attributes(File file) { super(file); this.readOnly = (boolean) file.getAttribute("dos", "readonly"); this.hidden = (boolean) file.getAttribute("dos", "hidden"); this.archive = (boolean) file.getAttribute("dos", "archive"); this.system = (boolean) file.getAttribute("dos", "system"); }
@SuppressWarnings("unchecked") protected Attributes(File file) { super(file); this.owner = (UserPrincipal) file.getAttribute("owner", "owner"); this.group = (GroupPrincipal) file.getAttribute("posix", "group"); this.permissions = (ImmutableSet<PosixFilePermission>) file.getAttribute("posix", "permissions"); }
@Nullable @Override public Object get(File file, String attribute) { switch (attribute) { case "group": return file.getAttribute("posix", "group"); case "permissions": return file.getAttribute("posix", "permissions"); default: return null; } }
@Nullable @Override public Object get(File file, String attribute) { if (ATTRIBUTES.contains(attribute)) { return file.getAttribute("dos", attribute); } return null; }
@Nullable @Override public Object get(File file, String attribute) { if (attribute.equals("owner")) { return file.getAttribute("owner", "owner"); } return null; }
@Nullable @Override public Object get(File file, String attribute) { if (attribute.equals("acl")) { return file.getAttribute("acl", "acl"); } return null; }
@Override public Object get(File file, String attribute) { Object value = file.getAttribute("user", attribute); if (value instanceof byte[]) { byte[] bytes = (byte[]) value; return bytes.clone(); } return null; }
@SuppressWarnings("unchecked") @Override public List<AclEntry> getAcl() throws IOException { return (List<AclEntry>) lookupFile().getAttribute("acl", "acl"); }
@Override public UserPrincipal getOwner() throws IOException { return (UserPrincipal) lookupFile().getAttribute("owner", "owner"); }
private byte[] getStoredBytes(String name) throws IOException { byte[] bytes = (byte[]) lookupFile().getAttribute(name(), name); if (bytes == null) { throw new IllegalArgumentException("attribute '" + name() + ":" + name + "' is not set"); } return bytes; }
@SuppressWarnings("unchecked") @Override public Object get(File file, String attribute) { switch (attribute) { case "uid": UserPrincipal user = (UserPrincipal) file.getAttribute("owner", "owner"); return getUniqueId(user); case "gid": GroupPrincipal group = (GroupPrincipal) file.getAttribute("posix", "group"); return getUniqueId(group); case "mode": Set<PosixFilePermission> permissions = (Set<PosixFilePermission>) file.getAttribute("posix", "permissions"); return toMode(permissions); case "ctime": return FileTime.fromMillis(file.getCreationTime()); case "rdev": return 0L; case "dev": return 1L; case "ino": return file.id(); case "nlink": return file.links(); default: return null; } }
@SuppressWarnings("unchecked") protected Attributes(File file) { super(file); this.owner = (UserPrincipal) file.getAttribute("owner", "owner"); this.group = (GroupPrincipal) file.getAttribute("posix", "group"); this.permissions = (ImmutableSet<PosixFilePermission>) file.getAttribute("posix", "permissions"); }
protected Attributes(File file) { super(file); this.readOnly = (boolean) file.getAttribute("dos", "readonly"); this.hidden = (boolean) file.getAttribute("dos", "hidden"); this.archive = (boolean) file.getAttribute("dos", "archive"); this.system = (boolean) file.getAttribute("dos", "system"); }
@Nullable @Override public Object get(File file, String attribute) { switch (attribute) { case "group": return file.getAttribute("posix", "group"); case "permissions": return file.getAttribute("posix", "permissions"); default: return null; } }
@Nullable @Override public Object get(File file, String attribute) { if (ATTRIBUTES.contains(attribute)) { return file.getAttribute("dos", attribute); } return null; }
@Nullable @Override public Object get(File file, String attribute) { if (attribute.equals("acl")) { return file.getAttribute("acl", "acl"); } return null; }
@Nullable @Override public Object get(File file, String attribute) { if (attribute.equals("owner")) { return file.getAttribute("owner", "owner"); } return null; }
@Override public Object get(File file, String attribute) { Object value = file.getAttribute("user", attribute); if (value instanceof byte[]) { byte[] bytes = (byte[]) value; return bytes.clone(); } return null; }
@SuppressWarnings("unchecked") @Override public List<AclEntry> getAcl() throws IOException { return (List<AclEntry>) lookupFile().getAttribute("acl", "acl"); }
private byte[] getStoredBytes(String name) throws IOException { byte[] bytes = (byte[]) lookupFile().getAttribute(name(), name); if (bytes == null) { throw new IllegalArgumentException("attribute '" + name() + ":" + name + "' is not set"); } return bytes; }