Skip to content

Commit

Permalink
Fix #309: Recursive delete on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
pathikrit committed May 8, 2019
1 parent baf2a67 commit 5cd4680
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/main/scala/better/files/File.scala
Expand Up @@ -1182,8 +1182,16 @@ class File private (val path: Path)(implicit val fileSystem: FileSystem = path.g
this
}

def deleteOnExit(): this.type = {
toJava.deleteOnExit()
def deleteOnExit(
swallowIOExceptions: Boolean = false,
linkOption: File.LinkOptions = File.LinkOptions.noFollow
): this.type = {
try {
if (isDirectory(linkOption)) list.toList.foreach(_.deleteOnExit(swallowIOExceptions, linkOption))
toJava.deleteOnExit()
} catch {
case _: IOException if swallowIOExceptions => //e.printStackTrace() //swallow
}
this
}

Expand Down

0 comments on commit 5cd4680

Please sign in to comment.