Use UniFile for local source file handling
(cherry picked from commit ca5498434409d4085c404f4ff5ed5e608f430a3b) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/RarPageLoader.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ZipPageLoader.kt # core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt # source-local/src/androidMain/kotlin/tachiyomi/source/local/LocalSource.kt # source-local/src/androidMain/kotlin/tachiyomi/source/local/image/LocalCoverManager.kt # source-local/src/commonMain/kotlin/tachiyomi/source/local/image/LocalCoverManager.kt
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
-1
@@ -1,4 +1,4 @@
|
||||
package tachiyomi.core.provider
|
||||
package tachiyomi.core.storage
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Environment
|
||||
+1
-1
@@ -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) }
|
||||
|
||||
@@ -43,7 +43,8 @@ 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
|
||||
// SY -->
|
||||
if (File(name).extension.equals("cbi", ignoreCase = true)) return true
|
||||
// SY <--
|
||||
|
||||
Reference in New Issue
Block a user