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

APE-is-also-a-ZIP clarifications #166

Closed
ahgamut opened this issue May 15, 2021 · 2 comments
Closed

APE-is-also-a-ZIP clarifications #166

ahgamut opened this issue May 15, 2021 · 2 comments

Comments

@ahgamut
Copy link
Collaborator

ahgamut commented May 15, 2021

I wanted to write a minimal example that uses the APE-is-also-a-ZIP feature, so I thought it would be helpful to collect the below info all at one spot (if there isn't already).

  1. Is every APE a ZIP file?
  2. Do I have to add any additional headers/object files to make the APE a ZIP?
  3. Alternatively, can I disable this feature when building the APE? Does disabling offer any benefit (binary size/speed)?
  4. After compilation, can I use zip/unzip or similar software to add data files to the APE?
  5. How do I add data files to the APE at compile time? Does it change if I'm adding multiple folders of files?
  6. Can I use regular filesystem calls (fopen etc.) on the internal ZIP store or are there custom functions?
  7. If using fopen etc. what location do I specify to read from the internal ZIP store?
  8. Can the APE "self-modify" itself at runtime i.e. write/add/delete files from its internal ZIP store?
  9. Can I use a compilation flag/runtime call to toggle the "self-modify" feature (eg only reads allowed)?
  10. Any important differences to note when loading a file from the internal store vs a local file (r/w speed, memory usage, OS-related issues)?
@jart
Copy link
Owner

jart commented May 16, 2021

  1. No. It usually becomes a zip if you link one of the functions that depend on tzdata
  2. I believe you can STATIC_YOINK("__zip_start") to force it to be a ZIP
  3. You can disable it by not needing it. See https://justine.lol/cosmopolitan/howfat.html
  4. Yes. Use the command zip foo.com somefile
  5. If you're using the monorepo, simply have you link command depend on FILENAME.zip.o which is auto-generated
  6. Yes you can, currently only for read, with limited system call support
  7. Simply say open("zip:FILENAME", O_RDONLY)
  8. Only redbean can at the moment. That functionality was added recently.
  9. n/a
  10. It might be faster. I haven't benchmarked it.

@jart jart closed this as completed May 16, 2021
@ahgamut
Copy link
Collaborator Author

ahgamut commented May 16, 2021

Understood. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants