Reputation: 1871
I would like to ignore hidden files when extracting a zip. Is there any way i can identify that a ZipEntry belongs to a 'hidden' file?
Upvotes: 2
Views: 2519
Reputation: 841
Java class ZipEntry
does not maintain file flags by design, as the accepted answer found.
If your usecase has not reserved the comment tag, you could fill it with file flag info, as e.g.
windows command line attrib <file>
delivers.
In order to mark only hidden files, that would be
ZipEntry entry = new ZipEntry("foo").setComment("H");
EDIT
There is also an extra
tag, designed to take additional implementation specific information as generic container, see
this answer
Upvotes: 0
Reputation: 75456
If this is on Windows, there is no way to do it. The ZipEntry doesn't contain such information. You might be able to write your own zipper to store the information in ExtraInfo field.
On Unix, you can workaround by checking the leading dot in the filename.
Upvotes: 2
Reputation: 82559
http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#isHidden%28%29
It should have been preserved when they created the zip.
Upvotes: 2