Using NIO2 for writing zip file entries without corresponding folder entries
Alan.Bateman at oracle.com
Wed Oct 10 11:50:37 UTC 2018
On 10/10/2018 12:31, Rafael Winterhalter wrote:
> I was wondering why the ZipFileSystem checked for the existence of a
> file's parents before writing a file. Writing folder entries is not a
> requirement in the specification for zip files and I find it strange
> that the implementation enforces it. I found that even to be
> problematic when altering a zip file where NIO2 requires you to add
> folder entries that did not exist before.
If you using a zip file system to create a new zip file then it
shouldn't be a surprise that you need to create a directory before
creating entries in the directory. The zip file system is just trying to
behave like a regular file system. The zip file system provider does
lack a configuration option to strip directories when writing, that
could potentially be added if important.
One other thing is that the zip file system provider can open existing
zip files that don't have entries for directories, it's should emulate
them for that scenario.
More information about the nio-dev