Created
March 20, 2019 16:14
-
-
Save elarib/8bedc6ab18067e39c9dd9bbcd23be873 to your computer and use it in GitHub Desktop.
List recusively directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def listSubdirectoriesRecursively( | |
directory: Path, | |
list: mutable.ListBuffer[Path] = new mutable.ListBuffer[Path] | |
): List[Path] = { | |
val iterator = fs.listLocatedStatus(directory) | |
while (iterator.hasNext) { | |
val pathStatus = iterator.next() | |
val path = pathStatus.getPath | |
if (pathStatus.isDirectory) | |
if (fs.getContentSummary(path).getDirectoryCount == 1) | |
list += path | |
else listSubdirectoriesRecursively(path, list) | |
} | |
list.sortBy(_.toString).toList | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment