scanDirectory now scans all subfolders

This commit is contained in:
patrick-werner 2019-07-26 19:02:13 +02:00
parent 94feb31bef
commit 270a8bca71
1 changed files with 9 additions and 7 deletions

View File

@ -504,19 +504,21 @@ public class ValidationEngine {
}
private Map<String, byte[]> scanDirectory(File f) throws FileNotFoundException, IOException {
Map<String, byte[]> res = new HashMap<String, byte[]>();
Map<String, byte[]> res = new HashMap<>();
for (File ff : f.listFiles()) {
if (!isIgnoreFile(ff) && !ff.isDirectory()) {
FhirFormat fmt = checkIsResource(ff.getAbsolutePath());
if (fmt != null) {
res.put(Utilities.changeFileExt(ff.getName(), "."+fmt.getExtension()), TextFile.fileToBytes(ff.getAbsolutePath()));
if (ff.isDirectory()){
res.putAll(scanDirectory(ff));
}
else if (!isIgnoreFile(ff)) {
FhirFormat fmt = checkIsResource(ff.getAbsolutePath());
if (fmt != null) {
res.put(Utilities.changeFileExt(ff.getName(), "."+fmt.getExtension()), TextFile.fileToBytes(ff.getAbsolutePath()));
}
}
}
}
return res;
}
private boolean isIgnoreFile(File ff) {
return Utilities.existsInList(ff.getName(), ".DS_Store") || Utilities.existsInList(Utilities.getFileExtension(ff.getName()).toLowerCase(), "md", "css", "js", "png", "gif", "jpg", "html", "tgz", "pack", "zip");