Closed latuszek closed 10 years ago
Hi @seiyapl, it would be nice inceed. However, it's not that easy to implement. Obvious Unix vs. Windows permissions incompatibility aside (which means that we won't be able to make it work for cross-platform use), Java is not that good at setting file permissions.
Storing the mask of a file into an extra field on a ZipEntry is easy, however, obtaining it from the file and then setting it for unzipped file is harder. Especially Zt-Zip being Java 4 compatible.
We'll look into it anyway, but if you have a good idea about how to do it, please mention it. Maybe you can come up with a pull-request that shows what do you have in mind?
Hi @shelajev. I know it won't be easy and I'm afraid I won't be helpful. I can only describe my use case. I'm using zt-zip in my autodeployment app which compress entire tomcat directory. However when I need to do rollback, file permissions are not restored. Currently I'm just changing them after unzipping calling unix "chmod" for all *.sh files.
I'm not too pessimistic about this as Ant actually supports the basics. I think delivering something similar will make a lot of users happy.
Well, one possibility would be to include a class to handle that, using Java7 API. So zt-zip would use that, but only when running on Java7.
Yup, wouldn't be the only conditional feature, https://github.com/zeroturnaround/zt-zip/blob/master/src/main/java/org/zeroturnaround/zip/ZipFileUtil.java
I'm taking this for myself. I'm looking into making it work on POSIX systems with modern enough Java version.
@seiyapl what version of Java do you use? I'll target that first and then we'll think how to improve the generic support later.
@shelajev Here's my current version:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
However, I think we will update to 1.7.0_60 soon.
@shelajev be sure not to invent the wheel. The Unix and DOS permissions are in the external fields ( http://www.pkware.com/documents/casestudies/APPNOTE.TXT ) and there is an implementation at http://svn.apache.org/repos/asf/ant/core/tags/ANT_170/src/main/org/apache/tools/zip/ZipEntry.java
I've put some time into investigating this. There's no easy solution in fact. Even with the Ant code at hand. The jdk's ZipOutputStream writes 0 for the external ettributes field of every entry. And it doesn't make it easy to extends the code.
Ant has their own ZipEntry implementation that has a field for the external attributes and their own ZipOutputStream to write the attributes to the correct place.
Just wanted to mention that I looked into that. Don't know how do we want to proceed yet.
Why not take similar approach?
Hm, indeed. I'll prepare a branch, we can look at how the code looks and decide then.
Thanks, Viktor!
we need more tests for the permissions functionality, but the feature is implemented and all interested parties can try / test / use it.
Hi, what is the status of this ? is it preserving unix permissions even if i extract it on windows? as i am looking for something which takes a zip file and remove some entries and recreates the zip file without loosing the unix permissions?
any help would be very appreciated.
It would be nice if file permissions under Unix system could be preserved.