Created
September 19, 2013 09:31
-
-
Save aembleton/6621168 to your computer and use it in GitHub Desktop.
Gets a list of files in a given directory and all child directories
This file contains hidden or 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
/** | |
* Gets a list of files in a given directory and all child directories | |
* @param f This is the File representing the root directory | |
* @return A list of File objects, each one representing a File inside f, either directly or in a sub-directory | |
*/ | |
def listFiles(f: File): List[File] = f match{ | |
case f if f.isDirectory => f.listFiles.toList.flatMap(listFiles(_)) | |
case f if f.isFile => List(f) | |
case _ => Nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment