8246592: Simplify checking of boolean file attributes

Reviewed-by: rriggs, alanb
This commit is contained in:
Claes Redestad 2020-06-08 22:47:16 +02:00
parent 1786701011
commit 9cd41b6555
4 changed files with 47 additions and 9 deletions

View file

@ -260,9 +260,20 @@ class UnixFileSystem extends FileSystem {
@Override
public int getBooleanAttributes(File f) {
int rv = getBooleanAttributes0(f);
String name = f.getName();
boolean hidden = !name.isEmpty() && name.charAt(0) == '.';
return rv | (hidden ? BA_HIDDEN : 0);
return rv | isHidden(f);
}
@Override
public boolean hasBooleanAttributes(File f, int attributes) {
int rv = getBooleanAttributes0(f);
if ((attributes & BA_HIDDEN) != 0) {
rv |= isHidden(f);
}
return (rv & attributes) == attributes;
}
private static int isHidden(File f) {
return f.getName().startsWith(".") ? BA_HIDDEN : 0;
}
@Override