diff options
author | Jakob Odersky <jakob@odersky.com> | 2017-04-09 18:18:22 -0700 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2017-04-09 18:18:22 -0700 |
commit | a7492a3b101ed0e119bf3315ff4dfb63a8f3fe01 (patch) | |
tree | 14b07d84ff8f5bb03fc909cd550d6c726a27be5c /crashboxd/src/test/scala/io/crashbox/ci/IOUtil.scala | |
parent | 30c3990d25293c01a380fc8715679e7f618a4cae (diff) | |
download | crashbox-ci-a7492a3b101ed0e119bf3315ff4dfb63a8f3fe01.tar.gz crashbox-ci-a7492a3b101ed0e119bf3315ff4dfb63a8f3fe01.tar.bz2 crashbox-ci-a7492a3b101ed0e119bf3315ff4dfb63a8f3fe01.zip |
Diffstat (limited to 'crashboxd/src/test/scala/io/crashbox/ci/IOUtil.scala')
-rw-r--r-- | crashboxd/src/test/scala/io/crashbox/ci/IOUtil.scala | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crashboxd/src/test/scala/io/crashbox/ci/IOUtil.scala b/crashboxd/src/test/scala/io/crashbox/ci/IOUtil.scala index 034c6a3..82c0840 100644 --- a/crashboxd/src/test/scala/io/crashbox/ci/IOUtil.scala +++ b/crashboxd/src/test/scala/io/crashbox/ci/IOUtil.scala @@ -1,13 +1,13 @@ package io.crashbox.ci -import java.io.{ ByteArrayOutputStream, File } +import java.io.{ByteArrayOutputStream, File} import java.nio.file.Files object IOUtil { def withTempDir[A](action: File => A): A = { def rm(parent: File): Unit = if (parent.isDirectory) { - parent.listFiles.foreach{ child => + parent.listFiles.foreach { child => rm(child) } } @@ -16,13 +16,15 @@ object IOUtil { finally rm(dir) } - def withTempStream[A](action: ByteArrayOutputStream => A, size: Int = 1024): A = { + def withTempStream[A](action: ByteArrayOutputStream => A, + size: Int = 1024): A = { val out = new ByteArrayOutputStream(size) try action(out) finally out.close() } - def withTemp[A](action: (File, ByteArrayOutputStream) => A, size: Int = 1024): A = { + def withTemp[A](action: (File, ByteArrayOutputStream) => A, + size: Int = 1024): A = { withTempDir { d => withTempStream { s => action(d, s) |