Fix/extracting assets from apks (#644)
* Get rid of multiple static "assets/" usage * Correctly add new zip entry The name of the entry has to be a "/" separated path, otherwise, the files can't be found.
This commit is contained in:
@@ -213,7 +213,7 @@ object Extension {
|
||||
var zipEntry = zipInputStream.nextEntry
|
||||
while (zipEntry != null) {
|
||||
if (zipEntry.name.startsWith("assets/")) {
|
||||
val assetFile = File(assetsFolder, zipEntry.name.substringAfter("assets/"))
|
||||
val assetFile = File(assetsFolder, zipEntry.name)
|
||||
assetFile.parentFile.mkdirs()
|
||||
FileOutputStream(assetFile).use { outputStream ->
|
||||
zipInputStream.copyTo(outputStream)
|
||||
@@ -236,7 +236,7 @@ object Extension {
|
||||
}
|
||||
assetsFolder.walkTopDown().forEach { file ->
|
||||
if (file.isFile) {
|
||||
jarZipOutputStream.putNextEntry(ZipEntry("assets/${file.relativeTo(assetsFolder)}"))
|
||||
jarZipOutputStream.putNextEntry(ZipEntry(file.relativeTo(assetsFolder).toString().replace("\\", "/")))
|
||||
file.inputStream().use { inputStream ->
|
||||
inputStream.copyTo(jarZipOutputStream)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user