Merge pull request #65 from hapifhir/iterate-subfolders

scanDirectory now scans all subfolders
This commit is contained in:
Grahame Grieve 2019-08-18 18:06:19 +10:00 committed by GitHub
commit 539eee9266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

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