Asset - Scripts GZIP utils - Create and extract zip, gzip and tar files - updated for GMS2

H

Homunculus

Guest

Version 1.0 for Game Maker: Studio 2 is available. It is now possible to create zip and gzip files!

GZIP utils is a set of utility scripts providing access to ZIP, GZIP and TAR file formats without requiring any external library (everything is written in GML). Moreover, you can also create zip and gzip files without even having an actual file on the filesystem by using the contents of a buffer instead.

This asset has been tested on the Mac and Windows export modules and is not compatible with HTML5 and javascript based modules. Drop me a note if you are interested in collaborating and testing the asset on other export modules.

Important: Due to the unavailability of specific GMS2 functions, the GMS1 version does not include the creation of zip and gzip files, and is no longer updated (although it is still available and stable).

Features
  • Create GZIP and ZIP archives from file or buffer data
  • Decompress GZIP files and expand TAR archives
  • Read ZIP and GZIP format metadata
  • No external library required
Resource link: GZIP utils - Markeplace
Documentation:
Manual and reference
Price: 3.99$
 
Last edited by a moderator:
H

Homunculus

Guest
Thanks! I haven't done any speed test yet, but I do expect some kind of bottleneck with respect to tar files. I didn't realize it until now, but tar files are bad. Like, REALLY bad. They are the de facto standard when gzipping though, can't do much about it.

I'll run a few tests, but decompression of regular gz files (no tar) should be pretty efficient.

A comparison with zip_unzip is probably the best way to go with this i think.
 
H

Homunculus

Guest
I ran some tests on different type of archives. The test run 10 times on a (really slow) virtual machine environment, and averaged the results. The GM zip_unzip function is really erratic in terms of time to decompress the same file, making the results a bit pointless... I even got a 4x unzip time difference on the same file.

Don't know if it's a problem of my machine or of the function to be honest... The trend however is that gzip_unzip is between 40% to 60% slower than zip_unzip on average.

I was able to extract archives of 3000 files / 350mb without problems though.
 
Last edited by a moderator:
H

Homunculus

Guest
Version 1.0 for GMS2 is out!
Create zip archives and gzip files in Game Maker: Studio 2 without any platform specific extension!

Finally, I was able to release version 1.0 of the asset (available for Game Maker: Studio 2 only) that adds the ability to create zip archives and gzip files, thanks to the new buffer_compress functionality.

Moreover, you don't even need to have the actual files on the filesystem, since you can just drop buffers in the archive as files.

A couple of sample snippets:

Create a zip archive
Code:
var _zip = zip_create();
zip_add_file(_zip, "data/items.csv");
zip_add_file(_zip, "saves/slot_1.sav");
zip_add_file(_zip, "saves/slot_2.sav");
_zip = zip_close(_zip);

if(_zip >= 0) { buffer_save(_zip, "backup.zip"); }
buffer_delete(_zip);
Generate a gzip file with the contents of a ds_map as a json file
Code:
var _json = json_encode(your_ds_map);

var _buffer = buffer_create(string_byte_length(_json), buffer_fixed, 1);
buffer_write(_buffer, buffer_text, _json);

var _gzip = gzip_create(_buffer, "data.json");
buffer_save(_gzip, "data.json.gz");

buffer_delete(_gzip);
buffer_delete(_buffer);
 

mbeytekin

Member
I contacted you via email but I want to ask my question here too.
I've just bought asset but I can't find zip_create() script in it. I guess there is a mistake in files.
 
H

Homunculus

Guest
Yeah I just replied by email as well, it's a typo in the docs and only in that snippet, the function should be zip_open() and not zip_create()
 
Top