mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-28 03:57:50 +02:00
Convert source modules to Kotlin Multiplatform (#9172)
Use KMP in source modules Use KMP in source-api Expect LocalSource
This commit is contained in:
@ -0,0 +1,6 @@
|
||||
package tachiyomi.source.local
|
||||
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.UnmeteredSource
|
||||
|
||||
expect class LocalSource : CatalogueSource, UnmeteredSource
|
@ -0,0 +1,12 @@
|
||||
package tachiyomi.source.local.image
|
||||
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
|
||||
expect class LocalCoverManager {
|
||||
|
||||
fun find(mangaUrl: String): File?
|
||||
|
||||
fun update(manga: SManga, inputStream: InputStream): File?
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package tachiyomi.source.local.io
|
||||
|
||||
import java.io.File
|
||||
|
||||
object Archive {
|
||||
|
||||
private val SUPPORTED_ARCHIVE_TYPES = listOf("zip", "cbz", "rar", "cbr", "epub")
|
||||
|
||||
fun isSupported(file: File): Boolean = with(file) {
|
||||
return extension.lowercase() in SUPPORTED_ARCHIVE_TYPES
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package tachiyomi.source.local.io
|
||||
|
||||
import java.io.File
|
||||
|
||||
sealed class Format {
|
||||
data class Directory(val file: File) : Format()
|
||||
data class Zip(val file: File) : Format()
|
||||
data class Rar(val file: File) : Format()
|
||||
data class Epub(val file: File) : Format()
|
||||
|
||||
class UnknownFormatException : Exception()
|
||||
|
||||
companion object {
|
||||
|
||||
fun valueOf(file: File) = with(file) {
|
||||
when {
|
||||
isDirectory -> Directory(this)
|
||||
extension.equals("zip", true) || extension.equals("cbz", true) -> Zip(this)
|
||||
extension.equals("rar", true) || extension.equals("cbr", true) -> Rar(this)
|
||||
extension.equals("epub", true) -> Epub(this)
|
||||
else -> throw UnknownFormatException()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package tachiyomi.source.local.io
|
||||
|
||||
import java.io.File
|
||||
|
||||
expect class LocalSourceFileSystem {
|
||||
|
||||
fun getBaseDirectories(): Sequence<File>
|
||||
|
||||
fun getFilesInBaseDirectories(): Sequence<File>
|
||||
|
||||
fun getMangaDirectory(name: String): File?
|
||||
|
||||
fun getFilesInMangaDirectory(name: String): Sequence<File>
|
||||
}
|
Reference in New Issue
Block a user