add FileUtil.withTmpDir

This commit is contained in:
xuwei-k
2013-10-11 02:42:16 +09:00
parent cf79ac1069
commit 79e560b7bf

View File

@@ -60,4 +60,14 @@ object FileUtil {
case _ => ""
}
}
def withTmpDir[A](dir: File)(action: File => A): A = {
if(dir.exists()){
FileUtils.deleteDirectory(dir)
}
try{
action(dir)
}finally{
FileUtils.deleteDirectory(dir)
}
}
}