commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John O'Leary <johnsomethingorot...@yahoo.com>
Subject commons-compress symlink support
Date Wed, 10 Feb 2010 00:54:33 GMT
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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message