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)
| 582 | * @return array of possible package names |
| 583 | */ |
| 584 | static public StringList packageListFromClassPath(String path) { |
| 585 | // Map<String, Object> map = new HashMap<String, Object>(); |
| 586 | StringList list = new StringList(); |
| 587 | String[] pieces = |
| 588 | PApplet.split(path, File.pathSeparatorChar); |
| 589 | |
| 590 | for (String piece : pieces) { |
| 591 | //System.out.println("checking piece '" + pieces[i] + "'"); |
| 592 | if (piece.length() != 0) { |
| 593 | if (piece.toLowerCase().endsWith(".jar") || |
| 594 | piece.toLowerCase().endsWith(".zip")) { |
| 595 | //System.out.println("checking " + pieces[i]); |
| 596 | packageListFromZip(piece, list); |
| 597 | |
| 598 | } else { // it's another type of file or directory |
| 599 | File dir = new File(piece); |
| 600 | if (dir.exists() && dir.isDirectory()) { |
| 601 | packageListFromFolder(dir, null, list); |
| 602 | //importCount = magicImportsRecursive(dir, null, |
| 603 | // map); |
| 604 | //imports, importCount); |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | } |
| 609 | // int mapCount = map.size(); |
| 610 | // String output[] = new String[mapCount]; |
| 611 | // int index = 0; |
| 612 | // Set<String> set = map.keySet(); |
| 613 | // for (String s : set) { |
| 614 | // output[index++] = s.replace('/', '.'); |
| 615 | // } |
| 616 | // return output; |
| 617 | StringList outgoing = new StringList(list.size()); |
| 618 | for (String item : list) { |
| 619 | outgoing.append(item.replace('/', '.')); |
| 620 | } |
| 621 | return outgoing; |
| 622 | } |
| 623 | |
| 624 | |
| 625 | static private void packageListFromZip(String filename, StringList list) { |
no test coverage detected