groovy-common-extensions icon indicating copy to clipboard operation
groovy-common-extensions copied to clipboard

added support of *.jar file extension in zip and unzip

Open akhikhl opened this issue 11 years ago • 3 comments

It would be nice to use zip and unzip functions not only on ZIP-files, but also on JAR-files.

akhikhl avatar Apr 14 '14 17:04 akhikhl

Sorry it took so long to get back to this, illness, Easter and a ton of stuff at work seem to have bogged me down for the past couple of weeks :sadpanda:

Wouldn't this require changing the underlying zip method to use JarOutputStream instead of ZipOutputStream? Maybe a separate jar/unjar method pair would be a better route?

timyates avatar Apr 22 '14 16:04 timyates

Yeah, no problem :)

Let's analyze, what we have. Jar(Input/Output)Stream classes differ from Zip versions only by special handling of manifest:

  • JarOutputStream accepts manifest as a parameter to constructor
  • JarInputStream has accessor getManifest

and that's it.

Since zip/unzip functions in groovy-common-extensions only talk on the level of File/Collection<File>, manifests cannot be exposed with these functions. But I still think, that it is OK to treat JARs as ZIPs, i.e. to allow zip/unzip JAR files. Sometimes manifest does not need special treatment - it's another file being zipped/unzipped, not more. What do you think?

Separate jar/unjar methods is a good idea. But then File/Collection<File> parameters/return results are not enough - we should give access to manifest. I'll think on possible function signatures.

akhikhl avatar Apr 22 '14 16:04 akhikhl

Of course you're right :blush: (told you I'd been ill)

I'm actually wondering whether it's worth just removing the extension checking... So it will just try and treat the file as a zip no matter what it's extension is...

timyates avatar Apr 24 '14 11:04 timyates