Clover coverage report - PMD - 3.7 Coverage timestamp: Wed May 31 2006 09:25:59 EDT FRAMES NO FRAMES |
file stats: | LOC: | 42 |  | Methods: | 2
| NCLOC: | 31 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
FileFinder.java | 0% | 0% | 0% | 0% |

1 |  | /**
2 |  | * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 |  | */
4 |  | package net.sourceforge.pmd.cpd;
5 |  |
6 |  | import java.io.File;
7 |  | import java.io.FilenameFilter;
8 |  | import java.util.ArrayList;
9 |  | import java.util.List;
10 |  |
11 |  | public class FileFinder {
12 |  |
13 |  | private FilenameFilter filter;
14 |  | private static final String FILE_SEP = System.getProperty("file.separator");
15 |  |
16 | 0 | public List findFilesFrom(String dir, FilenameFilter filter, boolean recurse) {
17 | 0 | this.filter = filter;
18 | 0 | List files = new ArrayList();
19 | 0 | scanDirectory(new File(dir), files, recurse);
20 | 0 | return files;
21 |  | }
22 |  |
23 |  | /**
24 |  | * Implements a tail recursive file scanner
25 |  | */
26 | 0 | private void scanDirectory(File dir, List list, boolean recurse) {
27 | 0 | String[] candidates = dir.list(filter);
28 | 0 | if (candidates == null) {
29 | 0 | return;
30 |  | }
31 | 0 | for (int i = 0; i < candidates.length; i++) {
32 | 0 | File tmp = new File(dir + FILE_SEP + candidates[i]);
33 | 0 | if (tmp.isDirectory()) {
34 | 0 | if (recurse) {
35 | 0 | scanDirectory(tmp, list, true);
36 |  | }
37 |  | } else {
38 | 0 | list.add(new File(dir + FILE_SEP + candidates[i]));
39 |  | }
40 |  | }
41 |  | }
42 |  | }