Make windows reserved filename detection more robust

This checks for more reserved filenames than just aux
This commit is contained in:
Ben Gruver 2013-09-14 11:35:53 -07:00
parent d868692e33
commit 6cd686fbf5

View File

@ -127,9 +127,12 @@ public class ClassFileNameHandler {
}
private static boolean testForWindowsReservedFileNames(File path) {
File f = new File(path, "aux.smali");
String[] reservedNames = new String[]{"aux", "con", "com1", "com9", "lpt1", "com9"};
for (String reservedName: reservedNames) {
File f = new File(path, reservedName + ".smali");
if (f.exists()) {
return false;
continue;
}
try {
@ -138,12 +141,13 @@ public class ClassFileNameHandler {
writer.flush();
writer.close();
f.delete(); //doesn't throw IOException
return false;
} catch (IOException ex) {
//if an exception occured, it's likely that we're on a windows system.
return true;
}
}
return false;
}
private static Pattern reservedFileNameRegex = Pattern.compile("^CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9]$",
Pattern.CASE_INSENSITIVE);