Skip to content

Commit

Permalink
[zio#323] added default arguments to createTempFileManaged
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliihonta committed Mar 28, 2021
1 parent 6ea8686 commit 3cdf51e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
8 changes: 4 additions & 4 deletions nio/src/main/scala/zio/nio/file/Files.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ object Files {
def createTempFileInManaged(
dir: Path,
suffix: String = ".tmp",
prefix: Option[String],
fileAttributes: Iterable[FileAttribute[_]]
prefix: Option[String] = None,
fileAttributes: Iterable[FileAttribute[_]] = Nil
): ZManaged[Blocking, IOException, Path] =
ZManaged.make(createTempFileIn(dir, suffix, prefix, fileAttributes))(release = deleteIfExists(_).ignore)

Expand All @@ -83,8 +83,8 @@ object Files {

def createTempFileManaged(
suffix: String = ".tmp",
prefix: Option[String],
fileAttributes: Iterable[FileAttribute[_]]
prefix: Option[String] = None,
fileAttributes: Iterable[FileAttribute[_]] = Nil
): ZManaged[Blocking, IOException, Path] =
ZManaged.make(createTempFile(suffix, prefix, fileAttributes))(release = deleteIfExists(_).ignore)

Expand Down
11 changes: 2 additions & 9 deletions nio/src/test/scala/zio/nio/file/FilesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ object FilesSpec extends BaseSpec {
for {
pathRef <- Ref.make[Option[Path]](None)
readBytes <- Files
.createTempFileInManaged(
dir = Path("."),
prefix = None,
fileAttributes = Nil
)
.createTempFileInManaged(dir = Path("."))
.use { tmpFile =>
pathRef.set(Some(tmpFile)) *> writeAndThenRead(tmpFile)(sampleFileContent)
}
Expand All @@ -33,10 +29,7 @@ object FilesSpec extends BaseSpec {
for {
pathRef <- Ref.make[Option[Path]](None)
readBytes <- Files
.createTempFileManaged(
prefix = None,
fileAttributes = Nil
)
.createTempFileManaged()
.use { tmpFile =>
pathRef.set(Some(tmpFile)) *> writeAndThenRead(tmpFile)(sampleFileContent)
}
Expand Down

0 comments on commit 3cdf51e

Please sign in to comment.