Changes in the zip output file format over time

16 views
Skip to first unread message

Cefan Daniel Rubin

unread,
Oct 22, 2024, 7:43:13 AM10/22/24
to cosmopolitan cosmonauts
Hello all!

I am back to re-write a command-line tool using cosmopolitan libc after some time and notice that documentation about the zip output files seems missing. I note that there is now a .cosmo file reflecting a size of 0 bytes via unzip -l and usually much of the size of the file now just does not add up from such a listing. In addition I don't seem to be able to add files to the zip in the same way as before. Is this no longer an advertised superpower of the ape format? I think it was wonderful for distribution purposes so I am sorry if that is the case! I would like to add files and still load them via paths like 'zip:file.txt' from a program using cosmo libc.  Please direct me to docs about this if I have missed them! Thank you Justine and cosmonauts for a super interesting evolution of this work! Cheers.

 - Cefan

Justine Tunney

unread,
Oct 25, 2024, 9:14:55 PM10/25/24
to Cefan Daniel Rubin, cosmopolitan cosmonauts
I'm not sure if I really understand what you're asking. We still have zip assets in our executables. You can still add and remove from your zip exe. Are you using the zip command from https://cosmo.zip/pub/cosmos/bin/ ? Are you using cosmocc?

--
You received this message because you are subscribed to the Google Groups "cosmopolitan cosmonauts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cosmopolitan-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cosmopolitan-libc/22cc8498-a223-41ba-b0fc-6dd022a47ef1n%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cefan Daniel Rubin

unread,
Oct 28, 2024, 6:04:38 AM10/28/24
to cosmopolitan cosmonauts
Good morning Justine

Thank you for the reply. I believe in the past regular Info-ZIP worked for adding assets although it has been a while since I tried. The APE Info-ZIP at https://cosmo.zip/pub/cosmos/bin/zip did indeed add a file successfully! Really glad this is still possible. :) Please can we add something like this to the docs to help others too:

---
Binary archive format
The APE format includes another portability superpower: the ability to distribute application support files WITHIN the compiled executable file. This is because APE files are also mostly regular zip files! You will need a copy of a compatible zip tool like the modified version of Info-ZIP available here: https://cosmo.zip/pub/cosmos/bin/zip. With this in hand the following command:

zip [APE file] [support_file.txt]

adds support_file.txt to your executable. You can see it listed within the archive with `unzip -l [APE file]`. 

Cosmo libc includes compatible file handling functions for accessing the contents of an APE file at the special '/zip' path. So your code is now able to do the following:

     if (access( "/zip/support_file.txt", F_OK) == 0) {
        fprintf(stderr, "/zip/support_file.txt FOUND and can be used as an asset\n");
     }

---

It could go in https://github.com/jart/cosmopolitan/blob/master/README.md or https://github.com/jart/cosmopolitan/blob/master/tool/cosmocc/README.md? Happy to post a PR if you prefer, please let me know where you would like it. Thank you as ever, more joy does cosmo add to the world and I'm appreciative! 

 - Cefan

Justine Tunney

unread,
Oct 28, 2024, 2:03:30 PM10/28/24
to Cefan Daniel Rubin, cosmopolitan cosmonauts
Sounds good. Send me a PR and be sure to send the email mentioned in CONTRIBUTING.md.

Reply all
Reply to author
Forward
0 new messages