Zip file modified when added to Phonegap app?

2019-09-21 06:04发布

I am writing a Phonegap app that includes a zip archive in the /assets/www/ folder. When the app is launched the file is copied to the fileSystem root. When I try to read the header, it appears that the file has been modified.

Here's the hexdump on my computer:

# hexdump -C Archive.zip| more
00000000  50 4b 03 04 14 00 00 00  08 00 4c b7 b1 40 84 1d  |PK........L..@..|
00000010  9b 1a 21 00 00 00 a0 01  00 00 0a 00 1c 00 73 61  |..!...........sa|

Here's the hexdump of the file in /sdcard/:

hexdump -C Archive.zip| more

00000000  50 4b 03 04 14 00 00 00  08 00 4c ef bf bd ef bf  |PK........L.....|
00000010  bd 40 ef bf bd 1d ef bf  bd 1a 21 00 00 00 ef bf  |.@........!.....|
00000020  bd 01 00 00 0a 00 1c 00  73 61 6d 70 6c 65 2e 74  |........sample.t|

HOUSTON! WE HAVE A PROBLEM!

So, who moved my cheese? What happened? Since .apk files are zipped folders, is there a potentially destructive side-effect of adding a zip file into a zip file?

2条回答
看我几分像从前
2楼-- · 2019-09-21 06:53

Android uses a special zip alignment. This could be your problem.

查看更多
smile是对你的礼貌
3楼-- · 2019-09-21 07:00

Your app converted the zip file from (probably) Latin-1 to UTF-8.

ef bf bd is UTF-8 code for replacement character.

查看更多
登录 后发表回答