MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / checkSubdirectory

Method checkSubdirectory

ij/src/main/java/ij/Menus.java:1174–1210  ·  view source on GitHub ↗

Looks for plugins and jar files in a subdirectory of the plugins directory.

(String path, String dir, Vector v)

Source from the content-addressed store, hash-verified

1172
1173 /** Looks for plugins and jar files in a subdirectory of the plugins directory. */
1174 private static void checkSubdirectory(String path, String dir, Vector v) {
1175 if (dir.endsWith(".java"))
1176 return;
1177 File f = new File(path, dir);
1178 if (!f.isDirectory())
1179 return;
1180 String[] list = f.list();
1181 if (list==null)
1182 return;
1183 dir += "/";
1184 int classCount=0, otherCount=0;
1185 String className = null;
1186 for (int i=0; i<list.length; i++) {
1187 String name = list[i];
1188 boolean hasUnderscore = name.indexOf('_')>=0;
1189 if (hasUnderscore && name.endsWith(".class") && name.indexOf('$')<0) {
1190 name = name.substring(0, name.length()-6); // remove ".class"
1191 v.addElement(dir+name);
1192 classCount++;
1193 className = name;
1194 } else if (hasUnderscore && (name.endsWith(".jar") || name.endsWith(".zip"))) {
1195 if (jarFiles==null) jarFiles = new Vector();
1196 jarFiles.addElement(f.getPath() + File.separator + name);
1197 otherCount++;
1198 } else if (validMacroName(name,hasUnderscore)) {
1199 if (macroFiles==null) macroFiles = new Vector();
1200 macroFiles.addElement(dir + name);
1201 otherCount++;
1202 } else {
1203 File f2 = new File(f, name);
1204 if (f2.isDirectory()) installSubdirectorMacros(f2, dir+name);
1205 }
1206 }
1207 if (Prefs.moveToMisc && classCount==1 && otherCount==0 && dir.indexOf("_")==-1)
1208 v.setElementAt("Miscellaneous/" + className,
1209 v.size() - 1);
1210 }
1211
1212 /** Installs macros and scripts located in subdirectories. */
1213 private static void installSubdirectorMacros(File f2, String dir) {

Callers 1

getPluginsMethod · 0.95

Calls 9

validMacroNameMethod · 0.95
substringMethod · 0.80
lengthMethod · 0.65
listMethod · 0.45
indexOfMethod · 0.45
addElementMethod · 0.45
getPathMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected