优化
This commit is contained in:
@@ -2,11 +2,11 @@ package io.legado.app.utils
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import splitties.init.appCtx
|
||||
import java.io.File
|
||||
|
||||
import splitties.init.appCtx
|
||||
|
||||
/* 自动判断压缩文件后缀 然后再调用具体的实现 */
|
||||
@Suppress("unused", "MemberVisibilityCanBePrivate")
|
||||
object ArchiveUtils {
|
||||
|
||||
// 临时目录 下次启动自动删除
|
||||
|
||||
@@ -49,10 +49,10 @@ object RarUtils {
|
||||
}
|
||||
|
||||
fun unRarToPath(archive: Archive, destDir: File?) {
|
||||
var entry: FileHeader
|
||||
var entry: FileHeader?
|
||||
while (archive.nextFileHeader().also { entry = it } != null) {
|
||||
val entryFile = File(destDir, entry.fileName)
|
||||
if (entry.isDirectory) {
|
||||
val entryFile = File(destDir, entry!!.fileName)
|
||||
if (entry!!.isDirectory) {
|
||||
if (!entryFile.exists()) {
|
||||
entryFile.mkdirs()
|
||||
}
|
||||
@@ -69,7 +69,6 @@ object RarUtils {
|
||||
FileOutputStream(entryFile).use {
|
||||
archive.getInputStream(entry).copyTo(it)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ object SevenZipUtils {
|
||||
|
||||
|
||||
fun un7zToPath(sevenZFile:SevenZFile, destDir: File?){
|
||||
var entry: SevenZArchiveEntry
|
||||
while (sevenZFile.nextEntry.also { entry=it }!=null){
|
||||
val entryFile = File(destDir, entry.name)
|
||||
if (entry.isDirectory) {
|
||||
var entry: SevenZArchiveEntry?
|
||||
while (sevenZFile.nextEntry.also { entry=it }!=null) {
|
||||
val entryFile = File(destDir, entry!!.name)
|
||||
if (entry!!.isDirectory) {
|
||||
if (!entryFile.exists()) {
|
||||
entryFile.mkdirs()
|
||||
}
|
||||
|
||||
@@ -180,10 +180,10 @@ object ZipUtils {
|
||||
}
|
||||
|
||||
fun unZipToPath(zipInputStream: ZipInputStream, path: String) {
|
||||
var entry: ZipEntry
|
||||
var entry: ZipEntry?
|
||||
while (zipInputStream.nextEntry.also { entry = it } != null) {
|
||||
val entryFile = File(path, entry.name)
|
||||
if (entry.isDirectory) {
|
||||
val entryFile = File(path, entry!!.name)
|
||||
if (entry!!.isDirectory) {
|
||||
if (!entryFile.exists()) {
|
||||
entryFile.mkdirs()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user