A downloadable extension

Download NowName your own price

Note: This extension is superseded by built-in functions in GM2023.6+

This  small extension allows you to create Zip archives from GameMaker games.

GMS2 version uses the recently added buffer_compress function and is GML-only (so should work on all native platforms).
GMS1 version requires my free buffer_zlib extension.

Functions:

  • zip_create(?compression_level)
    Creates a new Zip archive structure. Compression level can be 1..9 (from faster to better compression ratio), 0 (to skip compression), or -1 (to let runtime pick).
    GMS2 version assumes all non-zero compression levels to be -1 because buffer_compress doesn't have an argument for compression level (you can also import the GMS1 version and buffer_zlib though).
  • zip_destroy(zip)
    Destroys a previously created Zip archive structure. Don't forget!
  • zip_add_file(zip, path, file_path)
    Adds a copy of the given file to a to a Zip structure.
    For nesting, include slashes in path (e.g. "dir/test.txt").
  • zip_add_buffer(zip, path, buffer)
    Adds a copy of the given buffer to a Zip structure.
    Path handling is the same as with zip_add_file.
  • zip_add_buffer_ext(zip, path, buffer, pos, length)
    Same as zip_add_buffer but allows to only add a section of a buffer.
  • zip_save(zip, path)
    Finalizes the Zip structure (meaning that no new files can be written to it) and saves the archive to the given path.
  • zip_get_buffer(zip)
    Finalizes the Zip structure and returns its internal buffer.
    Current size will be indicated by the buffer's writing position (buffer_tell).
    Note that the buffer will be destroyed by zip_destroy.

Source code (uses sfgml, based on Haxe standard library zip writer)

StatusReleased
CategoryAssets
Rating
Rated 5.0 out of 5 stars
(3 total ratings)
AuthorYellowAfterlife
Made withGameMaker, Haxe
TagsGameMaker

Download

Download NowName your own price

Click download now to get access to the following files:

ZipWriterForGMS1.gmez 2.5 kB
ZipWriterForGMS2.gmez 2.6 kB
ZipWriterForGMS2.3+.yymps 4.2 kB

Comments

Log in with itch.io to leave a comment.

Hello, when using this extension, the archives created seem to be corrupt. I am using GM LTS?

I am getting this error when trying to extract the archive:

! C:\Users\madma\AppData\Local\MTG_Generator\Card Exports\zips\black death.zip: Checksum error in C:\Users\madma\AppData\Local\Temp\Rar$DIa10988.15865\Deathly Heirloom.png. The file is corrupt
! C:\Users\madma\AppData\Local\MTG_Generator\Card Exports\zips\black death.zip: The archive is corrupt

Answered in Discord, find

var _crc=buffer_crc32(_buf,_pos,_len)

and replace it with

var _crc=buffer_crc32(_buf,_pos,_len)^$FFFFFFFF

I don't understand how the extension works :(

(-1)

Like this

Was just trying to make one of these! Bless you!

Hey... this is pretty good!