8261183: Follow on to Make lists of normal filenames

Reviewed-by: alanb, rriggs, rhalade
This commit is contained in:
Brian Burkhalter 2021-02-16 22:21:39 +00:00 committed by Henry Jen
parent 40ef00cebf
commit 2fcd920adc

View File

@ -1134,14 +1134,7 @@ public class File
* the directory * the directory
*/ */
public String[] list() { public String[] list() {
SecurityManager security = System.getSecurityManager(); return normalizedList();
if (security != null) {
security.checkRead(path);
}
if (isInvalid()) {
return null;
}
return fs.list(this);
} }
/** /**
@ -1161,8 +1154,15 @@ public class File
* the directory * the directory
*/ */
private final String[] normalizedList() { private final String[] normalizedList() {
String[] s = list(); SecurityManager security = System.getSecurityManager();
if (getClass() != File.class) { if (security != null) {
security.checkRead(path);
}
if (isInvalid()) {
return null;
}
String[] s = fs.list(this);
if (s != null && getClass() != File.class) {
String[] normalized = new String[s.length]; String[] normalized = new String[s.length];
for (int i = 0; i < s.length; i++) { for (int i = 0; i < s.length; i++) {
normalized[i] = fs.normalize(s[i]); normalized[i] = fs.normalize(s[i]);