mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-06-02 03:16:32 +02:00
24 lines
579 B
Kotlin
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
|
||
|
}
|
||
|
}
|
||
|
}
|