mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-25 18:47:51 +02:00
Use UniFile for local source file handling
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
package eu.kanade.tachiyomi.util.storage
|
||||
|
||||
import com.hippo.unifile.UniFile
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import tachiyomi.core.storage.toFile
|
||||
import java.io.Closeable
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
@ -11,12 +13,12 @@ import java.util.zip.ZipFile
|
||||
/**
|
||||
* Wrapper over ZipFile to load files in epub format.
|
||||
*/
|
||||
class EpubFile(file: File) : Closeable {
|
||||
class EpubFile(file: UniFile) : Closeable {
|
||||
|
||||
/**
|
||||
* Zip file of this epub.
|
||||
*/
|
||||
private val zip = ZipFile(file)
|
||||
private val zip = ZipFile(file.toFile())
|
||||
|
||||
/**
|
||||
* Path separator used by this epub.
|
||||
|
@ -1,4 +1,4 @@
|
||||
package tachiyomi.core.provider
|
||||
package tachiyomi.core.storage
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Environment
|
@ -1,4 +1,4 @@
|
||||
package tachiyomi.core.provider
|
||||
package tachiyomi.core.storage
|
||||
|
||||
import java.io.File
|
||||
|
@ -1,9 +1,12 @@
|
||||
package tachiyomi.core.storage
|
||||
|
||||
import com.hippo.unifile.UniFile
|
||||
import java.io.File
|
||||
|
||||
val UniFile.extension: String?
|
||||
get() = name?.substringAfterLast('.')
|
||||
|
||||
val UniFile.nameWithoutExtension: String?
|
||||
get() = name?.substringBeforeLast('.')
|
||||
|
||||
fun UniFile.toFile(): File? = filePath?.let { File(it) }
|
||||
|
@ -37,7 +37,9 @@ import kotlin.math.min
|
||||
|
||||
object ImageUtil {
|
||||
|
||||
fun isImage(name: String, openStream: (() -> InputStream)? = null): Boolean {
|
||||
fun isImage(name: String?, openStream: (() -> InputStream)? = null): Boolean {
|
||||
if (name == null) return false
|
||||
|
||||
val contentType = try {
|
||||
URLConnection.guessContentTypeFromName(name)
|
||||
} catch (e: Exception) {
|
||||
|
Reference in New Issue
Block a user