@@ -2,13 +2,9 @@ package common
22
33import java.io.File
44import java.lang.reflect.Proxy
5- import java.nio.file.FileSystems
6- import java.nio.file.Files
7- import java.nio.file.Path
8- import java.text.DecimalFormat
9- import java.text.NumberFormat
10- import kotlin.math.ln
11- import kotlin.math.pow
5+ import java.nio.file.*
6+ import java.text.*
7+ import kotlin.math.*
128import kotlin.properties.ReadOnlyProperty
139import kotlin.reflect.full.isSubtypeOf
1410import kotlin.reflect.typeOf
@@ -52,10 +48,6 @@ inline fun <reified T> mock() =
5248 // InvocationHandler.invokeDefault(proxy, method, args)
5349 } as T
5450
55- /* * Returns the file size in a human-readable format. */
56- val File .displaySize
57- get() = length().byteDisplaySize()
58-
5951val Long .compactFmt: String
6052 get() = NumberFormat .getCompactNumberInstance().format(this )
6153
@@ -73,7 +65,7 @@ val String.camelCase: String
7365 * - [SI](https://en.wikipedia.org/wiki/International_System_of_Units#Prefixes)
7466 * - [Binary](https://en.wikipedia.org/wiki/Binary_prefix)
7567 */
76- fun Long.byteDisplaySize (si : Boolean = true): String {
68+ private fun Long.byteDisplaySize (si : Boolean = true): String {
7769 require(this >= 0 ) { " Bytes can't be negative" }
7870 val unit = if (si) 1000 else 1024
7971 return when (this < unit) {
@@ -98,11 +90,8 @@ fun IntArray.codePointsToString(separator: String = "") =
9890 joinToString(separator) { Character .toString(it) }
9991
10092/* * Find the file ends with given [format] under the directory. */
101- fun File.findPkg (format : String? ) =
102- when (format != null ) {
103- true -> walk().firstOrNull { it.isFile && it.name.endsWith(format, ignoreCase = true ) }
104- else -> null
105- }
93+ fun File.findPkg (format : String ) =
94+ walk().firstOrNull { it.isFile && it.name.endsWith(format, ignoreCase = true ) }
10695
10796/* * List files based on the glob [pattern] */
10897fun Path.glob (pattern : String ): List <Path > {
0 commit comments