Skip to content

Instantly share code, notes, and snippets.

@joprice
Created January 8, 2016 16:43
Show Gist options
  • Save joprice/1fdded7d5527a7708149 to your computer and use it in GitHub Desktop.
Save joprice/1fdded7d5527a7708149 to your computer and use it in GitHub Desktop.
@annotation.tailrec
def findFileInParents(name: String, dir: File = file(".")): Option[File] = {
lazy val parent = Option(dir.getAbsoluteFile.getParentFile)
val f = dir / name
if (!f.exists) {
println(s"no $f. checking parent")
if (parent.isDefined) findFile(name, parent.get)
else None
} else Some(f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment