I've been trying to figure how to use the symbolic link support in the 
AsiExtraField class of the commons compress project (1.0).  No luck so far.  
When I unzip the file, created by the code below, the regular file is ok, but 
the symbolic link is a regular 0 byte file.  Both the regular file, and the 
symbolic link, that I'm trying to zip up, exist on the file system. Any 
pointers?

File zipfile = new File(basedir, "test.zip");
ZipArchiveOutputStream zostream = new ZipArchiveOutputStream(zipfile);
// zip entry for original file
File main = new File(basedir, "regularfile");
ZipArchiveEntry entry = new ZipArchiveEntry("regularfile");
entry.setSize(main.length());
zostream.putArchiveEntry(entry);
FileInputStream fostream = new FileInputStream(main);
IOUtils.copy(fostream, zostream);
fostream.close();
zostream.closeArchiveEntry();
// zip entry for link
File link = new File(basedir, "symlink");
entry = new ZipArchiveEntry(link, "symlink");
// Using entry.setSize(link.length()) sets the size of the regular file, so 
skipping it
AsiExtraField field = new AsiExtraField();
field.setLinkedFile("regularfile");
entry.addExtraField(field);
zostream.putArchiveEntry(entry);
// Using IOUtils.copy() seems to add the regular file contents, so skipping it
zostream.closeArchiveEntry();

zostream.finish();
zostream.close();




      

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to