From 8284715f4d3c1d9d3d3932ae09ebd82a45ab27ba Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Sun, 1 Mar 2015 22:42:48 -0800 Subject: [PATCH] Don't try to test for reserved file names Instead, we'll just check os.name --- .../org/jf/util/ClassFileNameHandler.java | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/brut.apktool.smali/util/src/main/java/org/jf/util/ClassFileNameHandler.java b/brut.apktool.smali/util/src/main/java/org/jf/util/ClassFileNameHandler.java index 67037817..a223d30e 100644 --- a/brut.apktool.smali/util/src/main/java/org/jf/util/ClassFileNameHandler.java +++ b/brut.apktool.smali/util/src/main/java/org/jf/util/ClassFileNameHandler.java @@ -68,7 +68,7 @@ public class ClassFileNameHandler { public ClassFileNameHandler(File path, String fileExtension) { this.top = new DirectoryEntry(path); this.fileExtension = fileExtension; - this.modifyWindowsReservedFilenames = testForWindowsReservedFileNames(path); + this.modifyWindowsReservedFilenames = isWindows(); } // for testing @@ -229,27 +229,8 @@ public class ClassFileNameHandler { return sb.toString(); } - private static boolean testForWindowsReservedFileNames(File path) { - String[] reservedNames = new String[]{"aux", "con", "com1", "com9", "lpt1", "com9"}; - - 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 boolean isWindows() { + return System.getProperty("os.name").startsWith("Windows"); } private static Pattern reservedFileNameRegex = Pattern.compile("^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\\..*)?$",