comparison antlib/Du.kt @ 29:e90d290a9a8d

Remove dependence on Nashorn.
author David Barts <n5jrn@me.com>
date Mon, 13 Jun 2022 09:21:24 -0700
parents
children
comparison
equal deleted inserted replaced
28:c310ec097194 29:e90d290a9a8d
1 import java.io.File
2 import java.io.IOException
3
4 class Du : org.apache.tools.ant.Task() {
5 var path: String? = null
6 var output: String? = null
7
8 override fun execute(): Unit {
9 project.setProperty(output, du(path!!).toString())
10 }
11
12 private fun du(path: String): Long {
13 try {
14 return File(path).walk().map { if (it.isFile()) { it.length() } else { 0L } }.sum()
15 } catch (e: IOException) {
16 return 0L
17 }
18 }
19 }