Hypatia/app/src/main/java/us/spotco/malwarescanner/Utils.java

33 lines
910 B
Java
Raw Normal View History

2017-12-16 06:15:17 -05:00
package us.spotco.malwarescanner;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
2017-12-16 15:02:10 -05:00
class Utils {
2017-12-16 06:15:17 -05:00
2017-12-16 15:02:10 -05:00
private final static int MAX_FILE_SIZE = (1000 * 1000) * 50; //50MB
2017-12-16 06:15:17 -05:00
public static Set<File> getFilesRecursive(File root) {
Set<File> filesAll = new HashSet<>();
File[] files = root.listFiles();
if (files != null && files.length > 0) {
for (File f : files) {
if (f.isDirectory()) {
Set<File> filesTmp = getFilesRecursive(f);
if (filesTmp != null) {
filesAll.addAll(filesTmp);
}
} else {
if (f.length() <= MAX_FILE_SIZE) {//Exclude files larger than 50MB for performance
filesAll.add(f);
}
}
}
}
return filesAll;
}
}