Mercurial > cgi-bin > hgweb.cgi > ImagePrep
annotate antlib/Du.kt @ 30:098c4f5507c7
Convert to JDK 15.
author | David Barts <n5jrn@me.com> |
---|---|
date | Mon, 13 Jun 2022 11:31:49 -0700 |
parents | e90d290a9a8d |
children |
rev | line source |
---|---|
29 | 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 } |