stdlib: simplify File.recurse and File.extension functions

This commit is contained in:
Denis Mekhanikov
2014-10-14 18:42:48 +04:00
committed by Ilya Ryzhenkov
parent 1a4c11cb98
commit 23397d17dc
+2 -13
View File
@@ -9,12 +9,7 @@ import java.util.*
*/
public fun File.recurse(block: (File) -> Unit): Unit {
block(this)
val children = listFiles()
if (children != null) {
for (child in children) {
child.recurse(block)
}
}
listFiles()?.forEach { it.recurse(block) }
}
/**
@@ -46,13 +41,7 @@ public val File.path: String
*/
public val File.extension: String
get() {
val text = name
val idx = text.lastIndexOf('.')
return if (idx >= 0) {
text.substring(idx + 1)
} else {
""
}
return name.substringAfterLast('.', "")
}
/**