Skip to content

Commit 23d23d6

Browse files
committed
provide the same set of options as we do in the apply methods
1 parent 803d307 commit 23d23d6

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

os/src/TempOps.scala

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,23 @@ object temp {
9292
* }
9393
* }}}
9494
*/
95-
def withFile[A](fun: Path => A): A =
95+
def withFile[A](
96+
fun: Path => A,
97+
contents: Source = null,
98+
dir: Path = null,
99+
prefix: String = null,
100+
suffix: String = null,
101+
perms: PermSet = null
102+
): A = {
96103
Using.resource(os.temp(
97-
deleteOnExit = false // TempFile.close() deletes it, no need to register with JVM
104+
contents = contents,
105+
dir = dir,
106+
prefix = prefix,
107+
suffix = suffix,
108+
deleteOnExit = false, // TempFile.close() deletes it, no need to register with JVM
109+
perms = perms
98110
))(fun)
111+
}
99112

100113
/**
101114
* Convenience method that creates a temporary directory and automatically deletes it
@@ -108,9 +121,17 @@ object temp {
108121
* }
109122
* }}}
110123
*/
111-
def withDir[A](fun: Path => A): A =
124+
def withDir[A](
125+
fun: Path => A,
126+
dir: Path = null,
127+
prefix: String = null,
128+
perms: PermSet = null
129+
): A =
112130
Using.resource(os.temp.dir(
113-
deleteOnExit = false // TempFile.close() deletes it, no need to register with JVM
131+
dir = dir,
132+
prefix = prefix,
133+
deleteOnExit = false, // TempFile.close() deletes it, no need to register with JVM
134+
perms = perms
114135
))(fun)
115136

116137
}

0 commit comments

Comments
 (0)