A classpath, separated by the path separator, will contain a series of .jar/.zip files or directories containing .class files, or containing subdirectories that have .class files. @param path the input classpath @return array of possible package names
(String path)
| 509 | * @return array of possible package names |
| 510 | */ |
| 511 | static public StringList packageListFromClassPath(String path) { |
| 512 | // Map<String, Object> map = new HashMap<String, Object>(); |
| 513 | StringList list = new StringList(); |
| 514 | String pieces[] = |
| 515 | PApplet.split(path, File.pathSeparatorChar); |
| 516 | |
| 517 | for (int i = 0; i < pieces.length; i++) { |
| 518 | //System.out.println("checking piece '" + pieces[i] + "'"); |
| 519 | if (pieces[i].length() == 0) continue; |
| 520 | |
| 521 | if (pieces[i].toLowerCase().endsWith(".jar") || |
| 522 | pieces[i].toLowerCase().endsWith(".zip")) { |
| 523 | //System.out.println("checking " + pieces[i]); |
| 524 | packageListFromZip(pieces[i], list); |
| 525 | |
| 526 | } else { // it's another type of file or directory |
| 527 | File dir = new File(pieces[i]); |
| 528 | if (dir.exists() && dir.isDirectory()) { |
| 529 | packageListFromFolder(dir, null, list); |
| 530 | //importCount = magicImportsRecursive(dir, null, |
| 531 | // map); |
| 532 | //imports, importCount); |
| 533 | } |
| 534 | } |
| 535 | } |
| 536 | // int mapCount = map.size(); |
| 537 | // String output[] = new String[mapCount]; |
| 538 | // int index = 0; |
| 539 | // Set<String> set = map.keySet(); |
| 540 | // for (String s : set) { |
| 541 | // output[index++] = s.replace('/', '.'); |
| 542 | // } |
| 543 | // return output; |
| 544 | StringList outgoing = new StringList(list.size()); |
| 545 | for (String item : list) { |
| 546 | outgoing.append(item.replace('/', '.')); |
| 547 | } |
| 548 | return outgoing; |
| 549 | } |
| 550 | |
| 551 | |
| 552 | static private void packageListFromZip(String filename, StringList list) { |
no test coverage detected