Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TempPath (<: AutoCloseable) and withTempFile|Dir convenience methods #147

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
return A directly, rather than Try[A] (PR comment)
  • Loading branch information
mpollmeier committed Mar 14, 2023
commit 6bfa0a17f87df428691387254009b6d8a0779433
10 changes: 5 additions & 5 deletions os/src/TempOps.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package os

import java.nio.file.attribute.{FileAttribute, PosixFilePermissions}
import scala.util.{Using, Try}
import scala.util.Using

/**
* Create temporary files and directories. [[withTempFile]] and [[withTempDir]]
Expand Down Expand Up @@ -92,8 +92,8 @@ object temp {
* }
* }}}
*/
def withTempFile[A](fun: Path => A): Try[A] =
Using(os.temp(
def withTempFile[A](fun: Path => A): A =
Using.resource(os.temp(
deleteOnExit = false // TempFile.close() deletes it, no need to register with JVM
))(fun)

Expand All @@ -108,8 +108,8 @@ object temp {
* }
* }}}
*/
def withTempDir[A](fun: Path => A): Try[A] =
Using(os.temp.dir(
def withTempDir[A](fun: Path => A): A =
Using.resource(os.temp.dir(
deleteOnExit = false // TempFile.close() deletes it, no need to register with JVM
))(fun)

Expand Down