blob: d53cfcc9ceceba336387b500fd8283c185ee4ae0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package mill.modules
import ammonite.ops.{Path, RelPath}
import mill.eval.PathRef
import mill.util.Ctx
object Util {
def download(url: String, dest: RelPath)(implicit ctx: Ctx.DestCtx) = {
ammonite.ops.mkdir(ctx.dest)
val out = ctx.dest / dest
val website = new java.net.URI(url).toURL
val rbc = java.nio.channels.Channels.newChannel(website.openStream)
try{
val fos = new java.io.FileOutputStream(out.toIO)
try{
fos.getChannel.transferFrom(rbc, 0, java.lang.Long.MAX_VALUE)
PathRef(out)
} finally{
fos.close()
}
} finally{
rbc.close()
}
}
}
|