fix(gui): allow file and directory have same name in tree (#2420)
This commit is contained in:
@@ -348,11 +348,12 @@ public class JResource extends JLoadableNode {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return name.equals(((JResource) o).name);
|
||||
JResource other = (JResource) o;
|
||||
return name.equals(other.name) && type.equals(other.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
return name.hashCode() + 31 * type.ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,19 +64,17 @@ public class JRoot extends JNode {
|
||||
String[] parts = new File(rfName).getPath().split(splitPathStr);
|
||||
JResource curRf = root;
|
||||
int count = parts.length;
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
String name = parts[i];
|
||||
JResource subRF = getResourceByName(curRf, name);
|
||||
if (subRF == null) {
|
||||
if (i != count - 1) {
|
||||
subRF = new JResource(null, name, JResType.DIR);
|
||||
} else {
|
||||
subRF = new JResource(rf, rf.getDeobfName(), name, JResType.FILE);
|
||||
}
|
||||
subRF = new JResource(null, name, JResType.DIR);
|
||||
curRf.addSubNode(subRF);
|
||||
}
|
||||
curRf = subRF;
|
||||
}
|
||||
JResource leaf = new JResource(rf, rf.getDeobfName(), parts[count - 1], JResType.FILE);
|
||||
curRf.addSubNode(leaf);
|
||||
}
|
||||
root.sortSubNodes();
|
||||
root.update();
|
||||
|
||||
Reference in New Issue
Block a user