mirror of
https://github.com/mihonapp/mihon.git
synced 2025-07-13 03:05:11 +02:00
simpler format logic
This commit is contained in:
@ -14,13 +14,13 @@ sealed interface Format {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun valueOf(file: UniFile) = with(file) {
|
fun valueOf(file: UniFile): Format {
|
||||||
when {
|
if (file.isDirectory) return Directory(file)
|
||||||
isDirectory -> Directory(this)
|
return when (file.extension?.lowercase()) {
|
||||||
extension.equals("zip", true) || extension.equals("cbz", true) -> Zip(this)
|
"zip", "cbz" -> Zip(file)
|
||||||
extension.equals("7z", true) || extension.equals("cb7", true) -> SevenZip(this)
|
"7z", "cb7" -> SevenZip(file)
|
||||||
extension.equals("rar", true) || extension.equals("cbr", true) -> Rar(this)
|
"rar", "cbr" -> Rar(file)
|
||||||
extension.equals("epub", true) -> Epub(this)
|
"epub" -> Epub(file)
|
||||||
else -> throw UnknownFormatException()
|
else -> throw UnknownFormatException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user