Closed hfzzztz closed 8 years ago
Can you share the code you use to unpack archives with zt-zip?
I use this API to unpack zip file. public static void unpack(InputStream is, File outputDir) in ZipUtil
/* * Returns true if this is a directory entry. A directory entry is * defined to be one whose name ends with a '/'. * @return true if this is a directory entry / public boolean isDirectory() { return name.endsWith("/"); }
I think I find the reason now. As you can see, zipUtil use ‘/’ as separator. But some zip file use '\' as separator.
Yup, that could cause this. I'll try to create some zip archives and see from there.
Based on the Zip specification ( https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT ) everything must be forward slash. Can you share an archive that produces the problems you are having?
I am sorry that I can not share these archives for these archives may contain confidential information. But these archives are produced on windows using File.separator that is '\' as separator. Thanks for your help.
Can you create an archive that has the \ in it that you can share? I tried with Windows compression to get the archive that wouldn't work but I couldn't.
I might confused you. The archive that wouldn't work was created by another program, not zt-zip. That program use File.separator as separator. zt-zip does not. At first I doubt if there is anything wrong with zip unpacking functionality. But now I think it is not zt-zip's bug.
I think I do understand. The spec says that the only separator should be a forward slash (/) but some software out there also creates with a separator that is a backslash ().
zt-zip will never start creating these archives. If there are enough of these wrong archives on the internet then we can add support to unpacking these BUT I haven't found such archives yet.
I create a zip taking '\' as separator. On Windows this zip can be unpack correctly because Windows takes '\' as separator too. Here is the result I unpacked on Linux. I send the zip file to your email.
Thank you for providing the test archive. I did some work on the library on Friday. I added a BackslashUnpacker. You can see the usage at https://github.com/zeroturnaround/zt-zip/blob/master/src/test/java/org/zeroturnaround/zip/ZipUtilTest.java#L847 Let me know if this fixes the issue for you.
zt-zip 1.9 has been released, containing the above mentioned improvements.
Version 1.7 When I unpacking a zip file containing folders in Linux, all the entries in the zip are unpacked with name containing it's parent folders' names. Folders are omitted. But on windows everything is fine. Even on Linux some zip file can be unpacked correctly, while some can not. Is anything wrong? Thanks for your help.
Structure of zip
Entries unpacked