JDK-6708131 : Add ability to set File Attributes on Zip Entries
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 6u5
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-05-28
  • Updated: 2010-04-26
Related Reports
Relates :  
Relates :  
Description
J2SE Version (please include all output from java -version flag):
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

Does this problem occur on J2SE 5.0.x or 6.0?  Yes / No (pick one)
Yes

Operating System Configuration Information (be specific):
Microsoft Windows XP [Version 5.1.2600]

Bug Description:
RFE: Add ability to set File Attributes on Zip Entries

Inside ZipOutputStream there is already a note: 'REMIND: add support for file attributes'
so it looks like there are already plans to do this 

The writeCEN method already contains the line writeInt(0); // external file attributes (unused)
All we need are method to set/get the File Attributes on a Zip Entry and for this 
writeInt to be changed to write that value instead of 0.

I suggest adding methods allowing for any int value, and possibly later on adding
additional convenience methods to set the file attributes for known platforms as
documented in http://www.pkware.com/documents/casestudies/APPNOTE.TXT)

Comments
EVALUATION True, ZipOutputStream reminds us to do this someday. Adding the information about the attributes creates another problem: information written this way is not retrieable via ZipInputStream, since the attributes are written to the ZIP file's central directory, not the local file headers, and the central directory is at the end of the ZIP file. The related bugs note a similar problem with size information. The suggestion for adding methods to allow setting any int value should *not* be done, as (a) such methods they would live on forever, (b) some bits are reserved.
28-05-2008