zip
zip copied to clipboard
Extraction from ZIP archive with prepended data fails
I am trying to use this zip implementation to distribute resource data as part of a fat executable, because it is cross platform and has no external dependencies.
Packing and appending the ZIP archive to the executable from Setup.hs
works great, however unpacking the data at runtime from Main.hs
fails with:
Parsing of archive structure failed:
Cannot locate end of central directory
in ".stack-work/install/x86_64-osx/lts-11.6/8.2.2/bin/self-extracting-zip"
However, unzip
reports:
% unzip -l .stack-work/install/x86_64-osx/lts-11.6/8.2.2/bin/self-extracting-zip
Archive: .stack-work/install/x86_64-osx/lts-11.6/8.2.2/bin/self-extracting-zip
warning [.stack-work/install/x86_64-osx/lts-11.6/8.2.2/bin/self-extracting-zip]: 2566816 extra bytes at beginning or within zipfile
(attempting to process anyway)
Length Date Time Name
--------- ---------- ----- ----
220 05-20-2018 13:49 app/Main.hs
--------- -------
220 1 file
The entire test project can be found here. My question is, am I doing something wrong, or is this not a valid use case for the library?
Any help will be greatly appreciated.
I'll take a look. Probably this weekend. I'm quite busy these days so I can't assist immediately.
This usage is not supported right now. Zip uses offsets to specify start of file headers, and when you prepend something to zip archive these are no longer valid. unzip
probably just knows how to detect size of data at the beginning and adjust the offsets automatically.
We can do it too, just need to sit down and implement. Not sure when I'll have time.
Do you want to prepare a PR? That would be the fastest way forward.
I will see what I can do.