brenzosa / winzipaes

Automatically exported from code.google.com/p/winzipaes
0 stars 0 forks source link

How to add an emtpy folder to an encrypted zip archive using winzipaes? #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try adding an empty folder (folders are also of type File in Java) using 
add(java.io.File file, java.lang.String password) or add(java.io.File file, 
java.lang.String pathForEntry, java.lang.String password) leads to a 
java.io.FileNotFoundException because there is no file data that could be read.
2. Try adding an empty folder using add(java.lang.String name, 
java.io.InputStream is, java.lang.String password) and an empty 
ByteArrayInputStream leads to a zero byte file (instead of a folder) being 
added.
3. add(ExtZipEntry zipEntry, java.io.InputStream zipData) is protected and thus 
can't be used to add an entry for a folder without subclassing.

What is the expected output? 

An empty folder that is added to the ZIP archive.

What do you see instead?

An IOException or a file instead of folder being added.

What version of the product are you using? On what operating system?

winzipaes_src_20110911.zip on a German Windows 7 Pro 64bit with JDK/JRE 
1.6.0_27 64bit

Please provide any additional information below.

Empty folders in a ZIP archive are allowed, I just can't find an interface to 
add them using you lib.

I guess with a self-made ExtZipEntry using add(ExtZipEntry zipEntry, 
InputStream zipData) it should be possible to add an empty folder entry but 
this interface is not public and I'm too lazy to subclass your class just to 
add this feature.

Any way that adding an empty folder is supported in the current version of your 
lib?

Btw. sample program(s), and a working Wiki and/or forum would be nice.

Original issue reported on code.google.com by andrewei...@googlemail.com on 13 Sep 2011 at 7:20

GoogleCodeExporter commented 9 years ago
added testcase to TestAesZipFileEncrypter to show that you can add+extract an 
empty folder - the trick is to suffix "/" to the filename (on add + extract) - 
the empty ByteArrayInputStream could be avoided, but I think as it's quite an 
unusual usecase, an explicit method is too much - the testcases are meant to be 
sample programs ;-)

Original comment by olaf.merkert on 16 Sep 2011 at 5:04