mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8246592: Simplify checking of boolean file attributes
Reviewed-by: rriggs, alanb
This commit is contained in:
parent
1786701011
commit
9cd41b6555
4 changed files with 47 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue