Skip to content

Commit

Permalink
bugfix windows zip
Browse files Browse the repository at this point in the history
  • Loading branch information
jmp0 committed Sep 29, 2022
1 parent 4086428 commit 73f1a2a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
api 'com.github.zhkl0228:unidbg-parent:0.9.7'
api 'com.github.zhkl0228:unidbg-api:0.9.7'
api 'com.github.zhkl0228:unidbg-android:0.9.7'
implementation 'net.lingala.zip4j:zip4j:2.10.0'
implementation 'io.github.qsy7.java.dependencies:slf4j-simple:0.1.0'
implementation 'org.ow2.asm:asm-debug-all:5.0.3'
compileOnly fileTree(dir:'../libs/',includes:['*jar'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object UnidbgWrapperUtils {
}

fun toUnidbgObject(vm:VM,obj:Any?,className:String? = null):DvmObject<out Any>{
if (obj == null) return DvmObjectWrapper(vm.resolveClass("java/lang/String"),null)
if (obj == null) return DvmObjectWrapper(vm.resolveClass("java/lang/Object"),null)
//fixme wrapper fix
when(obj){
is String -> return StringObject(vm,obj)
Expand Down
39 changes: 18 additions & 21 deletions core/src/main/java/jmp0/util/ZipUtility.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package jmp0.util

import net.lingala.zip4j.ZipFile
import java.io.*
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.util.*
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream

object ZipUtility {
private val BUFFER_SIZE = 4096
Expand Down Expand Up @@ -61,22 +57,23 @@ object ZipUtility {
}
bos.close()
}

@SuppressWarnings("unused")
fun zip(sourceDirPath: String, zipFilePath: String) {
val p: Path = Files.createFile(Paths.get(zipFilePath))
ZipOutputStream(Files.newOutputStream(p)).use { zs ->
val pp: Path = Paths.get(sourceDirPath)
Files.walk(pp)
.filter { path -> !Files.isDirectory(path) }
.forEach { path ->
if (path.startsWith("$pp${File.separator}kotlin"))
//exclude kotlin package
return@forEach
val zipEntry = ZipEntry(pp.relativize(path).toString())
zs.putNextEntry(zipEntry)
zs.write(Files.readAllBytes(path))
zs.closeEntry()
}
}
ZipFile(zipFilePath).addFolder(File(sourceDirPath))
// val p: Path = Files.createFile(Paths.get(zipFilePath))
// ZipOutputStream(Files.newOutputStream(p)).use { zs ->
// val pp: Path = Paths.get(sourceDirPath)
// Files.walk(pp)
// .filter { path -> !Files.isDirectory(path) }
// .forEach { path ->
// if (path.startsWith("$pp${File.separator}kotlin"))
// //exclude kotlin package
// return@forEach
// val zipEntry = ZipEntry(pp.relativize(path).toString())
// zs.putNextEntry(zipEntry)
// zs.write(Files.readAllBytes(path))
// zs.closeEntry()
// }
// }
}
}

0 comments on commit 73f1a2a

Please sign in to comment.