avoid NPE if project directory does not exist; fixes #10

This commit is contained in:
John Lees-Miller
2015-04-26 21:00:28 -04:00
parent d697f75c77
commit 3ac0b0c2de
6 changed files with 124 additions and 5 deletions

View File

@@ -138,12 +138,15 @@ public class Util {
public static void deleteInDirectoryApartFrom(File directory, String... apartFrom) {
if (directory != null) {
Set<String> excluded = new HashSet<String>(Arrays.asList(apartFrom));
for (File file : directory.listFiles()) {
if (!excluded.contains(file.getName())) {
if (file.isDirectory()) {
deleteInDirectory(file);
File [] files = directory.listFiles();
if (files != null) {
for (File file : files) {
if (!excluded.contains(file.getName())) {
if (file.isDirectory()) {
deleteInDirectory(file);
}
file.delete();
}
file.delete();
}
}
}