12 public void run(String arg) {
16 void deleteDuplicates() {
17 String[] paths = getClassFiles();
21 for (
int i=0; i<paths.length; i++) {
22 name = getName(paths[i]);
23 if (name.endsWith(
"classx"))
25 for (
int j=i+1; j<paths.length; j++) {
26 if (paths[j].endsWith(name)) {
27 file1 =
new File(paths[i]);
28 file2 =
new File(paths[j]);
29 if (file1==null || file2==null)
31 date1 = file1.lastModified();
32 date2 = file2.lastModified();
37 }
else if (date2<date1) {
42 if (paths[i].endsWith(
"plugins"+name)) {
46 }
else if (paths[j].endsWith(
"plugins"+name)) {
57 void write(String path) {
58 IJ.log(
"Deleting duplicate class: "+path);
61 public String getName(String path) {
62 int index = path.lastIndexOf(separatorChar);
63 return (index < 0) ? path : path.substring(index);
68 String[] getClassFiles() {
69 String path = Menus.getPlugInsPath();
72 File f =
new File(path);
73 String[] list = f.list();
74 if (list==null)
return null;
75 Vector v =
new Vector();
76 for (
int i=0; i<list.length; i++) {
77 String name = list[i];
78 boolean isClassFile = name.endsWith(
".class");
81 v.addElement(path+name);
84 getSubdirectoryClassFiles(path, name, v);
87 list =
new String[v.size()];
88 v.copyInto((String[])list);
93 void getSubdirectoryClassFiles(String path, String dir, Vector v) {
95 if (dir.endsWith(
".java"))
97 File f =
new File(path, dir);
100 String[] list = f.list();
103 dir +=
Prefs.separator;
104 for (
int i=0; i<list.length; i++) {
105 String name = list[i];
106 if (name.endsWith(
".class")) {
108 v.addElement(path+dir+name);