revanced-cli/src/main/kotlin/app/revanced/cli/utils/Preconditions.kt

24 lines
579 B
Kotlin

package app.revanced.cli.utils
import java.io.File
import java.io.FileNotFoundException
class Preconditions {
companion object {
fun isFile(path: String): File {
val f = File(path)
if (!f.exists()) {
throw FileNotFoundException(f.toString())
}
return f
}
fun isDirectory(path: String): File {
val f = isFile(path)
if (!f.isDirectory) {
throw IllegalArgumentException("$f is not a directory")
}
return f
}
}
}