pull/34/head
kunfei 5 years ago
parent 3e8b62759b
commit 01223ea0b1
  1. 10
      app/src/main/java/io/legado/app/utils/ZipUtils.kt

@ -164,24 +164,24 @@ object ZipUtils {
zos: ZipOutputStream, zos: ZipOutputStream,
comment: String? comment: String?
): Boolean { ): Boolean {
var rootPath = rootPath var rootPath1 = rootPath
if (!srcFile.exists()) return true if (!srcFile.exists()) return true
rootPath = rootPath + (if (isSpace(rootPath)) "" else File.separator) + srcFile.name rootPath1 = rootPath1 + (if (isSpace(rootPath1)) "" else File.separator) + srcFile.name
if (srcFile.isDirectory) { if (srcFile.isDirectory) {
val fileList = srcFile.listFiles() val fileList = srcFile.listFiles()
if (fileList == null || fileList.isEmpty()) { if (fileList == null || fileList.isEmpty()) {
val entry = ZipEntry("$rootPath/") val entry = ZipEntry("$rootPath1/")
entry.comment = comment entry.comment = comment
zos.putNextEntry(entry) zos.putNextEntry(entry)
zos.closeEntry() zos.closeEntry()
} else { } else {
for (file in fileList) { for (file in fileList) {
if (!zipFile(file, rootPath, zos, comment)) return false if (!zipFile(file, rootPath1, zos, comment)) return false
} }
} }
} else { } else {
BufferedInputStream(FileInputStream(srcFile)).use { `is` -> BufferedInputStream(FileInputStream(srcFile)).use { `is` ->
val entry = ZipEntry(rootPath) val entry = ZipEntry(rootPath1)
entry.comment = comment entry.comment = comment
zos.putNextEntry(entry) zos.putNextEntry(entry)
zos.write(`is`.readBytes()) zos.write(`is`.readBytes())

Loading…
Cancel
Save