Correctly handle duplicate (except case) reserved file names on windows
diff --git a/util/src/main/java/org/jf/util/ClassFileNameHandler.java b/util/src/main/java/org/jf/util/ClassFileNameHandler.java
index 7a748db..124cd02 100644
--- a/util/src/main/java/org/jf/util/ClassFileNameHandler.java
+++ b/util/src/main/java/org/jf/util/ClassFileNameHandler.java
@@ -58,7 +58,6 @@
throw new RuntimeException("Not a valid dalvik class name");
}
- String blah;
int packageElementCount = 1;
for (int i=1; i<className.length()-1; i++) {
if (className.charAt(i) == '/') {
@@ -66,6 +65,7 @@
}
}
+ String packageElement;
String[] packageElements = new String[packageElementCount];
int elementIndex = 0;
int elementStart = 1;
@@ -77,7 +77,13 @@
throw new RuntimeException("Not a valid dalvik class name");
}
- packageElements[elementIndex++] = className.substring(elementStart, i);
+ packageElement = className.substring(elementStart, i);
+
+ if (modifyWindowsReservedFilenames && isReservedFileName(packageElement)) {
+ packageElement += "#";
+ }
+
+ packageElements[elementIndex++] = packageElement;
elementStart = ++i;
}
}
@@ -89,7 +95,13 @@
if (elementStart >= className.length()-1) {
throw new RuntimeException("Not a valid dalvik class name");
}
- packageElements[elementIndex] = className.substring(elementStart, className.length()-1);
+
+ packageElement = className.substring(elementStart, className.length()-1);
+ if (modifyWindowsReservedFilenames && isReservedFileName(packageElement)) {
+ packageElement += "#";
+ }
+
+ packageElements[elementIndex] = packageElement;
return top.addUniqueChild(packageElements, 0);
}
@@ -170,15 +182,9 @@
if (pathElementsIndex == pathElements.length - 1) {
elementName = pathElements[pathElementsIndex];
- if (modifyWindowsReservedFilenames && isReservedFileName(elementName)) {
- elementName += "#";
- }
elementName += fileExtension;
} else {
elementName = pathElements[pathElementsIndex];
- if (modifyWindowsReservedFilenames && isReservedFileName(elementName)) {
- elementName += "#";
- }
}
elementNameLower = elementName.toLowerCase();