Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extraction from ZIP archive with prepended data fails #46

Open
monofon opened this issue May 21, 2018 · 4 comments
Open

Extraction from ZIP archive with prepended data fails #46

monofon opened this issue May 21, 2018 · 4 comments
Labels
awaiting-pr Issues that await a PR that would implement/solve them enhancement feature-request

Comments

@monofon
Copy link

monofon commented May 21, 2018

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.

@mrkkrp
Copy link
Owner

mrkkrp commented May 21, 2018

I'll take a look. Probably this weekend. I'm quite busy these days so I can't assist immediately.

@mrkkrp
Copy link
Owner

mrkkrp commented May 23, 2018

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.

@mrkkrp
Copy link
Owner

mrkkrp commented May 24, 2018

Do you want to prepare a PR? That would be the fastest way forward.

@monofon
Copy link
Author

monofon commented May 25, 2018

I will see what I can do.

@mrkkrp mrkkrp added the awaiting-pr Issues that await a PR that would implement/solve them label May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-pr Issues that await a PR that would implement/solve them enhancement feature-request
Projects
None yet
Development

No branches or pull requests

2 participants