diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt index 88ef7f0d..8a063322 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -33,6 +33,7 @@ import java.io.FileInputStream import java.io.FileOutputStream import java.util.* import java.util.zip.ZipEntry +import java.util.zip.ZipFile import java.util.zip.ZipOutputStream @@ -243,9 +244,45 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList): Boolean { + sourcePaths.map { File(it) } + .forEach { + try { + val zipFile = ZipFile(it) + val entries = zipFile.entries() + while (entries.hasMoreElements()) { + val entry = entries.nextElement() + val file = File(it.parent, entry.name) + if (entry.isDirectory) { + file.mkdirs() + } else { + file.parentFile.mkdirs() + val ins = zipFile.getInputStream(entry) + ins.use { + ins.copyTo(FileOutputStream(file)) + } + } + } + } catch (e: Exception) { + activity.showErrorToast(e.toString()) + return false + } + } + return true + } + fun zipPaths(sourcePaths: List, targetPath: String): Boolean { val queue = LinkedList() val out = FileOutputStream(File(targetPath))