mirror of
https://github.com/revanced/Apktool.git
synced 2025-05-08 17:54:25 +02:00
Don't try to test for reserved file names
Instead, we'll just check os.name
This commit is contained in:
parent
b903c2066a
commit
8284715f4d
@ -68,7 +68,7 @@ public class ClassFileNameHandler {
|
|||||||
public ClassFileNameHandler(File path, String fileExtension) {
|
public ClassFileNameHandler(File path, String fileExtension) {
|
||||||
this.top = new DirectoryEntry(path);
|
this.top = new DirectoryEntry(path);
|
||||||
this.fileExtension = fileExtension;
|
this.fileExtension = fileExtension;
|
||||||
this.modifyWindowsReservedFilenames = testForWindowsReservedFileNames(path);
|
this.modifyWindowsReservedFilenames = isWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
// for testing
|
// for testing
|
||||||
@ -229,27 +229,8 @@ public class ClassFileNameHandler {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean testForWindowsReservedFileNames(File path) {
|
private static boolean isWindows() {
|
||||||
String[] reservedNames = new String[]{"aux", "con", "com1", "com9", "lpt1", "com9"};
|
return System.getProperty("os.name").startsWith("Windows");
|
||||||
|
|
||||||
for (String reservedName: reservedNames) {
|
|
||||||
File f = new File(path, reservedName + ".smali");
|
|
||||||
if (f.exists()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
FileWriter writer = new FileWriter(f);
|
|
||||||
writer.write("test");
|
|
||||||
writer.flush();
|
|
||||||
writer.close();
|
|
||||||
f.delete(); //doesn't throw IOException
|
|
||||||
} catch (IOException ex) {
|
|
||||||
//if an exception occurred, 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])(\\..*)?$",
|
private static Pattern reservedFileNameRegex = Pattern.compile("^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\\..*)?$",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user