|
|||||||||||||||||||
| This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| FileUtil.java | 60% | 58,8% | 33,3% | 56,7% |
|
||||||||||||||
| 1 |
/* |
|
| 2 |
* JBind |
|
| 3 |
* |
|
| 4 |
* Copyright (c) by Stefan Wachter. All rights reserved. |
|
| 5 |
* |
|
| 6 |
* Usage, modification, and redistribution is subject to license terms that are |
|
| 7 |
* available at 'http://www.jbind.org'. The JBind license is like the |
|
| 8 |
* 'Apache Software License V 1.1'. |
|
| 9 |
*/ |
|
| 10 |
package org.jbind.util.other; |
|
| 11 |
|
|
| 12 |
import java.io.File; |
|
| 13 |
import java.util.Collections; |
|
| 14 |
import java.util.HashSet; |
|
| 15 |
import java.util.Set; |
|
| 16 |
|
|
| 17 |
public class FileUtil {
|
|
| 18 |
|
|
| 19 |
/** |
|
| 20 |
* Recursively deletes this file and if it is a directory all it contained |
|
| 21 |
* directories. |
|
| 22 |
*/ |
|
| 23 | 0 |
public static boolean delete(File aFile) {
|
| 24 | 0 |
boolean deleted = true; |
| 25 | 0 |
File[] files = aFile.listFiles(); |
| 26 | 0 |
if (null != files) {
|
| 27 | 0 |
for (int i = 0; i < files.length; i++) {
|
| 28 | 0 |
deleted &= delete(files[i]); |
| 29 |
} |
|
| 30 |
} |
|
| 31 | 0 |
deleted &= aFile.delete(); |
| 32 | 0 |
return deleted; |
| 33 |
} |
|
| 34 |
|
|
| 35 | 559 |
public static Set collectJavaFiles(File aFile) {
|
| 36 | 559 |
Set res = null; |
| 37 | 559 |
if (aFile.isDirectory()) {
|
| 38 | 62 |
res = new HashSet(); |
| 39 | 62 |
File[] files = aFile.listFiles(); |
| 40 | 62 |
for (int i = 0; i < files.length; i++) {
|
| 41 | 535 |
res.addAll(collectJavaFiles(files[i])); |
| 42 |
} |
|
| 43 | 497 |
} else if (aFile.exists() && aFile.toString().endsWith(".java")) {
|
| 44 | 397 |
res = Collections.singleton(aFile); |
| 45 |
} else {
|
|
| 46 | 100 |
res = Collections.EMPTY_SET; |
| 47 |
} |
|
| 48 | 559 |
return res; |
| 49 |
} |
|
| 50 |
|
|
| 51 | 0 |
private FileUtil() {}
|
| 52 |
|
|
| 53 |
} |
|
| 54 |
|
|
||||||||||