Browse Source

Fixes to NPE errors when searching directories recursively

master
Drew Short 11 years ago
parent
commit
2850c3bf86
  1. 4
      src/main/scala/com/sothr/imagetools/Engine.scala

4
src/main/scala/com/sothr/imagetools/Engine.scala

@ -16,10 +16,12 @@ abstract class Engine extends Logging{
def getAllImageFiles(directoryPath:String, recursive:Boolean=false, recursiveDepth:Int=500):List[File] = {
val fileList = new mutable.MutableList[File]()
if (directoryPath != null && directoryPath != "") {
val directory:File = new File(directoryPath)
val imageFilter = new ImageFilter
if (directory.isDirectory) {
val files = directory.listFiles(imageFilter)
if (files != null) {
fileList ++= files
info(s"Found ${files.length} files that are images in directory: $directoryPath")
if (recursive) {
@ -30,6 +32,8 @@ abstract class Engine extends Logging{
}
}
}
}
}
fileList.toList
}

Loading…
Cancel
Save