Make list of package names by traversing a directory hierarchy. Each time a class is found in a folder, add its containing set of folders to the package list. If another folder is found, walk down into that folder and continue.
(File dir, String sofar,
StringList list)
| 585 | * walk down into that folder and continue. |
| 586 | */ |
| 587 | static private void packageListFromFolder(File dir, String sofar, |
| 588 | StringList list) { |
| 589 | // Map<String, Object> map) { |
| 590 | boolean foundClass = false; |
| 591 | String files[] = dir.list(); |
| 592 | |
| 593 | for (int i = 0; i < files.length; i++) { |
| 594 | if (files[i].equals(".") || files[i].equals("..")) continue; |
| 595 | |
| 596 | File sub = new File(dir, files[i]); |
| 597 | if (sub.isDirectory()) { |
| 598 | String nowfar = |
| 599 | (sofar == null) ? files[i] : (sofar + "." + files[i]); |
| 600 | packageListFromFolder(sub, nowfar, list); |
| 601 | //System.out.println(nowfar); |
| 602 | //imports[importCount++] = nowfar; |
| 603 | //importCount = magicImportsRecursive(sub, nowfar, |
| 604 | // imports, importCount); |
| 605 | } else if (!foundClass) { // if no classes found in this folder yet |
| 606 | if (files[i].endsWith(".class")) { |
| 607 | //System.out.println("unique class: " + files[i] + " for " + sofar); |
| 608 | // map.put(sofar, new Object()); |
| 609 | list.appendUnique(sofar); |
| 610 | foundClass = true; |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | |
| 617 | /** |
no test coverage detected