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