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